<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 hibernateSession.createQuery("from MessageAsEvent where 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 using?<br><br> []s<br> Edson<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>
Hi again,<br>
<br>
I wish to have a rule that when an Event has a certain uuid then load 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 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, 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>
<font color="#888888"><br>
--<br>
View this message in context: <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>
</font></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>