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