[rules-users] Duplicate Facts with overriden equals/hashcode

glambert27 glambe2 at hotmail.com
Tue Jan 7 11:30:14 EST 2014


Hi,I have an issue I'm trying to track down and won't to rule out the data
being an issue. Running 5.5 ExpertI have a Fact; let's say "Person"Class
Person {private String fName;private String lName;private String
ssn;getters/setters at Overridepublic boolean equals(final Object obj) {       
if ( obj == null ) return false;           if(obj instanceof Person){             
final Person other = (Person) obj;              return Objects.equal(ssn,
other.ssn);           } else{            return false;        }}   
@Override    public int hashCode(){        return Objects.hashCode(ssn);   
}}Now if I insert 2 person objects with the same ssn. Actually if my LHS is
$list : ArrayList() collect( Person() ), do I expect 2, 1, or 0 for my
arraylist. What is seeing is that the arraylist is 0 but that doesn't make
sense to me and I think there is another underline issue.



--
View this message in context: http://drools.46999.n3.nabble.com/Duplicate-Facts-with-overriden-equals-hashcode-tp4027569.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20140107/d2bf27ef/attachment.html 


More information about the rules-users mailing list