What keeps you from using &#39;from&#39;?<br><br>Using one or more rules to expand your &quot;complex object&quot; won&#39;t work in a stateless<br>session, but consider using a stateful session, if only for expansion.<br>
<br>Annotations for requesting automatic expansion may not be in everybody&#39;s interest<br>since looking for runtime annotations is not for free, and there are other issues,<br>such as (in terms of your example) should only a Father&#39;s children be inserted and<br>
not a Mother&#39;s and how to control this.<br><br>For further discussions of your problem a less abstract approach (What do you<br>really need to do?) would be preferable.<br><br>-W<br><br><div class="gmail_quote">On Mon, Feb 8, 2010 at 10:56 AM, gazzaaa87 <span dir="ltr">&lt;<a href="mailto:dan_hopwood@hotmail.co.uk">dan_hopwood@hotmail.co.uk</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><br>
Hi all,<br>
<br>
I am using a StatelessKnowledgeSession and therefore call the execute method<br>
to invoke the rules engine. Having carried out a basic test, it would appear<br>
that calling execute on an arbitrarily complex object does not insert child<br>
objects, rather rules will only fire if they are based on the parent.<br>
<br>
e.g. let&#39;s say you have a class called &#39;Father&#39;, which holds a collection of<br>
&#39;Child&#39; objects. By calling session.execute(fatherObject) I need rules to<br>
fire that use the Child pattern without having to loop through &#39;insert&#39;ing<br>
all the child elements manually.<br>
<br>
Has anyone come across a way around this? Having originally posted on the<br>
dev forum there were a few suggestions:<br>
<br>
    - You could use the &quot;from&quot; keyword but your rules wouldn&#39;t work on *any*<br>
arbitrary object - but this could be overcome if you could identify a<br>
suitable super-class to extend for your arbitrary objects.<br>
    - Have you considered  using the &quot;from&quot; Conditional Element, which lets<br>
you reason over components of a fact&#39;s collection-type element, without them<br>
being inserted as facts. See the Drools Expert manual for details.<br>
    - One way it has been done in the past is to have some rule with a<br>
higher salience take that &quot;root&quot; object and &quot;explode&quot; it into the children<br>
objects (as deep as needed).<br>
<br>
The only thing I managed to find was the use of a Batch Executor but you<br>
have to set that up before calling execute and therefore it&#39;s still<br>
effectively a manual process.<br>
<br>
If only Drools used java annotations, it would be ideal to specify behaviour<br>
similar to cascade with JPA.<br>
<br>
Any help or pointers much appreciated!<br>
<br>
Dan<br>
<font color="#888888">--<br>
View this message in context: <a href="http://n3.nabble.com/Executing-on-a-arbitrarily-complex-object-tp192130p192130.html" target="_blank">http://n3.nabble.com/Executing-on-a-arbitrarily-complex-object-tp192130p192130.html</a><br>

Sent from the Drools - User mailing list archive at Nabble.com.<br>
_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
</font></blockquote></div><br>