Event sent before committing changes.
In this event listener, you can add arbitrary entity instances to the committed collections returned by
#getModifiedInstances() and
#getRemovedInstances() methods, for example:
@Subscribe(target = Target.DATA_CONTEXT)
protected void onPreCommit(DataContext.PreCommitEvent event) {
event.getModifiedInstances().add(customer);
}
You can also prevent commit using the
#preventCommit() method of the event, for example:
@Subscribe(target = Target.DATA_CONTEXT)
protected void onPreCommit(DataContext.PreCommitEvent event) {
if (doNotCommit()) {
event.preventCommit();
}
}