<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"><<a href="mailto:richard.ambridge@gmail.com">richard.ambridge@gmail.com</a>></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>
><br>
> Did you tried this?<br>
><br>
> when<br>
> $m : MessageAsEvent(uuid=="mesC:7")<br>
> $o : MessageAsEvent(uuid=="mesC:7", id!=$<a href="http://m.id" target="_blank">m.id</a>) from<br>
> hibernateSession.createQuery("from MessageAsEvent where<br>
> serial=?").setParameter(0,$m.serial).list()<br>
> then<br>
> insert($o)<br>
> end<br>
><br>
> In any case, collect should work too. Which version of drools are you<br>
> using?<br>
><br>
> []s<br>
> Edson<br>
><br>
> 2009/10/29 richarda <<a href="mailto:richard.ambridge@gmail.com">richard.ambridge@gmail.com</a>><br>
><br>
>><br>
>> Hi again,<br>
>><br>
>> I wish to have a rule that when an Event has a certain uuid then load<br>
>> into<br>
>> working memory all other events that have been received for this unit...<br>
>><br>
>> So I write the rule:<br>
>><br>
>> rule "Repeating"<br>
>><br>
>> when<br>
>> $m : MessageAsEvent(uuid=="mesC:7")<br>
>> $others : LinkedList() from collect (<br>
>> MessageAsEvent(uuid=="mesC:7", id!=$<a href="http://m.id" target="_blank">m.id</a>)<br>
>> from hibernateSession.createQuery("from<br>
>> MessageAsEvent where<br>
>> serial=?").setParameter(0,$m.serial).list()<br>
>> )<br>
>> then<br>
>> System.out.println("Gathering m="+$m+" data="+$others);<br>
>> end<br>
>><br>
>><br>
>> Audit log shows: (wish cut and paste would work from Eclipse audit view)<br>
>><br>
>> <activationId>Repeating [131, 14]</activationId><br>
>> <rule>Repeating FAN</rule><br>
>> <declarations>$others=[MessageAsEvent:[124] uuid=mesC:7 serial=serial123<br>
>> count=7, MessageAsEvent:[94] uuid=mesC:7 serial=serial123 count=7,<br>
>> MessageAsEvent:[64] uuid=mesC:7 serial=serial123 count=7,<br>
>> MessageAsEvent:[118] uuid=mesC:7 serial=serial123 count=7,<br>
>> MessageAsEvent:[112] uuid=mesC:7 serial=serial123 count=7,<br>
>> MessageAsEvent:[106] uuid=mesC:7 serial=serial123 count=7,<br>
>> MessageAsEvent:[100] uuid=mesC:7 serial=serial123 count=7,<br>
>> MessageAsEvent:[88] uuid=mesC:7 serial=serial123 count=7,<br>
>> MessageAsEvent:[82] uuid=mesC:7 serial=serial123 count=7,<br>
>> MessageAsEvent:[76] uuid=mesC:7 serial=serial123 count=7,<br>
>> MessageAsEvent:[70] uuid=mesC:7 serial=serial123 count=7,<br>
>> MessageAsEvent:[58] uuid=mesC:7 serial=serial123 count=7,<br>
>> MessageAsEvent:[52] uuid=mesC:7 serial=serial123 count=7,<br>
>> MessageAsEvent:[46] uuid=mesC:7 serial=serial123 count=7,<br>
>> MessageAsEvent:[40] uuid=mesC:7 serial=serial123 count=7,<br>
>> MessageAsEvent:[34] uuid=mesC:7 serial=serial123 count=7](131);<br>
>> $m=MessageAsEvent:[130] uuid=mesC:7 serial=serial123<br>
>> count=7(14)</declarations><br>
>> <ruleFlowGroup>Gathering</ruleFlowGroup><br>
>><br>
>><br>
>><br>
>> So, you can see that the rule fired with $others having all the data,<br>
>> and<br>
>> $m being the main uuid<br>
>><br>
>><br>
>> but the output of the rule is:<br>
>> Gathering m=MessageAsEvent:[130] uuid=mesC:7 serial=serial123 count=7<br>
>> data=null<br>
>><br>
>> so, the $others has been translated to a null.<br>
>><br>
>> I'm trying to copy the Expert example:<br>
>><br>
>> import java.util.LinkedList;<br>
>><br>
>> rule "Send a message to all mothers"<br>
>> when<br>
>> $town : Town( name == 'Paris' )<br>
>> $mothers : LinkedList()<br>
>> from collect( Person( gender == 'F', children > 0 )<br>
>> from $town.getPeople()<br>
>> )<br>
>> then<br>
>> # send a message to all mothers<br>
>> end<br>
>><br>
>> which indicates that $mothers will be available in the RHS<br>
>><br>
>> for reference, the audit log shows when the rule fires:<br>
>><br>
>><br>
>> <org.drools.audit.event.ActivationLogEvent><br>
>> <type>6</type><br>
>> <activationId>Repeating [-1, 14]</activationId><br>
>> <rule>Repeating FAN</rule><br>
>> <declarations>$m=MessageAsEvent:[130] uuid=mesC:7 serial=serial123<br>
>> count=7(14)</declarations><br>
>> <ruleFlowGroup>Gathering</ruleFlowGroup><br>
>><br>
>><br>
>> What am I doing wrong?<br>
>> I basically want all the MessageAsEvent added to working memory, so later<br>
>> other rules will do work on all the events.<br>
>><br>
>> Cheers<br>
>> Ric<br>
>><br>
>> --<br>
>> View this message in context:<br>
>> <a href="http://www.nabble.com/Collect-and-hibernate-tp26112042p26112042.html" target="_blank">http://www.nabble.com/Collect-and-hibernate-tp26112042p26112042.html</a><br>
>> 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>
>><br>
><br>
><br>
><br>
> --<br>
> Edson Tirelli<br>
> JBoss Drools Core Development<br>
> JBoss by Red Hat @ <a href="http://www.jboss.com" target="_blank">www.jboss.com</a><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>
><br>
><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>