I’am using 5.2.0-SNAPSHOT using maven from https://repository.jboss.org/nexus/content/groups/public/ and i can’t make it work…
The query still return a size of 0…
Can you share your entire project with me ?
Thanks
De : Wolfgang Laun [mailto:wolfgang.laun@gmail.com]
Envoyé : jeudi 14 avril 2011 09:34
À : Rules Users List
Objet : Re: [rules-users] Simple rule and Query
This seems to be fixed for 5.2.x.:
declare Num
num : Integer
end
rule sort
when
Integer( $i: intValue )
then
insert( new Num( $i ) );
end
query numbers
$a: Num( $b: num )
end
QueryResults qRes = session.getQueryResults( "numbers" );
System.out.println( "result count: " + qRes.size() );
for( QueryResultsRow row: qRes ){
Object obj = row.get( "$b" );
System.out.println( "$b=" + obj.toString() );
}
This produces the expected results.
Calling getQueryResults with a string not denoting an existing query returns an empty result set. I've updated the javadoc - thanks.
-W
2011/4/14 DECOUX Yannick <yannick.decoux@ucm.be>
query numbers
$a: Num( $b: num )
end
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
_______________________________________________
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users