Or may be something more basic : drools does not 'interpret' Integer types as 
int, so == is testing object references ...
This explanation explain why it compiles but not working, whereas if my 
previous ideas are right, it should raise a compilation error ...

Try using 'int', or use Integer.valueOf(1) (that will return a shared instance 
of Integer).
But this is still very strange as doing the same test in java works (Integer is 
treated as a int, and == is testing values ...)


----- Mail original -----
De: "Vincent LEGENDRE" <vincent.legen...@eurodecision.com>
À: "Rules Users List" <rules-users@lists.jboss.org>
Envoyé: Jeudi 12 Avril 2012 20:44:41
Objet: Re: [rules-users] Trying to compare variables of two objects,    not 
working. (compiles, but not desired result)

I think (not sure) that the problem comes from the right part of your test : 
$lineItem.ID 
Try with $lineItem.getID(), or use 'dialect "mvel"' as rule property

You can also bind the id in LineItem and test it in the next pattern :
 
rule "Test"
    when
        $lineItem : LineItem( $lineID : ID > 0 )
        $trans : TransactionItem( ID > 0, AccountName != null, LineItemID == 
$lineID)
        $amount : AccountingItem( TransactionID > 0, CalculatedCommission > 0.0 
)
    then
        System.out.println( $amount.getCalculatedCommission() + " " + 
$lineItem.getID() );
end


But this is very strange. To me it should work ...

What is not usual too is your use of "_" before member attributes (let me 
guess, you did a lot of C++ ?), which is not the java POJO standards. And may 
be that drools relies on fields names too ...
And inside your tests, instead of "LineItemID" you should use "lineItemID" 
(with a lower case letter first, like the name your internal attribute should 
have, following the common java conventions).

But if all of this is a problem, the symptom should be a compilation error .... 
so it is still strange ...
_______________________________________________
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