Hibernate Tutorials/
« Previous | 1 | 2 | 3 | Next »
As you have learnt that in Hibernate, an object will be created and persisted. Once the object has been changed, it must be saved back to the database. This process continues until the next time the object is needed, and it will be loaded from the persistent store.

Thus an object passes through different stages in its life cycle andInterceptor Interface provides methods which can be called at different stages to perform some required tasks. These methods are callbacks from the session to the application, allowing the application to inspect and/or manipulate properties of a persistent object before it is saved, updated, deleted or loaded. Following is the list of all the methods available within the Interceptor interface:

S.N.Method and Description
1findDirty()This method is be called when the flush() method is called on a Session object.
2instantiate()This method is called when a persisted class is instantiated.
3isUnsaved()This method is called when an object is passed to thesaveOrUpdate() method/
4onDelete()This method is called before an object is deleted.
5onFlushDirty()This method is called when Hibernate detects that an object is dirty (ie. have been changed) during a flush i.e. update operation.
6onLoad()This method is called before an object is initialized.
7onSave()This method is called before an object is saved.
8postFlush()This method is called after a flush has occurred and an object has been updated in memory.
9preFlush()This method is called before a flush.

Hibernate Interceptor gives us total control over how an object will look to both the application and the database.
« Previous | 1 | 2 | 3 | Next »


copyright © 2014 - all rights riserved by javatechnologycenter.com