[rules-users] Fw: [drools-user] identity vs equality question - drools use of equals()

guillaume.tardif at sgcib.com guillaume.tardif at sgcib.com
Wed Jan 24 08:17:14 EST 2007


Hi,

I have a similar problem when using objects from an external framework as 
facts : the equals method is invoked despite using the 
WM_BEHAVIOR_IDENTITYproperty.

Here is an exmple reproducing this with JBoss Rules 3.0.5 : I have created 
a JBoss Rules project under Eclipse, and created 2 classes MyObject and 
MyObject2. 
These classes have hashCode() returning 0 and equals throwing a 
ClassCastException when comparing 2 object of different classes



Actually, after debugging a bit, it seems that  the equals method is 
invoked by the TruthMaintenanceSystem.assertMap, which has a hardcoded 
EqualityKeyComparator (never set to IdentityKeyComparator). 
The WorkingMemory.assertMap has its KetComparator set correctly to 
IdentityKeyComparator
Also, the equals method is not called when the hashCode() method returns 
different values for different objects, which makes it a bit harder to 
reproduce the issue.

This is a roadblock for using JBoss Rules in our context ; has someone any 
idea for a workaround?

Thanks in advance,
Guillaume
*************************************************************************
This message and any attachments (the "message") are confidential and intended solely for the addressee(s).
Any unauthorised use or dissemination is prohibited. E-mails are susceptible to alteration.   
Neither SOCIETE GENERALE nor any of its subsidiaries or affiliates shall be liable for the message if altered, changed or falsified.
                              ************
Ce message et toutes les pieces jointes (ci-apres le "message") sont confidentiels et etablis a l'intention exclusive de ses
destinataires. Toute utilisation ou diffusion non autorisee est interdite. Tout message electronique est susceptible d'alteration. 
La SOCIETE GENERALE et ses filiales declinent toute responsabilite au titre de ce message s'il a ete altere, deforme ou falsifie.
*************************************************************************
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20070124/10e1b6e7/attachment.html 
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: stackTrace.txt
Url: http://lists.jboss.org/pipermail/rules-users/attachments/20070124/10e1b6e7/attachment.txt 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: IdentityIssueTest.zip
Type: application/zip
Size: 7372 bytes
Desc: not available
Url : http://lists.jboss.org/pipermail/rules-users/attachments/20070124/10e1b6e7/attachment.zip 


More information about the rules-users mailing list