0 Replies Latest reply on Jan 12, 2008 8:43 AM by Gal Rubinstein

    Id var not updated after persist

    Gal Rubinstein Newbie

      hello all, using jboss 4.2.2 (red-hat developer studio) and mysql 5;

      after doing persist the Id retrun null... here is the code:

      1st, the table in DB:

      create table test (
       ID int(10) NOT NULL auto_increment,
       NAME VARCHAR(15),

      the -ds.xml

      the persistence.xml
      <?xml version="1.0" encoding="UTF-8"?>
      <persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence" ...............
      <persistence-unit name="tester" transaction-type="JTA">
       <property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5InnoDBDialect"/>
       <property name="hibernate.show_sql" value="true"/>

      the entity, manager, end tester EJB's:
      @Table(name = "test")
      public class TestEntity implements Serializable
       @Column(name = "id")
       private Integer someId;
       @Column(name = "name")
       private String someName;
       public String toString()
       return "id = " + someId + ", Name = " + someName;
      public @Stateless class TestManagerBean implements TestManager
       private String GET_BY_ID_EJBQL = "SELECT x FROM TestEntity x WHERE x.id = ?";
       private EntityManager manager;
       public void create(TestEntity test)
       public TestEntity getById(Integer id)
       return (TestEntity) manager.createQuery(
       GET_BY_ID_EJBQL).setParameter(1, id).getSingleResult();
      public @Stateless class RunTestBean implements RunTest
       @EJB private TestManager manager;
       public void test()
       TestEntity testEntity = new TestEntity();
       System.out.println("return = " + testEntity);

      there is also a standalone the looks up "RunTestBean/remote"
      and execute test().

      the output print out is:
      15:12:00,852 INFO [STDOUT] return = id = null, Name = abcd

      can anyone tell me how to "persuade" the container to kindly update the id
      from the table (the persist works, got a new line in table!).

      Thanks in advance