[jboss-dev-forums] [EJB3 Development] - Re: Entity hashCode and equals overriding

fabio valsecchi do-not-reply at jboss.com
Sat Jan 5 12:50:44 EST 2013


fabio valsecchi [https://community.jboss.org/people/fabiovalse] created the discussion

"Re: Entity hashCode and equals overriding"

To view the discussion, visit: https://community.jboss.org/message/787964#787964

--------------------------------------------------------------
I've just fix the problem! I've changed the code in this way:

-------------------------------------------------------
@Override
public boolean equals(Object o) {
if (o==this)
return true;
if (o instanceof Book) {
if (this.isbn.compareTo(((Book) o).getIsbn()) == 0)
                                 return true;
                       else return false;
             }
             return false;
          }
-------------------------------------------------------

The problem was the comparison between string! Now I use the compareTo() method and everything correctly works.

Thank you for your time Piotr!
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/787964#787964]

Start a new discussion in EJB3 Development at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2030]

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-dev-forums/attachments/20130105/63a8497d/attachment-0001.html 


More information about the jboss-dev-forums mailing list