for 2)
that's what i'm doing. I did override the NativeIdentifierGeneratorClass Property and return
there my Id generator. Therefore every id mapping is marked as "native".

for 3)
I do this now. But i really don't understand why the exception occurs when using the id generator. I wanted to avoid the assigned id because of the need to use save/update and i don't want this "logic" to assign the ID in the code of my entity class.



Am schrieb "José F. Romaniello" <[email protected]>:
I'm with John on this one, you should:

1-remove all the strident thing in you custom id generator

2-use your id generator as default for every mapping (you can override

the “native generator class" in a custom dialect and use native on

every mapping)

3-for the table/class that uses strident, set assigned instead of

native, and do the logic in the entity class.







2011/2/26, [email protected] [email protected]>:

> As far as i understood all this, i have to use native, if i want to provide

> my own ID generation. And i need this because the DB uses a TBL_IDEN for

> ID's.

> And in case of the PInfo Class there is no TBL_IDEN entry because the ID

> results from the StrIdent. So, since all the NH ID generators will not work,

> i have to use my own.

>

>

> Am schrieb John Davidson [email protected]>:

>> Why do you need that override if you want to use native. If you are using

>>

>> native, then there should be no override that sets the id value anywhere

>> in your code.

>

>> John Davidson

>

>

>> On Sat, Feb 26, 2011 at 12:27 PM, [email protected]> wrote:

>

>> I don't really want to manage the ID value in code. That's why i use the

>> IdentifierGenerator with the

>> overridden Generate method. So the ID is assigned from NH. I never touch

>> the ID in my code.

>

>> Am schrieb John Davidson [email protected]>:

>

>

>> > 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.

>> >

>

>

>

>

>> --

>

>> 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.

>

>



--

Enviado desde mi dispositivo móvil



--

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.

Reply via email to