wood burning stoves 2.0*
The moose likes EJB and other Java EE Technologies and the fly likes Primary Key Class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Primary Key Class" Watch "Primary Key Class" New topic
Author

Primary Key Class

Rajib Sarma
Ranch Hand

Joined: Apr 29, 2002
Posts: 34
Hi,
Why do we need to override the methods equals() and hashCode() for a primary key class?
Thanks
-Rajib


*** Rajib Prasad Sarma ***<br />==========================
Snigdha Solanki
Ranch Hand

Joined: Sep 07, 2000
Posts: 128
Primary Key Class need to override hashCode() so that it can be stored in a Hashtable. Container internally stores all the entity beans it has in memory in a hashtable or some similar structure.
Similarly,primary key class need to override equals method as container calls this method to compare two primary keys so as to determine if two cached entity beans represent the same data.


Snigdha<br />Sun Certified Programmer for the Java™ 2 Platform
 
jQuery in Action, 2nd edition
 
subject: Primary Key Class
 
Similar Threads
two or more primary keys
Doubt on enthuware answer (II)
EJBC Error
Is PrimaryKey class is must in cmp entity bean?
Primary key and update method strange issue