nordborg wrote:
Does the above code really works?
According to the API documenation for the Session.update() method an exception should be thrown if it is called with an argument that is already attached to the session. In any case, there is no need to call Session.update().
I am not sure that the call to tx.commit() should be placed inside the finally clause. If there is an error you will end up calling both rollback() and then commit().
Regarding the trigger, I have no idea.
Thank you for the suggestion, but even I got rid of those, hibernate still tried to delete first and then did a insert instead of just delete the proper record only...
Hibernate: delete from A_B where A_ID=?
Hibernate: insert into A_B (A_ID, B_ID) values (?, ?)