The code you have posted suggests to me that you do something like
   A a = new A();
   kSession.insert( a );
   a.setAge( 28 );
   kSession.fireAllRules();

Complete the object before you insert it or call update after the
modification.

-W


On 1 August 2011 10:04, gbelin <gbelin_s...@hotmail.com> wrote:

> I have a problem with int data in drools.
>
> I have created a test class for persons with it setters and getters:
>
> /public class A {
>
>        private int age;
>        private String sex;
>        private String name;
>
>        public A () {
>                System.out.println ("creating A.");
>        }/
>
> I have a rule that gets the person with de min age
>
>
> /rule "min age"
>        ruleflow-group 'group1'
>        salience 10
>        when
>                $a : A ()
>                not A (age<$a.age)
>        then
>                System.out.println ("  *** the min age "+$a.getAge()+"
> corresponds to " +
> $a.getName());
> end
> /
>
>
> I insert 4 persons in the knowledge base with different ages, then, when I
> run the rule, it returns all the 4 persons.
>
> If I set another rule with more priority that sets the ages of all persons,
> then the "min age" rule works propertly and write the message for the
> person
> with de minimun age.
>
> /rule "set age"
>        ruleflow-group 'group1'
>        salience 11
>        no-loop
>        when
>                $a : A ()
>        then
>                $a.setAge($a.getAge());
>                update($a);
>                System.out.println( "Person " + $a.getName() + " has an age
> of " +
> $a.getAge() + " years" );
> end
> /
>
>
> Is there any problem with drools and ints?
>
> Thanks in advance.
>
>
>
>
>
> --
> View this message in context:
> http://drools.46999.n3.nabble.com/java-int-problem-tp3215383p3215383.html
> Sent from the Drools: User forum mailing list archive at Nabble.com.
> _______________________________________________
> rules-users mailing list
> rules-users@lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
_______________________________________________
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users

Reply via email to