I am using Second Level Cache[OsCache] with hibrenate.
Hibernate Ver: 3.0
OSCache Ver:2.1
It is set to expire after every 10000 seconds, 2.7 hours. This cache is marked as read-only as app. is never updating it.
Now, I went ahead and updated the table and added a new row, hoping that this new value will be reflected , worsat case after 2.7 hours.
But It did not. What I am observing is hibernate preserves the keys for each row and after the refresh perios merely refreshes the existing keys and does not even look for new rows in this table.
Please help me and let me know how can I get this working, or if even it is possible to do so?
Here are the logs when it the cache is expired,you can see that the query which gets fired is with already stored Ids. I want to get rid of these Ids, so that it gets the frsh data from the database.
Code:
] - DEBUG org.hibernate.cache.StandardQueryCache - checking cached query results in region: org.hibernate.cache.StandardQueryCache
[] - DEBUG com.opensymphony.oscache.base.algorithm.AbstractConcurrentReadCache - get called (key=sql: select codelist0_.ID as ID7_, codelist0_.CODE_NAME as CODE2_7_, codelist0_.CODE_DESCRIPTION as CODE3_7_ from CODE_LIST codelist0_ where code_name='Visibility Level'; parameters: ; named parameters: {}.org.hibernate.cache.StandardQueryCache)
[] - DEBUG org.hibernate.cache.StandardQueryCache - Checking query spaces for up-to-dateness: [CODE_LIST]
[] - DEBUG com.opensymphony.oscache.base.algorithm.AbstractConcurrentReadCache - get called (key=CODE_LIST.org.hibernate.cache.UpdateTimestampsCache)
[] - DEBUG com.opensymphony.oscache.base.algorithm.AbstractConcurrentReadCache - persistRetrieve called (key=CODE_LIST.org.hibernate.cache.UpdateTimestampsCache)
[] - DEBUG com.opensymphony.oscache.base.Cache - No cache entry exists for key='CODE_LIST.org.hibernate.cache.UpdateTimestampsCache', creating
[] - DEBUG org.hibernate.cache.StandardQueryCache - returning cached query results
[] - DEBUG org.hibernate.event.def.DefaultLoadEventListener - loading entity: [com.rajiv.ci.contactMgmt.DTO.CodeList#1295]
[] - DEBUG org.hibernate.event.def.DefaultLoadEventListener - attempting to resolve: [com.rajiv.ci.contactMgmt.DTO.CodeList#1295]
[] - DEBUG com.opensymphony.oscache.base.algorithm.AbstractConcurrentReadCache - get called (key=com.rajiv.ci.contactMgmt.DTO.CodeList#1295.com.rajiv.ci.contactMgmt.DTO.CodeList)
[] - DEBUG org.hibernate.event.def.DefaultLoadEventListener - object not resolved in any cache: [com.rajiv.ci.contactMgmt.DTO.CodeList#1295]
[] - DEBUG org.hibernate.persister.entity.AbstractEntityPersister - Fetching entity: [com.rajiv.ci.contactMgmt.DTO.CodeList#1295]
[] - DEBUG org.hibernate.loader.Loader - batch loading entity: [com.rajiv.ci.contactMgmt.DTO.CodeList#<1295, 103, 104, 105>]
[] - DEBUG org.hibernate.jdbc.AbstractBatcher - about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
[] - DEBUG org.hibernate.SQL -
select
codelist0_.ID as ID7_0_,
codelist0_.CODE_NAME as CODE2_7_0_,
codelist0_.CODE_DESCRIPTION as CODE3_7_0_
from
CODE_LIST codelist0_
where
codelist0_.ID in (
?, ?, ?, ?
)
[/code]