Hi Billy, The warning occurs when you call SaveOrUpdate() on an entity with an 'assigned' identifier.
When NH doesn't control the IDs, it can't tell if that instance should be saved (it's new), or updated (it already exists in the DB), so it warns you to let you know it's hitting the DB (twice) when you might not have expected it to. The fix that caused this behaviour: http://216.121.112.228/browse/NH-1914 The discussion on what it should do: http://groups.google.com/group/nhibernate-development/browse_thread/thread/d10873bbc7ca917c/d608c5512a224288?lnk=gst&q=1914#d608c5512a224288 Regards, Richard From: Billy Stack Sent: Sunday, February 06, 2011 9:29 AM To: [email protected] Subject: Re: [nhusers] Re: When using id generator class="assigned", why does extra select take place The Id for the entity we were generating was a comb guid. Rather than the code setting this we just changed the id generator to "guid.comb". No select is performed by NHibernate by default when we perform a save. Thanks for the help Billy Stack On Sat, Feb 5, 2011 at 3:10 PM, Jason Meckley <[email protected]> wrote: this worked in my situation, but the entities I was saving where children of a parent entity that was resolved from session. so the context is slightly different. In your situation it sounds like the entity with the assigned id is the root. You know it's an insert only model, but NH doesn't know that, so it needs to check if it exists. There may be a mapping/configuration setting that prevents load before save, or prevents updates, but I not 100% sure about that. If that doesn't work (or exist) I would change the POID strategy to allow NH/DB to handle it. If the assigned ID has business meaning, then map this as an immutable attribute of the entity. Another option is to drop the use of NH altogether. I haven't used event sourcing myself, but what little I understand it suppose to simplify persistence concerns. If that's the case then NH or an RDBMS wouldn't be required. -- 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 mailto:nhusers%[email protected]. For more options, visit this group at http://groups.google.com/group/nhusers?hl=en. -- 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. -- 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.
