-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: ID auto generation for MySQL on JBoss 7
PostPosted: Thu Jan 12, 2012 11:22 am 
Newbie

Joined: Thu Jan 12, 2012 11:10 am
Posts: 1
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:
Code:
@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:
Code:
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

Thanks.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.