Hibernate version: 3.0
Name and version of the database you are using: FirstSQL 3.0
I'm experimenting with the PreInsertEventListener.
Although the code below gets executed correctly and the dataHash property is properly updated, the updated value is not written to disk, and the dataHash property remains null in the db record corresponding to the Thingy.
Should it be possible to modify entity values prior to insert/update? If so, why might the updated dataHash property fail to be written?
Code:
public class SBPreInsertListener extends DefaultPreInsertEventListener {
public SBPreInsertListener() {
}
public boolean onPreInsert(PreInsertEvent event) {
if (event.getEntity() instanceof Thingy) {
final Thingy thingy = (Thingy) event.getEntity();
thingy.setDataHash(thingy.getThingyData().save());
}
return super.onPreInsert(event);
}
}