I am beginning to get my hands dirty with Hibernate and I have configured my system to have an EHCache.
I have run into an issue where whenever I run a session.get(MyClass.class, int), I always seem to run a query against the database. I have set the object timeout to be longer than the amount of times that I execute multiple gets for this object. I turned on debug in log4j for the hibernate cache and hibernate jdbc packages. I have enabled both the second level cache and the query cache.
When i run a second get on the object, the log messages show that it has found the object since the following line is displayed:
DEBUG [http-7080-1] 2009-11-25 16:34:45,310 JCLLoggerAdapter.debug@170 key: com.objects.MyClass#2232
When I evict all objects from the sessionfactory cache, i see this message:
DEBUG [http-7080-1] 2009-11-25 16:35:40,356 JCLLoggerAdapter.debug@170 key: com.objects.MyClass#2232 DEBUG [http-7080-1] 2009-11-25 16:35:40,356 JCLLoggerAdapter.debug@170 Element for com.objects.MyClass#2232 is null
Either way I am seeing a query go against the database. I have the object set as read-write, however ,I know that the object is not being updated at all.
Am I just not understanding how the cache is supposed to work with Hibernate? Or is there some form of misconfiguration on my part?
Thanks
|