Another method would be to close and reopen the session so I can make changes to the product object:
Code:
session.Close();
session.OpenSession();
product.Id = 0;
session.SaveOrUpdate(product)
Both of these methods didn't seem right and I have gone down the route of deep cloning my product object (using serialization), setting its Id to 0 (to avoid any clashes in my table) and persisting it back using the session object.
This work great until you start building one-to-one relationships and need to clone each child object individually and reset their Id's to 0.
I'd just like to know that the method of keeping a constant session, cloning my domainobjects, resetting their key field to 0 and persisting them back is the correct/best/preferred way of copying records in a database?
Many Thanks!