[jboss-dev-forums] [JBoss AS 7 Development] - ID auto generation for MySQL on JBoss AS 7

koshey do-not-reply at jboss.com
Thu Jan 12 10:36:44 EST 2012


koshey [https://community.jboss.org/people/koshey] created the discussion

"ID auto generation for MySQL on JBoss AS 7"

To view the discussion, visit: https://community.jboss.org/message/646493#646493

--------------------------------------------------------------
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:


@Entity
@Table(name="foo")
public class Foo {


          private Integer id;
          private String model;

          @Id 
          @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-127.0.0.1-8080-1) 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?


Environment:
MySQL 5.5.16
JBoss AS 7.1.0.Beta1
Hibernate 3.6.1
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/646493#646493]

Start a new discussion in JBoss AS 7 Development at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2225]

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-dev-forums/attachments/20120112/7f77c39f/attachment.html 


More information about the jboss-dev-forums mailing list