0 Replies Latest reply on Jan 12, 2012 10:36 AM by koshey

    ID auto generation for MySQL on JBoss AS 7

    koshey Newbie

      Hi everyone,

      I need help to resolve such problem. Application needs to support several DB (MySQL, Oracle). After migration to JBoss 7 entity id auto generation was broken.

      Etity example:





      public class Foo {



                private Integer id;

                private String model;



                @SequenceGenerator(name="foo_seq_gen", sequenceName="foo_0", initialValue=1, allocationSize=1)

                @Column(name="id", updatable=false)

                @GeneratedValue(generator = "foo_seq_gen")

                public Integer getId() {

                          return id;


                public void setId(Integer id) {

                          this.id = id;



                @Column(name="model", length=64, updatable=false)

                public String getModel() {

                          return model;


                public void setModel(String model) {

                          this.model = model;





      For Oracle all still works fine. But when trying to perform create operation on MySQL an error occures:



      15:34:56,290 ERROR [org.hibernate.util.JDBCExceptionReporter] (http-localhost- Table 'scheme.foo_0' doesn't exist



      Thus MySQL tries to access unexistent table as sequence insteed use native autogeneration mechanism.



      Does anybody know the cure?




      MySQL 5.5.16

      JBoss AS 7.1.0.Beta1

      Hibernate 3.6.1