Manish Mudgal
Manish Mudgal

Reputation: 1186

Hibernate Interceptor/Listeners for HQL

I have a spring web application where I want to block hibernate's insert/delete/update operation if the user in httpSession is a kind of Super user (where user.isSuper() returns true).

I have implemented listener for these events but the problem is that listener is not firing for HQL queries(session.executeUpdate()).

Same problem is with interceptors as well.

Please help.

Upvotes: 6

Views: 1199

Answers (1)

Vijay
Vijay

Reputation: 5050

Try this following code instead of session.executeUpdate() :-

  getSessionFactory().getCurrentSession().setFlushMode(FlushMode.NEVER);
  getSessionFactory().getCurrentSession().close()

Upvotes: 1

Related Questions