native « Key « JPA Q&A





1. Set with natively generated keys    forum.hibernate.org

I realize the contract for set says that contained objects must be unique. What do you do when you want to support cascaded inserts when the children are in a set? I ended up overriding equals and getHashCode to id if one exists otherwise I used a candidate key's attributes. What do you do when you don't have a candidate key ...

2. identity primary key with class="native"    forum.hibernate.org

If you are worrying about insert sql statement being issued to the database, then stop: RDBMS will discard the insert if transaction will be rolled back. Note: db connection should not be in the autocommit mode and the RDBMS is supposed to support transactions (for example MySQL does not support them without innodb)