The code you have posted suggests to me that you do something like<br> A a = new A();<br> kSession.insert( a );<br> a.setAge( 28 );<br> kSession.fireAllRules();<br><br>Complete the object before you insert it or call update after the modification.<br>
<br>-W<br><br><br><div class="gmail_quote">On 1 August 2011 10:04, gbelin <span dir="ltr"><<a href="mailto:gbelin_saiz@hotmail.com">gbelin_saiz@hotmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
I have a problem with int data in drools.<br>
<br>
I have created a test class for persons with it setters and getters:<br>
<br>
/public class A {<br>
<br>
private int age;<br>
private String sex;<br>
private String name;<br>
<br>
public A () {<br>
System.out.println ("creating A.");<br>
}/<br>
<br>
I have a rule that gets the person with de min age<br>
<br>
<br>
/rule "min age"<br>
ruleflow-group 'group1'<br>
salience 10<br>
when<br>
$a : A ()<br>
not A (age<$a.age)<br>
then<br>
System.out.println (" *** the min age "+$a.getAge()+" corresponds to " +<br>
$a.getName());<br>
end<br>
/<br>
<br>
<br>
I insert 4 persons in the knowledge base with different ages, then, when I<br>
run the rule, it returns all the 4 persons.<br>
<br>
If I set another rule with more priority that sets the ages of all persons,<br>
then the "min age" rule works propertly and write the message for the person<br>
with de minimun age.<br>
<br>
/rule "set age"<br>
ruleflow-group 'group1'<br>
salience 11<br>
no-loop<br>
when<br>
$a : A ()<br>
then<br>
$a.setAge($a.getAge());<br>
update($a);<br>
System.out.println( "Person " + $a.getName() + " has an age of " +<br>
$a.getAge() + " years" );<br>
end<br>
/<br>
<br>
<br>
Is there any problem with drools and ints?<br>
<br>
Thanks in advance.<br>
<font color="#888888"><br>
<br>
<br>
<br>
<br>
--<br>
View this message in context: <a href="http://drools.46999.n3.nabble.com/java-int-problem-tp3215383p3215383.html" target="_blank">http://drools.46999.n3.nabble.com/java-int-problem-tp3215383p3215383.html</a><br>
Sent from the Drools: User forum mailing list archive at Nabble.com.<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>
</font></blockquote></div><br>