LaLiLuna wrote:
You can configure when Hibernate does flush. It is explained in the Hibernate reference.
10.10. Flushing the Session
normally you have to flush in seldom cases.
Eg. if you want to get the value from an auto-increment field.
when you use ids generated by the database, your database should not create double entries. You may have another problem here.
Regards Sebastian
I don't believe I have an additional problem. I am not inserting an additional value with the same id just the same name, and there is a unique constraint on the name. But I delete the old one first. Because hibernate is required to flush the identity inserts when they are called in order to obtain an id it does this immediately however it does not flush the deletes until the end of the transaction per it's performance strategy.
In my mind this doesn't make sense, if it knows it has to complete the sql inserts why not flush everything up until that point. However since it does not my question is what is the best strategy to handle this? Should I just flush after every delete?