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@ucm.be]
Envoyé : mardi 5 avril 2011 07:52
À : rules-users@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