3 Replies Latest reply on May 18, 2004 10:53 AM by juha

    problems with ejb create and primary keys

    ghoyle

      Hi,

      I am having a problem deploying a sample entity I created. I am new to jboss and Entity Beans etc.
      I created a a simple Entity Bean based on CMP 2.0 and was hoping it would create the table when I deployed it.
      I am developing in Netbeans 3.6 and using the nbkboss pluging.


      The error i get from jboss is


      2004-05-13 16:14:54,541 INFO [org.jboss.deployment.MainDeployer] Starting deployment of package: file:/opt/jboss-3.2.3/server/all/deploy/employ.jar
      2004-05-13 16:14:54,864 WARN [org.jboss.ejb.EJBDeployer.verifier] EJB spec violation:
      Bean : Employee
      Method : public EmployeePK ejbCreate(short, String, String, String, Date, String, String, short, String, BigDecimal, String) throws CreateException
      Section: 10.6.4
      Warning: The return type of an ejbCreate(...) method must be the entity bean's primary key type.

      2004-05-13 16:14:54,868 ERROR [org.jboss.deployment.MainDeployer] could not create deployment: file:/opt/jboss-3.2.3/server/all/deploy/employ.jar
      org.jboss.deployment.DeploymentException: Verification of Enterprise Beans failed, see above for error messages.


      The ejb create method I am using looks like


      public EmployeePK ejbCreate(short EmpNo , java.lang.String FirstName , java.lang.String LastName , java.lang.String PhoneExt , java.sql.Date HireDate , java.lang.String DeptNo , java.lang.String JobCode , short JobGrade , java.lang.String JobCountry , java.math.BigDecimal Salary , java.lang.String FullName) throws CreateException{
      
       setEmpNo(EmpNo) ;
       setFirstName(FirstName) ;
       setLastName(LastName) ;
       setPhoneExt(PhoneExt) ;
       setHireDate(HireDate) ;
       setDeptNo(DeptNo) ;
       setJobCode(JobCode) ;
       setJobGrade(JobGrade) ;
       setJobCountry(JobCountry) ;
       setSalary(Salary) ;
       setFullName(FullName) ;
       return null;
      
       }
      


      The Primary key class is

      public class EmployeePK extends Object implements Serializable {
       public short EmpNo;
      
       public EmployeePK() {
       }
      
       public EmployeePK(short EmpNo) {
       this.EmpNo = EmpNo ;
       }
      
       /**
       * @see java.lang.Object#equals(Object)
       */
       public boolean equals(Object otherOb) {
       boolean b = true;
       EmployeePK other = (EmployeePK) otherOb;
      
       if (this == otherOb) {
       return b;
       }
      
       if (!(otherOb instanceof EmployeePK)) {
       b=false;
       return b;
       }
       return b;
      
       }
       /**
       *Override hashCode()
       */
      }
      


      Any help at all will be much appreciated.

      G

        • 1. Re: problems with ejb create and primary keys

          How do you declare your PK in your deployment descriptor?

          • 2. Re: problems with ejb create and primary keys
            ghoyle

            my deployment descriptor or at least part of it is

            <ejb-jar>
             <description></description>
             <display-name>employ</display-name>
             <enterprise-beans>
             <entity>
             <description></description>
             <display-name>Employee</display-name>
             <ejb-name>Employee</ejb-name>
             <home>EmployeeHome</home>
             <remote>Employee</remote>
             <local-home>EmployeeLocalHome</local-home>
             <local>EmployeeLocal</local>
             <ejb-class>EmployeeBean</ejb-class>
             <persistence-type>Container</persistence-type>
             <prim-key-class>short</prim-key-class>
             <reentrant>false</reentrant>
             <cmp-version>2.x</cmp-version>
             <abstract-schema-name>Employee</abstract-schema-name>
             <primkey-field>EmpNo</primkey-field>
             <cmp-field>
             <field-name>FullName</field-name></cmp-field>
             <cmp-field>
             <field-name>EmpNo</field-name></cmp-field>
             <cmp-field>
             <field-name>FirstName</field-name></cmp-field>
             <cmp-field>
             <field-name>LastName</field-name></cmp-field>
             <cmp-field>
             <field-name>PhoneExt</field-name></cmp-field>
             <cmp-field>
             <field-name>HireDate</field-name></cmp-field>
             <cmp-field>
             <field-name>DeptNo</field-name></cmp-field>
             <cmp-field>
             <field-name>JobCode</field-name></cmp-field>
             <cmp-field>
             <field-name>JobGrade</field-name></cmp-field>
             <cmp-field>
             <field-name>JobCountry</field-name></cmp-field>
             <cmp-field>
             <field-name>Salary</field-name></cmp-field>
             <security-identity>
             <use-caller-identity></use-caller-identity></security-identity>
             <query>
             <description></description>
             <query-method>
             <method-name>findByPrimaryKey</method-name>
             <method-params>
             <method-param>EmployeePK</method-param></method-params>
             </query-method>
             <ejb-ql></ejb-ql>
             </query>
             </entity> </enterprise-beans>
            .
            .
            .
            


            Hope this helps...

            • 3. Re: problems with ejb create and primary keys

              Your prim-key-class must be something.something.EmployeePK