[rules-users] Simple rule and Query

DECOUX Yannick yannick.decoux at ucm.be
Thu Apr 14 02:43:15 EDT 2011


Hi everyone,

I'am still stuck with this simple example, anyone can tell me where to look or what I'm missing ?

Thanks
Yannick


De : DECOUX Yannick [mailto:yannick.decoux at ucm.be]
Envoyé : mardi 5 avril 2011 07:52
À : rules-users at lists.jboss.org
Objet : [rules-users] Simple rule and Query

Hi,

I'am trying to use Query and i'am facing a little problem :
Given this simple rule :

package be.test.person
import be.test.person.*

query "get adult"
      adult : Adult( )
end

query "get person"
      person : Person( )
end

declare Adult
      name : String
end

rule "A person over 18 is an adult"
      when
            Person( age >= 18)
      then
            System.out.println("Adult detected");
            insert(new Adult());
end

Lets suppose one Person over 18 is inserted inside the working memory, the result of the query « get adult » is 0 (Please note the declaration of Adult type inside the rule)
If I create a Java class Adult (commenting the one in the .drl file) and then run the query again, this time the result is 1
Also, the signature of org.drools.runtime.rule.WorkingMemory.getQueryResults(String) says IllegalArgumentException when query is not found in the KnowledgeBase. This doesn't seems to be the case when I use a fake query name.
I'am using drools 5.1.1

Any idea on this ?

Thanks

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20110414/869b020e/attachment.html 


More information about the rules-users mailing list