0 Replies Latest reply on Nov 14, 2012 11:15 AM by chalu

    Sequence for entity's generated ID is not commited

    chalu

      Hello,

      I have JBoss AS 7 + PostgreSQL 9 as storage for entity beans with ID PK generated by db sequences. Works fine until app server restart - after restart entity got already used ID.

      When I look into db sequence, I see that it is not updated.

       

      My db datasource in configuration/standalone.xml is:

      <datasource jta="false" jndi-name="java:/PostgresDS" pool-name="PostgresDS" enabled="true" use-ccm="false">

                          <connection-url>jdbc:postgresql://localhost:5432/hrp</connection-url>

                          <driver-class>org.postgresql.Driver</driver-class>

                          <driver>postgresql-9.0-802.jdbc4.jar</driver>

                          <security>

                              <user-name>xxx</user-name>

                              <password>yyy</password>

                          </security>

                          <validation>

                              <validate-on-match>false</validate-on-match>

                              <background-validation>false</background-validation>

                          </validation>

                          <statement>

                              <share-prepared-statements>false</share-prepared-statements>

                          </statement>

      </datasource>

       

      I entity bean I have:

      @Entity

      @Table(name = "LogStep", schema = "public")

      @SequenceGenerator(name = "logstep_sequence", sequenceName = "LogStep_id_seq", allocationSize = 10, initialValue = 1)

      public class LogStep implements java.io.Serializable{

      ....

      private Integer id;

      ....

       

        @Id

                @Column(name = "id", unique = true, nullable = false)

                @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "logstep_sequence")

                public Integer getId() {

                          return this.id;

                }

       

       

      Could someone help me to find where is my mistake?

       

      Thanks

      Jiri