-->
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: annotations& mysql/auto_increment
PostPosted: Fri Feb 04, 2005 10:40 am 
Regular
Regular

Joined: Thu Feb 19, 2004 4:48 am
Posts: 62
Is there an annotation to tell the schema-update to create primary keys with auto_increment?

And another switch to tell mysql to use InnoDB-Tables instead of the default myIsam?

And if there is no annotation (probably to db-specific), is there a hibernate-property to switch that?

cheers&thx in advance
stefan


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 04, 2005 2:48 pm 
Pro
Pro

Joined: Fri Nov 19, 2004 5:52 pm
Posts: 232
Location: Chicago, IL
I think for MySQL, it will use identity/auto_increment by default. So, if you do something like the following it should work.

Code:
@Id(generate=GeneratorType.AUTO)
public int getId() {
   return id;
}


I don't know the answer to the InnoDB question. I know that for columns, you can use the Column annotation like the following to explicitly specify the type for a column. I don't know if there is something equivalent for at the table level or not.

Code:
@Column(columnDefinition="text")


Top
 Profile  
 
 Post subject:
PostPosted: Sat Feb 05, 2005 7:30 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Isn't there an InnoDB Dialect already?

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Sun Feb 06, 2005 9:52 am 
Regular
Regular

Joined: Thu Feb 19, 2004 4:48 am
Posts: 62
yes, of course, you're right, missed this one:)

Switching to

hibernate.dialect org.hibernate.dialect.MySQLInnoDBDialect

creates the tables automatically as InnoDB-Tables, and using

@Id (generate=GeneratorType.AUTO)

on the Ids automatically generates the primary keys with an auto_increment.

Did I mention that I absolutely love hibernate? With the new annotations it couldn't get much easier - next logical step would be, that hibernate guesses, what I want to persist and automatically installs the database and the operating system...

thx for the help!
stf


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.