Reputation: 21211
I a persisted NHibernate object that I would like to repersist as a new entity. How do I get NHibernate to save this object as if it was a new?
I am thinking I might create a session interceptor to force every entity to look new and ensure the id is left blank like a new unpresisted entity would.
Upvotes: 0
Views: 1059
Reputation: 104178
You can implement the Clone method in your class. It is up to you to decide how to do this (swallow or deep copy). The identity property must be set to the 'unsaved-value' declared in the mapping file, so that NHibernate knows it is a new object.
Upvotes: 1