I've come across an odd quirk in hibernate. Namely, when updating one of the properties in a composite-id, I've found I need to flush the session after the delete in order for the old record to be deleted.
session.delete(obj);
session.flush();
obj.setIdProperty1(newValue);
session.save(obj);
If the session.flush()
is omitted, the original record does not get deleted. This means that two sepa开发者_如何转开发rate calls to the database need to be made instead of one when updating the id fields. I'm wondering whether the flush can be avoided so that the delete/insert can be sent as a batch?
tnx!
精彩评论