This seems to be fixed for 5.2.x.:<br><br>declare Num<br>  num : Integer<br>end<br><br>rule sort<br>when<br>    Integer( $i: intValue )<br>then<br>    insert( new Num( $i ) );<br>end<br><br>query numbers<br>    $a: Num( $b: num )<br>
end<br><br><br>    QueryResults qRes = session.getQueryResults( &quot;numbers&quot; );<br>    System.out.println( &quot;result count: &quot; + qRes.size() );<br>    for( QueryResultsRow row: qRes ){<br>        Object obj = row.get( &quot;$b&quot; );<br>
    System.out.println( &quot;$b=&quot; + obj.toString() );<br>    }<br><br>This produces the expected results.<br><br>Calling getQueryResults with a string not denoting an existing query returns an empty result set. I&#39;ve updated the javadoc - thanks.<br>
<br>-W<br><br><br><br><br><br><div class="gmail_quote">2011/4/14 DECOUX Yannick <span dir="ltr">&lt;<a href="mailto:yannick.decoux@ucm.be">yannick.decoux@ucm.be</a>&gt;</span><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">

<div link="blue" vlink="purple" lang="FR-BE"><div><p class="MsoNormal"><span style="color: rgb(31, 73, 125);">query numbers<br>    $a: Num( $b: num )<br>end<br>Hi everyone,</span></p><p class="MsoNormal"><span style="color: rgb(31, 73, 125);"> </span></p>
<p class="MsoNormal"><span style="color: rgb(31, 73, 125);">I’am still stuck with this simple example, anyone can tell me where to look or what I’m missing ?</span></p><p class="MsoNormal"><span style="color: rgb(31, 73, 125);"> </span></p>
<p class="MsoNormal"><span style="color: rgb(31, 73, 125);">Thanks</span></p><p class="MsoNormal"><span style="color: rgb(31, 73, 125);">Yannick</span></p><p class="MsoNormal"><span style="color: rgb(31, 73, 125);"> </span></p>
<p class="MsoNormal"><span style="color: rgb(31, 73, 125);"> </span></p><div><div style="border-style: solid none none; border-color: rgb(181, 196, 223) -moz-use-text-color -moz-use-text-color; border-width: 1pt medium medium; padding: 3pt 0cm 0cm;">
<p class="MsoNormal"><b><span style="font-size: 10pt;" lang="FR">De :</span></b><span style="font-size: 10pt;" lang="FR"> DECOUX Yannick [mailto:<a href="mailto:yannick.decoux@ucm.be" target="_blank">yannick.decoux@ucm.be</a>] <br>
<b>Envoyé :</b> mardi 5 avril 2011 07:52<br><b>À :</b> <a href="mailto:rules-users@lists.jboss.org" target="_blank">rules-users@lists.jboss.org</a><br><b>Objet :</b> [rules-users] Simple rule and Query</span></p></div></div>
<p class="MsoNormal"> </p><p class="MsoNormal">Hi,</p><p class="MsoNormal"> </p><p class="MsoNormal">I’am trying to use Query and i’am facing a little problem :</p><p class="MsoNormal">Given this simple rule : </p><p class="MsoNormal">
 </p><p class="MsoNormal" style=""><b><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(150, 0, 0);">package</span></b><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;"> be.test.person</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"></span></p>
<p class="MsoNormal" style=""><b><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(150, 0, 0);">import</span></b><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;"> be.test.person.*</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"></span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"> </span></p><p class="MsoNormal" style=""><b><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(150, 0, 0);">query</span></b><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;"> </span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: green;">&quot;get adult&quot;</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"></span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;">      adult : Adult( )</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"></span></p>
<p class="MsoNormal" style=""><b><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(150, 0, 0);">end</span></b><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"></span></p><p class="MsoNormal" style="">
<span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"> </span></p><p class="MsoNormal" style=""><b><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(150, 0, 0);">query</span></b><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;"> </span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: green;">&quot;get person&quot;</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"></span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;">      person : Person( )</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"></span></p>
<p class="MsoNormal" style=""><b><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(150, 0, 0);">end</span></b><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"></span></p><p class="MsoNormal" style="">
<span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"> </span></p><p class="MsoNormal" style=""><b><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(150, 0, 0);">declare</span></b><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;"> Adult</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"></span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;">      name : String</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"></span></p><p class="MsoNormal" style="">
<b><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(150, 0, 0);">end</span></b><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"></span></p><p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"> </span></p>
<p class="MsoNormal" style=""><b><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(150, 0, 0);">rule</span></b><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;"> </span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: green;">&quot;A person over 18 is an adult&quot;</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;"> </span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"></span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;">      </span><b><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(150, 0, 0);">when</span></b><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"></span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;">            Person( age &gt;= 18)</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"></span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;">      </span><b><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(150, 0, 0);">then</span></b><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;"> </span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"></span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;">            System.out.println(</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: green;">&quot;Adult detected&quot;</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;">);</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"></span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;">            </span><b><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(150, 0, 0);">insert</span></b><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;">(</span><b><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(150, 0, 0);">new</span></b><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;"> Adult());         </span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"></span></p>
<p class="MsoNormal"><b><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(150, 0, 0);">end</span></b></p><p class="MsoNormal"><b><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(150, 0, 0);"> </span></b></p>
<p class="MsoNormal">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)</p><p class="MsoNormal">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</p>
<p class="MsoNormal">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.</p>
<p class="MsoNormal">I’am using drools 5.1.1</p><p class="MsoNormal"> </p><p class="MsoNormal">Any idea on this ?</p><p class="MsoNormal"> </p><p class="MsoNormal">Thanks</p><p class="MsoNormal"> </p></div></div><br>_______________________________________________<br>

rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
<br></blockquote></div><br>