Hibernate Interceptor / HQL Listeners

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

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

The same goes for interceptors.

Please, help.

+6
source share
1 answer

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

getSessionFactory().getCurrentSession().setFlushMode(FlushMode.NEVER); getSessionFactory().getCurrentSession().close() 
+1
source

Source: https://habr.com/ru/post/908950/


All Articles