1 Reply Latest reply on Jan 20, 2003 11:11 PM by surfee

    Unknown Primary Key

    Avinash Gupta Newbie

      I am trying to use the "key-generator" to generate primary keys in JBoss 3.2beta2. The relevant section in my standardjbosscmp-jdbc.xml looks like this:

      <unknown-pk>
      <key-generator-factory>UUIDKeyGeneratorFactory</key-generator-factory>
      <unknown-pk-class>java.lang.String</unknown-pk-class>
      <jdbc-type>VARCHAR</jdbc-type>
      <sql-type>VARCHAR(32)</sql-type>
      </unknown-pk>
      <entity-command name="key-generator"/>

      The primary key does get generated and a row does get inserted in the table. However, on doing a SELECT with the same primary key, the row is not found. The relevant parts of server.log are shown below. It is clear that a row DOES get inserted (Rows affected = 1), but immediately after that, the SELECT fails with a NoSuchEntityException. I am using MySQL as the database. Any idea why this may be happening? Thanks.

      2002-12-26 14:14:59,122 DEBUG [org.jboss.ejb.plugins.cmp.jdbc.JDBCKeyGeneratorCreateCommand.AddressEJB] Create: pk=5C44CFB27F000001000E86478C1329EB
      2002-12-26 14:14:59,124 DEBUG [org.jboss.ejb.plugins.cmp.jdbc.JDBCKeyGeneratorCreateCommand.AddressEJB] Executing SQL: SELECT COUNT(*) FROM AddressEJB WHERE AddressEJB_upk=?
      2002-12-26 14:14:59,125 DEBUG [org.jboss.ejb.plugins.cmp.jdbc.JDBCKeyGeneratorCreateCommand.AddressEJB] Executing SQL: INSERT INTO AddressEJB (AddressEJB_upk, streetName1, streetName2, city, state, zipCode, country, ContactInfoEJB_address) VALUES (?, ?, ?, ?, ?, ?, ?, ?)
      2002-12-26 14:14:59,127 DEBUG [org.jboss.ejb.plugins.cmp.jdbc.JDBCKeyGeneratorCreateCommand.AddressEJB] Rows affected = 1
      2002-12-26 14:14:59,129 DEBUG [org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor] invokerBInding is null in ProxyFactoryFinder
      2002-12-26 14:14:59,131 DEBUG [org.jboss.ejb.plugins.cmp.jdbc.JDBCLoadEntityCommand.AddressEJB] Executing SQL: SELECT streetName1, streetName2, city, state, zipCode, country, ContactInfoEJB_address FROM AddressEJB WHERE (AddressEJB_upk=?)
      2002-12-26 14:14:59,134 ERROR [org.jboss.ejb.plugins.LogInterceptor] NoSuchEntityException:
      javax.ejb.NoSuchEntityException: Entity not found: primaryKey=5C44CFB27F000001000E86478C1329EB
      at org.jboss.ejb.plugins.cmp.jdbc.JDBCLoadEntityCommand.execute(JDBCLoadEntityCommand.java:170)
      at org.jboss.ejb.plugins.cmp.jdbc.JDBCLoadEntityCommand.execute(JDBCLoadEntityCommand.java:62)
      at org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.loadEntity(JDBCStoreManager.java:572)
      at org.jboss.ejb.plugins.CMPPersistenceManager.loadEntity(CMPPersistenceManager.java:410)
      at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.loadEntity(CachedConnectionInterceptor.java:353)
      at org.jboss.ejb.plugins.EntitySynchronizationInterceptor.invoke(EntitySynchronizationInterceptor.java:251)
      at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor.java:186)