-->
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.  [ 4 posts ] 
Author Message
 Post subject: @GeneratedValue and auto-increment for MySql 4.1
PostPosted: Fri Feb 10, 2006 2:30 pm 
Newbie

Joined: Fri Feb 10, 2006 2:20 pm
Posts: 9
Hibernate version:
Core: 3.1.2
Annotation: 3.1 beta8
Tools: 3.1 beta4

Mapping documents:
Code:
@Entity
public class News implements Serializable {

   @Id   
   @GeneratedValue(strategy = GenerationType.AUTO)
   private Long id;

   @Version
   private int version;

   @Temporal(TemporalType.DATE)
   private Date date;

   @Basic
   private String title;

   @Lob
   private String content;
...


Name and version of the database you are using:
MySql 4.1

The generated SQL (show_sql=true):
Code:
create table News (id bigint not null, version integer not null, date datetime, title varchar(255), content text, primary key (id));



I've juste upgraded to annotaion beta8 and tools beta4 and the auto-increment does not seems to work anymore with mysql...
The table structure is fine except there is no auto-inctrement anymore.

Did I miss something while I upgraded ?

Thanks for your help.

Cedric


Top
 Profile  
 
 Post subject:
PostPosted: Sun Feb 12, 2006 3:27 am 
Beginner
Beginner

Joined: Wed Aug 24, 2005 5:32 am
Posts: 23
Hi Cedric,

This feature works for me, and if you take a look at the MySQLDialect you will see the next method

Quote:
public String getIdentityColumnString() {
return "not null auto_increment"; //starts with 1, implicitly
}


The only thing I can think of it that your runtime environment is mis-configured and still using the old Hibernate jars.

For example if your application runs on JBOSS 4.0.3SP1 and lower it will not see the new Hibernate classes (even if you deploy it with your application) since it has its own copy of hibernate jars under <jboss home>/server/<server root>/lib.

If this is the case then it will look for the old style annotations. It means that it will look for something like @Id(generate=GeneratorType.AUTO) and it will ignore annotations in the new format.

Eyal Lupu


Top
 Profile  
 
 Post subject:
PostPosted: Sun Feb 12, 2006 10:33 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
or your old domain model classes are in the classpath

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 13, 2006 1:13 pm 
Newbie

Joined: Fri Feb 10, 2006 2:20 pm
Posts: 9
Thanks for your help!

It works now... I was working with my old model classes :(


Cedric


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

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.