• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Need ORM that allows interception (and modifiation) of qeuries

 
Kevin Embree
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am designing a solution for a project, but to achieve my current design goals I need to be able to intercept (and modify) 99% of all queries in the ORM before they are executed.
NOTE: for purposes of code maintenance and performance intercepting the result sets while functional is not adequate

Ideally, I would like to intercept and manipulate the query objects (specifically add additional 'where' parameters) and not have to intercept the native SQL. Though I could work with intercepting the native sql, if I had to.

I have only used hibernate before for ORM, I have been unsuccessful in finding a means to do this sort of interception with the hibernate API(I would love it if someone can point me to a solution in hibernate)

I have just discovered @queryreceptors in eclipselink but I'm not sure this is what I'm looking for though, if there is a eclipselink guru out there that could clarify it for me that would be awesome. Anyone else aware of any other ORM that may provide this type of functionality?

Many thanks in advance,
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 35279
384
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not a technology per se, but you could use AOP to write an interceptor on the methods that the ORM uses to access the database? That would let you modify them as they go by.
 
Kevin Embree
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Interesting idea, I haven't used a generic AOP before, that would provide the benefit that I don't have to abandon hibernate, which I'm already comfortable with.
Any AOP recommendations? I happen to be developing for a Wildfly application server. They probably have a bundled one. I'll have to check. If anyone else knows of a ORM with built-in functionality to do this I'd still like to know of it.
But for now I will read up on AOPs.

thanks!
 
Tim Holloway
Saloon Keeper
Posts: 18359
56
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I recommend reading this similar discussion: http://www.coderanch.com/t/648601/ORM/databases/native-SQL-fragment-clause-bigger
 
Kevin Embree
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For me the solution I'm going with is using a visitListener in JOOQ. It allows full automated manipulation of the SQL and with proper usage can ensure the correct manipulations are applied to every applicable SQL throughout the entire application.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic