[hibernate-dev] remove ID on failed flush

Marcel Hörr marcel.hoerr at gmx.de
Fri Oct 14 12:10:43 EDT 2011


hey guys,

i'm currently facing the following situation:

we're using the current stable version of hibernate (3.6.7) as a jpa-vendor with an oracle database. the ids of our entities are generated by a sequence, which works fine. but in the case of a failure during the save action, our entities get an id although they have not been saved to the database. in case of a sequence generated id this is quite bad, because we can not use this id again. the id should be set to null.

of course i have read the comments in this ticket:
https://hibernate.onjira.com/browse/HB-1014

or the conversations in this thread (and the conversations linked in that thread):
https://forum.hibernate.org/viewtopic.php?f=1&t=942461

but reading the above articles wasn't quite helpful, because no solution or hint in the right direction was suggested. a few people stated, that this behavior was fixed in hibernate 3, but that seems not be the case.

do you guys have any suggestions how to handle this problem? or is this something application code has to deal with in your opinion (i hope not ;-))?

any help appreciated.

- marcel



More information about the hibernate-dev mailing list