-->
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.  [ 2 posts ] 
Author Message
 Post subject: Return primary key of inserted record
PostPosted: Thu Sep 27, 2007 12:03 pm 
Newbie

Joined: Mon May 21, 2007 3:14 pm
Posts: 14
Is there a way, using NHibernate (in C#), to retrieve the value of the primary key field for the record just inserted when calling an ISession's Save function? Thanks in advance for your help.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 27, 2007 12:45 pm 
Hibernate Team
Hibernate Team

Joined: Tue Jun 13, 2006 11:29 pm
Posts: 315
Location: Calgary, Alberta, Canada
I assumed that you are using some form of auto-generated ID on the database table and you specified "native" or "identity" in the <generator> element in the mapping file. Given that my assumption is correct, when you save an entity using ISession.Save(), NHibernate puts the generated ID back into the ID property of your entity as defined in the <id> element in the mapping file.

_________________
Karl Chu


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