hibernate_newbie wrote:
The evict wouldn't work in our case anyways because we're using autogenerated ids. Hibernate would complain about not the object having a null id since the save failed.
The IDs are assigned to the objects when you invoke save, and if the flush fails (the actual insert/update) and you rollback the "DATABASE" transaction, you'll notice the objects will still have the ID's business state prior to the Exception. As such, you can merge those objects into a new Session (even though they are auto-gend-ids), and invoke save/(flush if needed) again and it should work.