Thanks for the answer, but I don't want to put one more column to the tables
for this purpose. What I envision is a solution which tracks the
persistent/transient state in the entity using an ordinary property, and use
that for the insert/update decision. I can programatically ensure that this
extra state property is reflects reality, but i need a way to tell
nhibernate to use this information. I think about using ILifecycle or
IInterceptor for this purpose and asking is there a way to do this?

Thanks.
Zsolt

On Wed, Sep 14, 2011 at 11:04 PM, Tyler Burd <[email protected]> wrote:

> One option is adding versioning to your entities.****
>
> ** **
>
> http://www.nhforge.org/doc/nh/en/index.html#mapping-declaration-version***
> *
>
> ** **
>
> You will need to add a version column to your table, as well as a version
> property.  I use a nullable int for this.  If the version property is null,
> NHibernate will treat the object as a new, unsaved object and issue inserts,
> no matter the ID.  If the version property is NOT null, it will know that
> the object already exists and issue an UPDATE statement.****
>
> ** **
>
> *From:* [email protected] [mailto:[email protected]] *On
> Behalf Of *Zsolt Soczo
> *Sent:* Wednesday, September 14, 2011 2:27 PM
> *To:* [email protected]
> *Subject:* [nhusers] Working with assigned ids****
>
> ** **
>
> Hello,
>   we have decided to use client side generated Guids for entity keys.
> However, this cause problems when I want to insert an entity with children
> entities.
> Nhibernate does not know whether the children are persistent in the
> database, so it must query them first and decide about the insert or update.
> This is very logical, but how can I help it to know which child object is
> new and which is already persisted?
> I can't use a zero guid to flag the entity as transient because of the very
> reason the id is generated on the client side. So, who can I give nhibernate
> the necessarily info to decide about the persistence state of the objects?
>
> Thanks,
> Zsolt****
>
> --
> 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.
>



-- 
Üdv,
soci

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