All,

 

I am searching a way to do the following:

Hibernate before executing a query will access my hook class. If my hook class returns an object this is the object that Hibernate should return as the result of this query, if I return null the query will continue to execute normally.

 

The motivation of doing this is. The second level cache works only on objects PKs (moreover I think it calls the second level cache only for PKs queries so even if I wrote my own second level cache implementation it won't work). I want to be able to use a cache that enables me to use it for non PKs queries. In this case I need to intercept the Hibernate query before it happens, check my cache and return the object if it exists and if not let hibernate continue his normal work.

 

I search the Interceptors/Events options and I did not found any solution for above, did I missed something? , Any ideas?

 

Thanks,

Ronen