-->
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.  [ 3 posts ] 
Author Message
 Post subject: Hibernate primary key mapping
PostPosted: Wed Jul 06, 2011 10:56 pm 
Newbie

Joined: Thu Jun 09, 2011 3:37 pm
Posts: 9
Hi, I am using hibernate 3 and trying to retrieve records form contact table and it has first, last name,phno, contactid is key. i have contact.hbm.xml file with all these mappings. i am able to retrive all records using this hbm file. when I want to insert a record in by using the same hbm file (key is auto genrated by db) I am getting sql error exception.
So i have created a different bean with out contact id and genrated hbm file with out contact id. then I tried to insert a record , it's going through.
My question is it right way, if it's right way then why do we need hibernate? or please let me know if there is altenative for this.
Thanks,
reddy.


Top
 Profile  
 
 Post subject: Re: Hibernate primary key mapping
PostPosted: Thu Jul 07, 2011 8:42 am 
Newbie

Joined: Thu Jun 09, 2011 3:37 pm
Posts: 9
Please respond me ..


Top
 Profile  
 
 Post subject: Re: Hibernate primary key mapping
PostPosted: Fri Jul 08, 2011 9:34 am 
Newbie

Joined: Wed Feb 13, 2008 7:28 pm
Posts: 5
You'll probably have better luck if you post your mapping file for the contact table. You shouldn't need two mapping files. If the table has a generated identity column, you will need to specify that in the mapping.

Look here: http://docs.jboss.org/hibernate/core/3. ... aration-id

Specifically, look at section 5.1.2.2. (Identifier generator)

What you're probably missing is this:

<generator class="identity" />


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 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.