org.hibernate.classic
public Interface Lifecycle
- Imports
- java.io.Serializable, org.hibernate.CallbackException, .Session
Provides callbacks from the Session to the persistent object.
Persistent classes may implement this interface but they are not
required to.
onSave: called just before the object is saved
onUpdate: called just before an object is updated,
ie. when Session.update() is called
onDelete: called just before an object is deleted
onLoad: called just after an object is loaded
onLoad() may be used to initialize transient properties of the
object from its persistent state. It may not be used to load
dependent objects since the Session interface may not be
invoked from inside this method.
A further intended usage of onLoad(), onSave() and
onUpdate() is to store a reference to the Session
for later use.
If onSave(), onUpdate() or onDelete() return
VETO, the operation is silently vetoed. If a
CallbackException is thrown, the operation is vetoed and the
exception is passed back to the application.
Note that onSave() is called after an identifier is assigned
to the object, except when identity column key generation is used.
- Author
- Gavin King
- See Also
CallbackException
Field Summary
| Modifier and Type | Field and Description
|
|---|
| public static final boolean | NO_VETOReturn value to accept the action (false)
|
| public static final boolean | VETOReturn value to veto the action (true)
|
Method Summary
| Modifier and Type | Method and Description
|
|---|
| public boolean | Returns: true to veto delete onDelete(Session the session s)Called when an entity is deleted.
|
| public void |
|
| public boolean | Returns: true to veto save onSave(Session the session s)Called when an entity is saved.
|
| public boolean | Returns: true to veto update onUpdate(Session the session s)Called when an entity is passed to Session.update().
|
Field Detail
| NO_VETO | back to summary
|
|---|
| public static final boolean NO_VETO Return value to accept the action (false)
|
| VETO | back to summary
|
|---|
| public static final boolean VETO Return value to veto the action (true)
|
Method Detail
| onLoad | back to summary
|
|---|
| public void onLoad(Session s, Serializable id) Called after an entity is loaded. It is illegal to
access the Session from inside this method.
However, the object may keep a reference to the session
for later use.
- Parameters
- s:Session
the session
- id:Serializable
the identifier
|
| onUpdate | back to summary
|
|---|
| public boolean onUpdate(Session s) throws CallbackException Called when an entity is passed to Session.update().
This method is not called every time the object's
state is persisted during a flush.
- Parameters
- s:Session
the session
- Returns:boolean
true to veto update
|