If you are managing the Id value in your code you should use a generator of "assigned" rather than "native".
John Davidson On Sat, Feb 26, 2011 at 10:56 AM, <[email protected]> wrote: > It would be very nice, if someone could take a quick look at the described > problem. Maybe i do something totally wrong, but i'm > runing a little out of time and don't know what to do. Thanks > > > > Am schrieb [email protected]: > > I have to correct the code form the last post it: > > > > public override object Generate(ISessionImplementor session, object obj) > > { > > if( obj is Domain.Base.PInfo ) > > { > > int nID = 0; > > if( int.TryParse((obj as Domain.Base.PInfo).StrIdent,out nID) ) > > { > > return nID; > > } > > return null; > > } > > return base.Generate(session,obj); > > } > > > > So i thought i give back the ID for the new entity. Not right? > > Ther inheritance from TableGenerator is because the DB has a TBL_IDEN > Table, so i do this in > > the Configure method: > > > > public override void Configure(IType type, IDictionary parms, Dialect > dialect) > > > { > > string strTable = parms["target_table"]; > > string strColumn = parms["target_column"]; > > > > parms["table"] = "TBL_IDEN"; > > parms["column"] = "IDEN_CNT"; > > parms["where"] = "((IDEN_TABLE = '" + strTable + "') AND (IDEN_COL = '" + > strColumn + "'))"; > > base.Configure(type, parms, dialect); > > } > > > > As for the mapping, the ID is mapped as "native" and StrIdent is a simple > string property: > > > > > > > > > > > > > > ... > > > > So, i hope this is enough information and anyone has a hint for me. > > > > Thanks > > > > Am schrieb [email protected]: > > > I know and i don't do that :-) > > > What I do is, i use an own IdentifierGenerator inherited from > TableGenerator. There i have to check the following: > > > > > > public override object Generate(ISessionImplementor session, object > obj) > > > { > > > if( obj is Thp5.Domain.Base.Patient.PatientInfo ) > > > { > > > int nID = 0; > > > if( int.TryParse((obj as Domain.Base.PInfo).StrIdent,out nID) ) > > > { > > > return nID; > > > } > > > return null; > > > } > > > return base.Generate(session,obj); > > > > > > This is because the ID is calculated from the string ID (don't ask > about it..it has to be this way) > > > > > > Is this the wrong way? > > > > > > Am schrieb "José F. Romaniello" [email protected]>: > > > > you should not modify the POIDs of your entities instances > > > > > > > > 2011/2/25 [email protected]> > > > > > > > > Hi all, > > > > > > > > i get the following exception and don't know exactly what i should do > about it: > > > > > > > > "identifier of an instance of Domain.Base.PInfo was altered from > 102472 to 102472" > > > > > > > > > > > > Any hint? > > > > > > > > Thanks > > > > > > > > > > > > > > > > > > > > -- > > > > > > > > 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. > > > > > > -- > 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.
