eftshift0
eftshift0

Reputation: 30156

hibernate - force save before delete

I have this information that I have to update on a table row before I issue the delete operation (a before delete trigger will take care of copying relevant data from the table). When I try to do the save and then delete from hibernate, hibernate will skip the save altogether. Sure... it makes sense to assume that it makes no sense to do the save operation if the entity is to be deleted.... but this is not the case as I just told you.

Committing the transaction before doing the delete could pull it off but that would mean that a new transaction would be required plus many more object I'm working with would have to be reloaded which makes it a no-go. Is there a way to adjust the definition of the entity so that the save operation is carried out before the actual delete?

Upvotes: 0

Views: 876

Answers (1)

Vitaly
Vitaly

Reputation: 2790

I guess you should try session.flush() before delete().

Upvotes: 1

Related Questions