Entity Bean (CMP) - Primary Key


EJB design: Entity Bean (CMP) - Primary Key

  1. Entity Bean (CMP) - Primary Key (3 messages)

        I have developed an Entity Bean(CMP) with Custom Primary Key class (Single Column Key in Database).
            Entity Bean : StudentBean
            Primary Key Class : StudentPK
            package: student
            Data BAse Table: Student(rollNo*, name, clas,marks)
             RollNo Number(2)

            in ejb-jar XML document :


     when I am generating Container classes EJBC compiler
     is giving an Error : pk = bean.rollno can't covert integer to StudentPK...

        what is wrong in this

      ThanX in advance
      Ramesh Raju

  2. Do you have a constructor for StudenPK with an integer parameter? Remember also to include a parameter-less constructor and a toString()-methode.

    public class StudentPK implements Serializable {
      public int snr;

      public StudentPK(int a) {
        this.snr = a;

      public StudentPK()

      public String toString() {
        return "" + sBookingnr;

  3. Entity Bean (CMP) - Primary Key[ Go to top ]

    This is an example of the PK class in an entity bean CMP.
    I am not sure why the ejbc complain if we do not have the hashCode & equals methods.
    If someone knows please let us know.
    public class calssPK implements java.io.serializable {
       public int intPK;
       public classPK() { }
       public classPK(int intPK) {
         this.intPK = intPK;
       public int hashCode() {return 1;}
       public boolean equals (Object obj) { return false;}

  4. Hi,

    Are you using a Weblogic container ?
    If yes I have exactly the same problem (only with WebLogic).
    The file where you get the error is : xxxEOImpl.java which is generated...
    Since I didn't find any example on the WebLogic site with custom primary key, I wonderer if this is simply possible with WebLogic ?!

    Does anyone have any experience with custom primary key AND weblogic ???