[rules-users] Using from with named queries

rouvas at di.uoa.gr rouvas at di.uoa.gr
Wed Jul 28 09:06:46 EDT 2010


Hello list,

I'm using Drools.5.0.1 and I am trying to comprehend how to used the
"from" keyword over a named query.

I've googled this:
http://blog.athico.com/2007/06/chained-from-accumulate-collect.html

where it states:

p : Person( )
  Restaurant( food == p.favouriteFood )
                from hs.getNamedQuery( "list restaurants by postcode" )
                     .setProperties( [ "postcode" : p.address.zipcode ] )
                     .list()

If I understand the above correctly, the "hs.getNamedQuery" returns
"Restaurant" objects using values from "Person" object.

There are a couple of issues that I would like to resolve.

Where and how is the "hs" object in "hs.getNamedQuery" statement is declared?

If the "Person" object itself is the result of a NamedQuery, could the
above statement be rewritten as:

  p : Person( ) from ps.getNamedQuery("return list of persons")
  Restaurant( food == p.favouriteFood )
                from hs.getNamedQuery( "list restaurants by postcode" )
                     .setProperties( [ "postcode" : p.address.zipcode ] )
                     .list()

Thank you for your time.
-Stathis

PS: Please take note that this is a newbie (in Drools) speaking.





More information about the rules-users mailing list