Are your EJB3 beans merely JPA annotated, or state(full\less) session beans?<br><br>Drools can create new instance of JPA annotated beans, as there&#39;s simply POJOs however if for stateful\stateless session beans your contain will handle life-cycle.<br>
<br>The associations you describe are part of your domain model and therefore Drools rules can achieve what you describe. Here&#39;s a simple example:-<br><br><span style="font-family: courier new,monospace;">rule &quot;ensure all documents have a summary line&quot;</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">when</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">    $d : Document( )</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">    not Line( document == $d, lineType == &quot;summaryLine&quot; )</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">then</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">    Line newLine = new Line();</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">    newLine.setDocument( $d );</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">    insert(newLine);</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">end</span><br style="font-family: courier new,monospace;">
<br>Your exact implementation will depend upon your object model.<br><br>With kind regards,<br><br>Mike<br><br><div class="gmail_quote">2011/2/19 Thomas Adler <span dir="ltr">&lt;<a href="mailto:thomas.adler@live.com">thomas.adler@live.com</a>&gt;</span><br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">



<div>
Hi,<br><br>I am trying to use Drools and I would like to check whether such scenario could work:<br>I have facts Document and Line (EJB3 beans, in fact). And Document class has attribute:<br>List&lt;Line&gt; lines<br><br>
So - I would like to pass to stateless session a Document instance &quot;document&quot; and I would like to write rule, that<br>1) create some new Lines;<br>2) calculates total from lines;<br>3) updates document.total;<br>
4) add new Lines instances, that where created during the rule execution to document.lines;<br>And at the end of execution of this session I will like to do some other things with document and document.lines, e.g. persist in database.<br>
<br>So - can Drools handle such create of associations during the session execution?<br><br>Thanks!<br>Thomas  <br>                                               </div>
<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>
<br></blockquote></div><br>