Interceptors in Hibernate

by Krishna Srinivasan

An interceptor can be used to intercept the existing business functionality to provide extensible or add-on features. They provide pluggable architecture and are generally callback methods that will be called by the framework in response to a particular set of events/actions if properly registered and configured. They follow the standard Interceptor pattern and they have various advantages in an application design. They can be used to monitor the various parts of the input that are passed to an application to validate them. They even have the capability to overwrite the core functional logic of the module.

A Hibernate application can be structured in a way such that certain methods can be make to be invoked when a particular life-cycle event occurs. Not always the API in a software/product will completely satisfy the application needs and requirements. Hibernate is no more away from this. Therefore, Hibernate API is designed in such a way to provide pluggable framework through the notion of Interceptors.

As we can see, the maintenance of this logging information should happen whenever when an insert/update goes to the Database. Such a logger interceptor can be easily plugged into the application with minimal code change because of the flexible design of Hibernate. Shunmuga Raja writes about Inteceptors in Hibernate here.

Interceptors in Hibernate.
Introduction to Java Server Faces


Basheer Ahamed
2007-05-14 07:15:55
In this book there are lotof things we have to learn......

realy it's good book for java developers.

2007-05-14 09:21:10
If you're going to copy verbatim the first three paragraphs of an article, at least fix the grammer. "Hibernate is no more away from this."
2007-05-14 23:26:27
I thought usage of Validatable and Lifecycle interfaces was not encouraged anymore by the hibernate team...
2007-05-15 02:18:14
There is a lot to learn alright.. mostly in presentation for the folks presenting the article.
I'm a little leery of following advice from a site that can't even present their info in a readable manner.