If I use session-per-transaction and call:
session.SaveOrUpdate(entity) corrected:
session.SaveOrUpdateCopy
I noticed I saved by calling:
session.SaveOrUpdateCopy(entity);
..which does NOT update the Id. But by changing to:
session.SaveOrUpdate(entity);
..the Id's of transient entity will be updated.
I probably misunderstood the documentation (?).. Section 9.4.2 says:
SaveOrUpdateCopy(Object o)... If the given instance is unsaved or does not exist in the database, NHibernate will save it and return it as a newly persistent instance.
Is it just me, or does it not sound like a transient object (unsaved), will be "returned as persistent" ? Doesn't that mean with updated Id? Would appreciate a clarification how to interpret this sentence correctly (?)