sounds reasonable imo. note that you have to SELECT (i.e. refresh) after you create an entity, to get the new identity value, as it won't SELECT IDENTITY_INSERT() for you.
btw, for GUID id, it's considered best practice to use the "guid.comb" generator On Wed, Oct 29, 2008 at 4:18 PM, Bil Simser <[EMAIL PROTECTED]> wrote: > > Hi guys, > > Just wondering if this is the best way to do something. We have a > table mapping where we're using a GUID for the Id/primary key. In > addition, there's a requirement for us to give back a confirmation > number to users when we add a new item to this table. > > The workaround we did for this was as follows: > > Specify the table mappings like so: > > <class name="NumberRequest" lazy="false"> > <id name="Id" type="Guid"> > <generator class="assigned"/> > </id> > <property name="ConfirmationNumber" generated="insert" insert="false" > update="false"> > </class> > > Then in the mappings file change the column on creation to an identity > column using the <database-object> tag: > > <database-object> > <create> > ALTER TABLE NumberRequest DROP COLUMN ConfirmationNumber > ALTER TABLE NumberRequest ADD ConfirmationNumberINT IDENTITY > </create> > </database-object> > > Make sense or is there a better way? > > > -- Ken Egozi. http://www.kenegozi.com/blog http://www.musicglue.com http://www.castleproject.org http://www.gotfriends.co.il --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
