Yeah, thanks Emmanuel, that's what I'm looking for.
The only thing I'm not sure on is how to determine which objects are dirty.
I thought this would be obvious from , but that doesn't always seem to be called. For example in the following scenario, the Cat (momo) has a reference to its Vet (sarah). If you save the Cat first, onFlushDirty() is never called on the Vet.
Is this the expected behaviour? Is there some other way to determine which objects are dirty?
Code:
sarah = Vet.create( "sarah", null );
momo = Cat.create( "momo", 'm', 8.5F, sarah );
// i.e. momo.setVet( sarah );
session.save( momo );
Quote:
onSave( [Cat 'momo'])
isTransient called on [Vet 'sarah']
Code:
session.save( sarah );
Quote:
onSave( [Vet 'sarah'])
Code:
session.flush();
Quote:
preFlush( [ [Cat 'momo'], [Vet 'sarah'] ] )
findDirty( [Cat 'momo'] )
onFlushDirty( [Cat 'momo'])
findDirty( [Vet 'sarah'] )
Hibernate: insert into CAT (version, NAME, sex, weight, vet, CAT_ID) values (?, ?, ?, ?, ?, ?)
Hibernate: insert into VET (version, NAME, certificationDate, VET_ID) values (?, ?, ?, ?)
Hibernate: update CAT set version=?, NAME=?, sex=?, weight=?, vet=? where CAT_ID=? and version=?
postFlush()