[rules-users] java int problem

gbelin gbelin_saiz at hotmail.com
Mon Aug 1 04:04:18 EDT 2011


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.



More information about the rules-users mailing list