Muneeb Tariq
Muneeb Tariq

Reputation: 35

Custom Listener Definition in Hibernate

I wrote a Custom Listener. But when i tries to set it in Hibernate Configuration as in

Configuration configuration=new Configuration().setListener("save-Update",XYZClass);

It states that there is no function with the name setListener. Help me out what am i doing wrong. My Hibernate Version id 4.02

Upvotes: 0

Views: 295

Answers (1)

Learner
Learner

Reputation: 21425

Hibernate 4.x do not have setListener method, this method is available in Hibernate 3.x version only.

In Hibernate 4.x you can use interceptors, go through this link for details:

Chapter 14. Interceptors and events Hibernate interceptor example

This SO post has some details on how to use Listeners in Hibernate 4.x, you can have a look at this:

eventlisteners using hibernate 4.0 with spring 3.1.0.release?

Upvotes: 1

Related Questions