<br>   You must be having a problem with the hibernate query then. Just as a test, try replacing the query call with an arbitrary method call that returns a couple objects.<br><br>   Edson<br><br><br><br><div class="gmail_quote">
2009/10/29 richarda <span dir="ltr">&lt;<a href="mailto:richard.ambridge@gmail.com">richard.ambridge@gmail.com</a>&gt;</span><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>
Using Drools 5.0.1<br>
<br>
I get the same results with the below rule.<br>
I leave the System.out.println in,  and the rule executes the number of<br>
times for the number of items that should be loaded from the hibernate,<br>
but each time the $o is still null.<br>
<br>
the insert seems to be ignored, audit shows no record of it,  but I assume<br>
insert(null)  is ignored by drools<br>
<div><div></div><div class="h5"><br>
<br>
Edson Tirelli-4 wrote:<br>
&gt;<br>
&gt;     Did you tried this?<br>
&gt;<br>
&gt;        when<br>
&gt;                 $m : MessageAsEvent(uuid==&quot;mesC:7&quot;)<br>
&gt;                 $o :  MessageAsEvent(uuid==&quot;mesC:7&quot;, id!=$<a href="http://m.id" target="_blank">m.id</a>) from<br>
&gt; hibernateSession.createQuery(&quot;from MessageAsEvent where<br>
&gt; serial=?&quot;).setParameter(0,$m.serial).list()<br>
&gt;        then<br>
&gt;                 insert($o)<br>
&gt;        end<br>
&gt;<br>
&gt;     In any case, collect should work too. Which version of drools are you<br>
&gt; using?<br>
&gt;<br>
&gt;     []s<br>
&gt;     Edson<br>
&gt;<br>
&gt; 2009/10/29 richarda &lt;<a href="mailto:richard.ambridge@gmail.com">richard.ambridge@gmail.com</a>&gt;<br>
&gt;<br>
&gt;&gt;<br>
&gt;&gt; Hi again,<br>
&gt;&gt;<br>
&gt;&gt; I wish to have a rule that when an Event has a certain uuid then load<br>
&gt;&gt; into<br>
&gt;&gt; working memory all other events that have been received for this unit...<br>
&gt;&gt;<br>
&gt;&gt; So I write the rule:<br>
&gt;&gt;<br>
&gt;&gt; rule &quot;Repeating&quot;<br>
&gt;&gt;<br>
&gt;&gt;        when<br>
&gt;&gt;                 $m : MessageAsEvent(uuid==&quot;mesC:7&quot;)<br>
&gt;&gt;                 $others : LinkedList() from collect (<br>
&gt;&gt;                           MessageAsEvent(uuid==&quot;mesC:7&quot;, id!=$<a href="http://m.id" target="_blank">m.id</a>)<br>
&gt;&gt;                               from hibernateSession.createQuery(&quot;from<br>
&gt;&gt; MessageAsEvent where<br>
&gt;&gt; serial=?&quot;).setParameter(0,$m.serial).list()<br>
&gt;&gt;                        )<br>
&gt;&gt;        then<br>
&gt;&gt;                System.out.println(&quot;Gathering m=&quot;+$m+&quot; data=&quot;+$others);<br>
&gt;&gt; end<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; Audit log shows: (wish cut and paste would work from Eclipse audit view)<br>
&gt;&gt;<br>
&gt;&gt;  &lt;activationId&gt;Repeating [131, 14]&lt;/activationId&gt;<br>
&gt;&gt;  &lt;rule&gt;Repeating FAN&lt;/rule&gt;<br>
&gt;&gt;  &lt;declarations&gt;$others=[MessageAsEvent:[124] uuid=mesC:7 serial=serial123<br>
&gt;&gt; count=7, MessageAsEvent:[94] uuid=mesC:7 serial=serial123 count=7,<br>
&gt;&gt; MessageAsEvent:[64] uuid=mesC:7 serial=serial123 count=7,<br>
&gt;&gt; MessageAsEvent:[118] uuid=mesC:7 serial=serial123 count=7,<br>
&gt;&gt; MessageAsEvent:[112] uuid=mesC:7 serial=serial123 count=7,<br>
&gt;&gt; MessageAsEvent:[106] uuid=mesC:7 serial=serial123 count=7,<br>
&gt;&gt; MessageAsEvent:[100] uuid=mesC:7 serial=serial123 count=7,<br>
&gt;&gt; MessageAsEvent:[88] uuid=mesC:7 serial=serial123 count=7,<br>
&gt;&gt; MessageAsEvent:[82] uuid=mesC:7 serial=serial123 count=7,<br>
&gt;&gt; MessageAsEvent:[76] uuid=mesC:7 serial=serial123 count=7,<br>
&gt;&gt; MessageAsEvent:[70] uuid=mesC:7 serial=serial123 count=7,<br>
&gt;&gt; MessageAsEvent:[58] uuid=mesC:7 serial=serial123 count=7,<br>
&gt;&gt; MessageAsEvent:[52] uuid=mesC:7 serial=serial123 count=7,<br>
&gt;&gt; MessageAsEvent:[46] uuid=mesC:7 serial=serial123 count=7,<br>
&gt;&gt; MessageAsEvent:[40] uuid=mesC:7 serial=serial123 count=7,<br>
&gt;&gt; MessageAsEvent:[34] uuid=mesC:7 serial=serial123 count=7](131);<br>
&gt;&gt; $m=MessageAsEvent:[130] uuid=mesC:7 serial=serial123<br>
&gt;&gt; count=7(14)&lt;/declarations&gt;<br>
&gt;&gt;  &lt;ruleFlowGroup&gt;Gathering&lt;/ruleFlowGroup&gt;<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; So, you can see that the rule fired with $others having all the data,<br>
&gt;&gt; and<br>
&gt;&gt; $m being the main uuid<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; but the output of the rule is:<br>
&gt;&gt; Gathering m=MessageAsEvent:[130] uuid=mesC:7 serial=serial123 count=7<br>
&gt;&gt; data=null<br>
&gt;&gt;<br>
&gt;&gt; so, the $others has been translated to a null.<br>
&gt;&gt;<br>
&gt;&gt; I&#39;m trying to copy the Expert example:<br>
&gt;&gt;<br>
&gt;&gt; import java.util.LinkedList;<br>
&gt;&gt;<br>
&gt;&gt; rule &quot;Send a message to all mothers&quot;<br>
&gt;&gt; when<br>
&gt;&gt;    $town : Town( name == &#39;Paris&#39; )<br>
&gt;&gt;    $mothers : LinkedList()<br>
&gt;&gt;               from collect( Person( gender == &#39;F&#39;, children &gt; 0 )<br>
&gt;&gt;                             from $town.getPeople()<br>
&gt;&gt;                           )<br>
&gt;&gt; then<br>
&gt;&gt;    # send a message to all mothers<br>
&gt;&gt; end<br>
&gt;&gt;<br>
&gt;&gt; which indicates that $mothers will be available in the RHS<br>
&gt;&gt;<br>
&gt;&gt; for reference, the audit log shows when the rule fires:<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; &lt;org.drools.audit.event.ActivationLogEvent&gt;<br>
&gt;&gt;  &lt;type&gt;6&lt;/type&gt;<br>
&gt;&gt;  &lt;activationId&gt;Repeating [-1, 14]&lt;/activationId&gt;<br>
&gt;&gt;  &lt;rule&gt;Repeating FAN&lt;/rule&gt;<br>
&gt;&gt;  &lt;declarations&gt;$m=MessageAsEvent:[130] uuid=mesC:7 serial=serial123<br>
&gt;&gt; count=7(14)&lt;/declarations&gt;<br>
&gt;&gt;  &lt;ruleFlowGroup&gt;Gathering&lt;/ruleFlowGroup&gt;<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; What am I doing wrong?<br>
&gt;&gt; I basically want all the MessageAsEvent added to working memory, so later<br>
&gt;&gt; other rules will do work on all the events.<br>
&gt;&gt;<br>
&gt;&gt; Cheers<br>
&gt;&gt; Ric<br>
&gt;&gt;<br>
&gt;&gt; --<br>
&gt;&gt; View this message in context:<br>
&gt;&gt; <a href="http://www.nabble.com/Collect-and-hibernate-tp26112042p26112042.html" target="_blank">http://www.nabble.com/Collect-and-hibernate-tp26112042p26112042.html</a><br>
&gt;&gt; Sent from the drools - user mailing list archive at Nabble.com.<br>
&gt;&gt;<br>
&gt;&gt; _______________________________________________<br>
&gt;&gt; rules-users mailing list<br>
&gt;&gt; <a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
&gt;&gt; <a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
&gt;&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; --<br>
&gt;  Edson Tirelli<br>
&gt;  JBoss Drools Core Development<br>
&gt;  JBoss by Red Hat @ <a href="http://www.jboss.com" target="_blank">www.jboss.com</a><br>
&gt;<br>
&gt; _______________________________________________<br>
&gt; rules-users mailing list<br>
&gt; <a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
&gt; <a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
&gt;<br>
&gt;<br>
<br>
--<br>
</div></div>View this message in context: <a href="http://www.nabble.com/Collect-and-hibernate-tp26112042p26113182.html" target="_blank">http://www.nabble.com/Collect-and-hibernate-tp26112042p26113182.html</a><br>
<div><div></div><div class="h5">Sent from the drools - user mailing list archive at Nabble.com.<br>
<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>
</div></div></blockquote></div><br><br clear="all"><br>-- <br>  Edson Tirelli<br>  JBoss Drools Core Development<br>  JBoss by Red Hat @ <a href="http://www.jboss.com">www.jboss.com</a><br>