Is there an easy way to make NH INSERT or UPDATE an entity depending on whether there is already an entity with same <natural-id />
?
The entity is mapped to another (root) one using <many-to-one cascade="save-update" />
.
Is there an easy way to make NH INSERT or UPDATE an entity depending on whether there is already an entity with same <natural-id />
?
The entity is mapped to another (root) one using <many-to-one cascade="save-update" />
.
Not automatically. You will have to read from the database to see if a record for that natural-id already exists and then determine if you need to do an insert or update. Which of course means that the cascade won't work.
I was looking for something similar in http://stackoverflow.com/questions/325990/how-do-i-insert-or-update-or-overwrite-a-record-using-nhibernate