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

Wolfgang Laun wolfgang.laun at gmail.com
Tue Jan 7 12:09:05 EST 2014


If you have a rule
   rule "a Person" when
       $p: Person()
   then ... end
does it fire? What about the list if you insert just one Person?

-W

PS: Try to format your posts like everybody else, please.

On 07/01/2014, glambert27 <glambe2 at hotmail.com> wrote:
> 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.


More information about the rules-users mailing list