4 Replies Latest reply on Nov 12, 2003 6:36 PM by Steven Grimm

    My primary key is vanishing!

    Steven Grimm Newbie

      I have a CMP entity bean with an XDoclet-generated primary key class:

      EquipmentBean.java:
      ...
      * @ejb.pk
      * class = "com.foo.db.equipment.EquipmentPK"
      ...
      /**
      * @ejb.persistence
      * column-name = "equip_id"
      * sql-type = "INTEGER"
      * jdbc-type = "INTEGER"
      * @ejb.pk-field
      * @ejb.interface-method
      */
      public abstract int getId();

      When I fetch an instance of this bean, the primary key seems to get reset, which causes me to be unable to call any business methods. For example, I put this in a JSP:

      EquipmentPK pk = new EquipmentPK(103016);
      Equipment equipBean = ((EquipmentHome)PortableRemoteObject.narrow(new InitialContext().lookup("EquipmentHome"), EquipmentHome.class)).findByPrimaryKey(pk);
      System.err.println("original PK = " + pk);
      System.err.println("equipment PK = " + equipBean.getPrimaryKey());
      System.err.println("equipment ID = " + equipBean.getId());

      (103016 is a record that exists in the database.) I get the following output, which indicates to me that the lookup is succeeding (since I don't get a finder exception on findByPrimaryKey()) but the bean in question is invalid:

      11:12:24,142 ERROR [STDERR] original PK = [.103016.]
      11:12:24,142 ERROR [STDERR] equipment PK = [.0.]
      11:12:24,158 ERROR [LogInterceptor] NoSuchEntityException:
      javax.ejb.NoSuchEntityException: Entity not found: primaryKey=[.0.]
      at org.jboss.ejb.plugins.cmp.jdbc.JDBCLoadEntityCommand.execute(JDBCLoadEntityCommand.java:224)
      at org.jboss.ejb.plugins.cmp.jdbc.JDBCLoadEntityCommand.execute(JDBCLoadEntityCommand.java:76)
      at org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.loadEntity(JDBCStoreManager.java:577)
      at org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.loadEntity(JDBCStoreManager.java:559)
      at org.jboss.ejb.plugins.CMPPersistenceManager.loadEntity(CMPPersistenceManager.java:381)
      at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.loadEntity(CachedConnectionInterceptor.java:352)
      at org.jboss.ejb.plugins.EntitySynchronizationInterceptor.invoke(EntitySynchronizationInterceptor.java:239)
      at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor.java:185)
      at org.jboss.ejb.plugins.EntityReentranceInterceptor.invoke(EntityReentranceInterceptor.java:114)
      at org.jboss.ejb.plugins.EntityInstanceInterceptor.invoke(EntityInstanceInterceptor.java:163)
      at org.jboss.ejb.plugins.EntityLockInterceptor.invoke(EntityLockInterceptor.java:89)
      at org.jboss.ejb.plugins.EntityCreationInterceptor.invoke(EntityCreationInterceptor.java:54)
      at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:84)
      at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:267)
      at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:128)
      at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:118)
      at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:191)
      at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryFinderInterceptor.java:122)
      at org.jboss.ejb.EntityContainer.internalInvoke(EntityContainer.java:490)
      at org.jboss.ejb.Container.invoke(Container.java:700)
      at sun.reflect.GeneratedMethodAccessor70.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:324)
      at org.jboss.mx.capability.ReflectedMBeanDispatcher.invoke(ReflectedMBeanDispatcher.java:284)
      at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:546)
      at org.jboss.invocation.local.LocalInvoker.invoke(LocalInvoker.java:101)
      at org.jboss.invocation.InvokerInterceptor.invoke(InvokerInterceptor.java:90)
      at org.jboss.proxy.TransactionInterceptor.invoke(TransactionInterceptor.java:46)
      at org.jboss.proxy.SecurityInterceptor.invoke(SecurityInterceptor.java:45)
      at org.jboss.proxy.ejb.EntityInterceptor.invoke(EntityInterceptor.java:97)
      at org.jboss.proxy.ClientContainer.invoke(ClientContainer.java:85)
      at $Proxy210.getId(Unknown Source)
      at org.apache.jsp.resetPracticeAuctions_jsp._jspService(resetPracticeAuctions_jsp.java:1147)

      Anyone else seen this behavior?