Discussions

EJB programming & troubleshooting: CMP Bean with out Primary Key Class

  1. CMP Bean with out Primary Key Class (2 messages)

    Hi,

    I am trying to write a CMP Bean with out PK Class and my table dosen't have any primary key. So I am using
    java.lang.Object in my Home Interface findByPrimaryKey(java.lang.Object) and in XML files <prim-key-class>java.lang.Object</prim-key-class> is this right?

    while compiling with ejbc the following error occured

    ERROR: Error from ejbc: [9.2.9] In EJB InvoiceMaster, the primary key class must implement the method public int hashCode().
    ERROR: Error from ejbc: [9.2.9] In EJB InvoiceMaster, the primary key class must implement the method boolean equals(Object other). ERROR: ejbc found errors

    is the java.lang.Object allready implements equals and hashCode methods ?

    please help me. Thank u

    Kamal.
                                  Kamal.
  2. HI,
    U CANT USE ENTITY BEAN WITH OUT A PRIMARY KEY.
    AND THE FIELDS IN THE PRIMARY KEY CLASS SHOULD BE CONTAINAR MANAGED.
    SO TRY TO IDENTIFY A PRIMARY KEY IN YOUR TABLE AND PROCEED.
    THANKS
    SUBRAHMANYAM K V S
  3. As per EJB Specification1.1, the definition of PrimaryKey can be deffered until deployment time by making the findByPrimarykey to take java.lang.Object as parameter and by making the return type of ejbCreate in bean implementation class to java.lang.Object.
    But I am getting error similar to on errors Mr.Kamal got while running ejbc.It says that the equals & hashCode methods are undefined. I am using Weblogic5.1. I will be thankful if any one can provide a solution for this.
    Regards
    Sundar