Implementing an EJB CMP compound primary key?

Alessandro A. Garbagnati

A Primary Key Class is a class that follows few simple rules:

  • it has to implement the java.io.Serializable interface.
  • all its fields have to be made public, to allow the container to use the Relfection API during the synchronization with the database.
  • to allow the class to be better handled inside Collections, it should override the hashCode() and equals() methods.
  • when using CMP Entity Beans, be sure that the fields of the Primary Key class are also present in the Bean class, to allow the container to set the values, always using Reflection API.
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

About | Sitemap | Contact