KarlW wrote:
So If I get you right, Hibernate works like that:
It saves an object o to table x.
After that I want to save another object ao to table y.
In the hibernate mapping of table y exists a many-to-one-relation with the first table x.
Before saving object ao to table y, hibernate will look in the database in table x if there is an object o.
Is that right???
Regards, Karl
No. Hibernate won't make sure that the o exists in table x when saving ao to table y without a FK constraint on the database. But it will throw an exception when reading the object if not-found="ignore" isn't specified on the <many-to-one>
You don't really want Hibernate to do all those extra database reads do you ? That's what database constraints are for.