0 Replies Latest reply on Feb 27, 2003 4:13 AM by Tom

    AutoGenerated PK Exception

    Tom Newbie

      Hi Guys,

      I am getting an exception when i try to generate a PK
      with oracle 8i

      what i am getting is :

      javax.ejb.CreateException: Error checking if entity exists:java.lang.ClassCastException
      at org.jboss.ejb.plugins.cmp.jdbc.JDBCCreateEntityCommand.entityExists(JDBCCreateEntityCommand.java:188)

      at org.jboss.ejb.plugins.cmp.jdbc.JDBCPkSqlCreateCommand.execute(JDBCPkSqlCreateCommand.java:121)

      at org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.createEntity(JDBCStoreManager.java:575)

      at org.jboss.ejb.plugins.CMPPersistenceManager.createEntity(CMPPersistenceManager.java:253)

      at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.createEntity(CachedConnectionInterceptor.java:270)




      This is what i used :


      jbosscmp-jdbc.xml

      <unknown-pk>
      <unknown-pk-class> java.lang.Integer</unknown-pk-class>
      <column-name> id</column-name>
      <jdbc-type>INTEGER </jdbc-type>
      <sql-type>INTEGER</sql-type>
      </unknown-pk>
      <entity-command name="pk-sql">
      SELECT job_seq.nextval from dual
      </entity-command>


      Remote Interface is :

      public interface EmployeeRemoteHome extends javax.ejb.EJBHome {
      public java.lang.Object create(Long id) throws CreateException, RemoteException;
      public java.lang.Object create(Long id, BigDecimal depaid) throws CreateException, RemoteException;
      public Collection findAll() throws FinderException, RemoteException;
      public EmployeeRemote findByPrimaryKey(java.lang.Object depaId) throws FinderException, RemoteException;
      }

      and the Bean Implementation is :

      abstract public class EmployeeBean implements EntityBean {
      EntityContext entityContext;
      public java.lang.Object ejbCreate(java.lang.Long id) throws CreateException {
      setId(id);
      return null;
      }
      public java.lang.Object ejbCreate(java.lang.Long id, java.math.BigDecimal depaid) throws CreateException {
      setDepaId(depaid);
      return null;
      }
      ..........
      ........


      In the ejb-jar.xml the <prim-key-class> is java.lang.Object
      and there is no <primkey-field> specified

      Why am i getting the exception?