• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

primary keys

 
Anushe Khan
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
When to compare primary keys using 'equals' method and when to use isIdentical()?(difference)

Thanks
 
Mcgill Smith
Ranch Hand
Posts: 178
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Comparing primary keys is valid only when comparing objects obtained from the same home interface.When objects are obtained from different home interfaces,the client must use the isIdentical method on one of the objects to perform the comparison.
 
Weerawit Maneepongsawat
Ranch Hand
Posts: 203
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes you can compare Primary key class using equals method (if primary key class override equals and hashCode) for testing on entity bean has same value.
but isIdentical method is locate on EJBObject or EJBLocalObject.
You can use isIdentical for session bean or entity bean but if you use primary key equals method you can use only entity bean.
hope this help.
 
Anushe Khan
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks.
 
Ko Ko Naing
Ranch Hand
Posts: 3178
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oh what I know is that equals() is for objects on the same heap and isIdentical() is for objects on the remote heap... That's a simple concept for the difference between equals() and isIdentical()...
Just my 2 cents...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic