One of my usages of NHibernate is to move objects between two different databases; for this reason I'd set the id type to be assigned (since I never want an id generated if the object doesn't exist at destination).
However, there are some cases when I do need to create new entities and I don't want to manually do the job that auto_increment does, so it would make more sense to set the id types to 'generated' for this case, but I very rarely need to use the 'generated' behaviour. I don't really want to duplicate the entire mapping file and have to maintain two copies.
The code below copies an object from database A to database B, and preserves the id x whether the object exists in B or not. If I change the id types to generated, will this remain the case?
Code:
long x = 100;
MyObject o;
{
Session sA = GetSessionOnA();
o = sA.Get<MyObject>(x);
}
Session sB = GetSessionOnB();
sB.SaveOrUpdateCopy(o);
sB.Flush();