Hibernate version: 3.1.3
Oracle 9
I am trying to remove individual entries from a QueryCache region during runtime. I couldn't find it anywhere in the documentation the right way to do it so I had to do some search on the web and come up what I have right now. It is very hacky but I can't think of another way to do it.
Please tell me that there is a proper way to do this.
Currently my code is manually building the QueryKey base on the sql string(hibernate.show_sql) and then passing the QueryKey to the cache.remove() method.
Code:
...
QueryKey queryKey = new QueryKey(sqlQueryKey, parameters, null, EntityMode.POJO);
if(cache.get(queryKey) != null){
cache.remove(queryKey);
}
...
It works fine except when I need to update the sqlQueryKey each time the object model changes.
Is there a better way to to this? Perhaps either by overriding the QueryCache key or figuring out what the sqlQueryKey is for a particular query during runtime?