-->
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: Error in inserting a new record from a table having auto_inc
PostPosted: Wed Feb 10, 2010 9:36 am 
Newbie

Joined: Wed Feb 10, 2010 9:20 am
Posts: 3
my hbm file configured as:
<class name="com.ats.hibernate.pojo.Login" table="LOGIN" lazy="true" >
<id column="id" name="userId" type="java.lang.Integer">
<generator class="increment"></generator>
</id>
In some class where i want to use login class coded as:
Session sess=HibernateUtils.currentSession();
Login login = new Login();
login.setUsername(username);
login.setPassword(password);
login.setGender(gender);
login.setLevel(level);
sess.save(login);
Finally everything goes correct but at the time of sess.save(login);
console displays as Hibernate: select max(id) from LOGIN


Top
 Profile  
 
 Post subject: Re: Error in inserting a new record from a table having auto_inc
PostPosted: Wed Feb 10, 2010 9:45 am 
Expert
Expert

Joined: Wed Mar 03, 2004 6:35 am
Posts: 1240
Location: Lund, Sweden
If your id column is an auto-increment column, I think you should use the 'identity' generator, not the 'increment' generator. See http://docs.jboss.org/hibernate/stable/ ... aration-id for more information.


Top
 Profile  
 
 Post subject: Re: Error in inserting a new record from a table having auto_inc
PostPosted: Wed Feb 10, 2010 10:07 am 
Newbie

Joined: Wed Feb 10, 2010 9:20 am
Posts: 3
sorry i've tried with identity but no use same Hibernate command executing
Hibernate: select max(id) from LOGIN

I have already mentioned it in the hbm file that it is an auto increment cloumn and see this any problem in this


Top
 Profile  
 
 Post subject: Re: Error in inserting a new record from a table having auto_inc
PostPosted: Wed Feb 10, 2010 10:15 am 
Newbie

Joined: Wed Feb 10, 2010 9:20 am
Posts: 3
please help in this matter

thanks
avinash


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.