Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 775
Manish Mudgal Avatar asked Feb 21 '12 06:02

Manish Mudgal


1 Answers

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

  getSessionFactory().getCurrentSession().setFlushMode(FlushMode.NEVER);
  getSessionFactory().getCurrentSession().close()
like image 192
Vijay Avatar answered Oct 04 '22 02:10

Vijay