Hibernate Books

All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: auto increment column(AUTO_INCREMENT) of Mysql
PostPosted: Wed Aug 04, 2010 2:36 pm 
Newbie

Joined: Wed Aug 04, 2010 2:20 pm
Posts: 5
How to create auto increment column(AUTO_INCREMENT) of Mysql in Hibernate using annotations?.

We need Hiberate DDL for the below Query.

CREATE TABLE `animals` (
`id` MEDIUMINT(9) NOT NULL AUTO_INCREMENT,
`name` CHAR(30) NOT NULL,
PRIMARY KEY (`id`)


Top
 Profile  
 
 Post subject: Re: auto increment column(AUTO_INCREMENT) of Mysql
PostPosted: Thu Aug 05, 2010 12:47 am 
Newbie

Joined: Tue Jun 01, 2010 4:18 am
Posts: 11
Hi uvrajs. Do you mean like this:

Code:
@Entity
public class Animals implements Serializable {
  @Id @GeneratedValue(strategy=GenerationType.AUTO)
  private int id;
  private String name;

  // Constructor.. Getter-Setter.. etc.
}


Top
 Profile  
 
 Post subject: Re: auto increment column(AUTO_INCREMENT) of Mysql
PostPosted: Tue Aug 10, 2010 2:16 pm 
Newbie

Joined: Wed Aug 04, 2010 2:20 pm
Posts: 5
HI,
Thanks a lot.It worked.:)


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 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.