47651

Hibernate Interceptor/Listeners for HQL

Question:

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.

Answer1:

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

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

Recommend

  • Accessing HttpSession in PreProcessInterceptor
  • Maven compile fails silently - Unresolved compilation problems
  • implementing HttpSessionListener
  • Spring Long Polling with DeferredResult
  • Django - can't get highchart to display data
  • Ruby: Why does this way of using map throw an error?
  • How to generate an asynchronous reset verilog always blocks with chisel
  • How to align an image side by side with a heading element?
  • findObjectsInBackgroundWithBlock block signature not correct
  • How gzip file gets stored in HDFS
  • What is the default HTTP verb in WebApi ? GET or POST?
  • Responsive left sidebar open close
  • Prevent page break in text block with iText, XMLWorker
  • C++ friend class std::vector
  • NHibernate manually control fetching
  • SyntaxError: (irb):26: both block arg and actual block given
  • TFS 2015 - Waiting for an agent to be requested
  • How to synchronize jQuery dialog box to act like alert() of Javascript
  • Object and struct member access and address offset calculation
  • Creating Java object from class name with constructor, which contains parameters [duplicate]
  • how to avoid repetitive constructor in children
  • Yii2: Config params vs. const/define
  • Ajax Loaded meta Tags
  • Deleting and Updating values from a cusrsor adapter
  • Possible to stop flickering java tooltip in heavyweight mode?
  • Fill an image in a square container while keeping aspect ratio
  • Rearranging Cells in UITableView Bug & Saving Changes
  • Windows forms listbox.selecteditem displaying “System.Data.DataRowView” instead of actual value
  • How to include full .NET prerequisite for Wix Burn installer
  • KeystoneJS: Relationships in Admin UI not updating
  • Authorize attributes not working in MVC 4
  • Bitwise OR returns boolean when one of operands is nil
  • Is it possible to post an object from jquery to bottle.py?
  • sending mail using smtp is too slow
  • Busy indicator not showing up in wpf window [duplicate]
  • Why is Django giving me: 'first_name' is an invalid keyword argument for this function?
  • Reading document lines to the user (python)
  • How can I use `wmic` in a Windows PE script?
  • Python/Django TangoWithDjango Models and Databases
  • Net Present Value in Excel for Grouped Recurring CF