0 Replies Latest reply on Jun 15, 2006 3:24 PM by chlabreu

    Manually assigned PK not working on embeddable container

    chlabreu

      Playing a bit with the "microcontainer-deployment" example of the "jboss-EJB-3.0_Embeddable_ALPHA" distribution package I noticed the em.persist throws an exception if I change


      @Id(generate=GeneratorType.AUTO)
      public int getId()
      {
      return id;
      }


      to


      @Id(generate=GeneratorType.NONE)
      public int getId()
      {
      return id;
      }


      in the Customer class and try to assign manually the PK in the CustomerDAOBean class


      public int createCustomer(String name)
      {
      Customer cust = new Customer();
      cust.setId(1); // ADDED THIS!
      cust.setName(name);
      em.persist(cust);

      return cust.getId();
      }


      The Exception is little explanatory:


      WARN 15-06 16:20:53,562 (JBossEntityResolver.java:getLocalEntityName:201) -Entity is not registered, publicId=null
      WARN 15-06 16:20:53,578 (SaxJBossXBParser.java:warning:226) -schema_reference.4: Failed to read schema document 'bean-deployer_1_0.xsd', because 1) could not find the document; 2) the document could not be read; 3) the root element of the document is not <xsd:schema>. @ file:/C:/temp/XXXX/bin/embedded-jboss-beans.xml[5,45]
      WARN 15-06 16:20:54,390 (JBossEntityResolver.java:getLocalEntityName:201) -Entity is not registered, publicId=null systemId=file:/C:/temp/XXXX/bin/bean-deployer_1_0.xsd
      WARN 15-06 16:20:54,390 (SaxJBossXBParser.java:warning:226) -schema_reference.4: Failed to read schema document 'bean-deployer_1_0.xsd', because 1) could not find the document; 2) the document could not be read; 3) the root element of the document is not <xsd:schema>. @ file:/C:/temp/XXXX/bin/ejb3-deployment.xml[5,45]
      Exception in thread "main" java.lang.RuntimeException: org.jboss.tm.JBossRollbackException: Unable to commit, tx=TransactionImpl:XidImpl[FormatId=257, GlobalId=null:1150399253750/3, BranchQual=null:1150399253750, localId=0:3] status=STATUS_NO_TRANSACTION; - nested throwable: (org.hibernate.exception.GenericJDBCException: Could not execute JDBC batch update)
      at org.jboss.aspects.tx.TxPolicy.handleEndTransactionException(TxPolicy.java:185)
      at org.jboss.aspects.tx.TxPolicy.endTransaction(TxPolicy.java:167)
      at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:74)ERROR 15-06 16:20:58,796 (EjbTimerUtil.java:getTimerService:43) -Unable to initialize timer service