[rules-users] Why might "collect from" not work?

KDR dr.soprano at neverbox.com
Thu Aug 27 07:20:14 EDT 2009


Based on the examples in the Drools Expert documentation, I have a rule like
this (simplified version here):

when
 Search($t : town)
 $results : ArrayList()
    from collect ( Person (town == $t) )

  # $p: Person(town == $t) # this works
then
 System.out.println("Matches for " + $t);
 System.out.println($results.size()); # this produces 0!
# System.out.println($p.getName()); # this works
end

When I use instead the commented out lines in the "when" and "then", it
prints out a list of names of matching people.

However when I tried to collect the matching people into an ArrayList for
use in the "then", I got nothing, so I tried to test it by printing out the
size of the list as shown above, and I found that the size was 0, so it's
clearly not collecting matching people into the list even though it works
fine individually.

Can anyone suggest what might be going wrong please? 

Thanks in advance for any help.

Cheers.
-- 
View this message in context: http://www.nabble.com/Why-might-%22collect-from%22-not-work--tp25167528p25167528.html
Sent from the drools - user mailing list archive at Nabble.com.




More information about the rules-users mailing list