1 Reply Latest reply on Feb 23, 2006 2:05 PM by lafr

    Problem in EJB QL for Oracle

    ntomer

      Hi,

      I am trying to implement a CMP to learn how does it work. I created a
      table on Oracle 9i with the following script -

      CREATE TABLE Employee
      (
      EmpNo NUMBER(5, 0)
      CONSTRAINT pk_empno PRIMARY KEY,
      EmpName VARCHAR2(50)
      );

      I am using NetBeans 5.0 IDE; thru NetBeans wizard I created an entity bean
      for this table; the findByPrimaryKey method takes a java.math.BigDecimal
      parameter. The ejb-jar.xml snippet is -


      jdbc:oracle:thin:@192.168.4.184:1521:NITIN
      [NitinTest on NITINTEST]
      <display-name>EmployeeEB</display-name>
      <ejb-name>EmployeeBean</ejb-name>
      <local-home>com.newgen.ejb.EmployeeLocalHome</local-home>
      com.newgen.ejb.EmployeeLocal
      <ejb-class>com.newgen.ejb.EmployeeBean</ejb-class>
      <persistence-type>Container</persistence-type>
      <prim-key-class>java.math.BigDecimal</prim-key-class>
      false
      <abstract-schema-name>Employee</abstract-schema-name>
      <cmp-field>
      <field-name>empno</field-name>
      </cmp-field>
      <cmp-field>
      <field-name>empname</field-name>
      </cmp-field>
      <primkey-field>empno</primkey-field>

      auto generated method
      <query-method>
      <method-name>findByEmpno</method-name>
      <method-params>
      <method-param>java.math.BigDecimal</method-param>
      </method-params>
      </query-method>
      <ejb-ql>SELECT OBJECT(e) FROM Employee AS e WHERE e.empno =
      ?1</ejb-ql>


      auto generated method
      <query-method>
      <method-name>findByEmpname</method-name>
      <method-params>
      <method-param>java.lang.String</method-param>
      </method-params>
      </query-method>
      <ejb-ql>SELECT OBJECT(e) FROM Employee AS e WHERE e.empname
      = ?1</ejb-ql>



      I wrote a SessionFacade for this entity bean, which calls the
      findByPrimaryKey method of the entity bean.
      The problem I am facing is, even when I am passing the correct data (a
      primary key for which a row exists), the entity bean is throwing a
      FinderException. Any idea why this might be happening?

      Thanx and Regards

      Nitin