Use session.Persist instead session.Save 2009/10/29 Kent Boogaart <[email protected]>
> > @Dan: no, I tried that and the Id property still isn't updated. > > @Fabio: all I want is to know what the ID is for my saved entities. If > NH doesn't do it for me, it seems my alternative is to do a far less > efficient and less reliable query that matches and multiple fields. > > > So, I'm using the identity generator and I *want* to roundtrip to get > the ID because the alternative is far worse. What am I doing wrong? > > Thanks, > Kent > > > On Oct 29, 2:40 pm, Dan Normington <[email protected]> wrote: > > Kent, > > I think all you have to do is change the generator class. You currently > have it set to "native". I personally haven't used Identity types in > NHibernate, but I think the following should work: > > > > <generator class="identity"/> > > > > ________________________________ > > From: Kent Boogaart <[email protected]> > > To: nhusers <[email protected]> > > Sent: Thu, October 29, 2009 9:34:08 AM > > Subject: [nhusers] Re: Update ID of entity after save > > > > Thanks Dan, but what exactly are you suggesting I change? Nothing in > > that link tells me what I should be doing to have my entity updated > > automatically with its ID. > > > > I'm using SQL2005 if it makes any difference, which presumably it > > shouldn't with NH. > > > > Thanks, > > Kent > > > > On Oct 29, 2:26 pm, Dan Normington <[email protected]> wrote: > > > > > Check out this link. It seems to provide information on how to > implement this: > > > > >http://nhforge.org/blogs/nhibernate/archive/2009/02/09/nh2-1-0-new-ge. > .. > > > > > ________________________________ > > > From: Kent Boogaart <[email protected]> > > > To: nhusers <[email protected]> > > > Sent: Thu, October 29, 2009 9:21:00 AM > > > Subject: [nhusers] Update ID of entity after save > > > > > Hi, > > > > > I feel like I must be missing something obvious. I'm using 2.1.0.GA. I > > > have code that saves an entity with ID mapped as: > > > > > <id name="Id" type="int" unsaved-value="0"> > > > <generator class="native"/> > > > </id> > > > > > The entity is successfully saved, but its Id property remains as zero > > > afterwards. > > > > > How can I have NHibernate automatically update the Id property to the > > > value of "SELECT SCOPE_IDENTITY"? > > > > > I read somewhere about applying an IdAttribute to my entity's Id > > > property, but that attribute no longer appears to exist. > > > > > Thanks, > > > Kent > > > -- Fabio Maulo --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "nhusers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/nhusers?hl=en -~----------~----~----~----~------~----~------~--~---
