public static class DataContext.PreCommitEvent
extends java.util.EventObject
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(); } }
Constructor and Description |
---|
PreCommitEvent(DataContext dataContext,
java.util.Collection modified,
java.util.Collection removed) |
Modifier and Type | Method and Description |
---|---|
java.util.Collection |
getModifiedInstances()
Returns the collection of modified instances.
|
java.util.Collection |
getRemovedInstances()
Returns the collection of removed instances.
|
DataContext |
getSource()
The data context which sent the event.
|
boolean |
isCommitPrevented()
Returns true if
preventCommit() method was called and commit will be aborted. |
void |
preventCommit()
Invoke this method if you want to abort the commit.
|
public PreCommitEvent(DataContext dataContext, java.util.Collection modified, java.util.Collection removed)
public DataContext getSource()
getSource
in class java.util.EventObject
public java.util.Collection getModifiedInstances()
public java.util.Collection getRemovedInstances()
public void preventCommit()
public boolean isCommitPrevented()
preventCommit()
method was called and commit will be aborted.