-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 8 posts ] 
Author Message
 Post subject: How can I turn off expry for the timestamp cache?
PostPosted: Fri Sep 17, 2004 9:04 pm 
Newbie

Joined: Fri Sep 17, 2004 2:53 pm
Posts: 7
Hi,

I really need help for my EhCache caching issue. I am using EhCache with Hibernate. I did whatever the document said to config the cache but can not get the cached records used. It still goes back to database everytime a query issued.

I turned on the debug info for EhCache, EhCacheProvider, ReadWriteCache, StandardQueryCache etc. I can tell the records have been cached but everytime to access it says "Cached item was locked". So no cached records returned. Sounds like this related to TimeStamp Cache.

In Christian and Gavin's Hibernate In Action page 292 says we should config the timestamp cache or we can turn the expiry off for timestamp cache.

Also I got a warn at the very beginning of my debug message:

WARN net.sf.hibernate.cache.EhCache - Could not find configuration for net.sf.hibernate.cache.UpdateTimestampsCache. Configuring using the defaultCache settings.

Please help me where can I config there values? Very appreciate your help!



Hibernate version: 2.1.6

Mapping documents:

Code between sessionFactory.openSession() and session.close():

Full stack trace of any exception that occurs:

Name and version of the database you are using:
MSSQL

The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:
2004-09-17 17:43:05,728 [HttpProcessor[8080][4]] WARN net.sf.hibernate.cache.EhCache - Could not find configuration for net.sf.hibernate.cache.UpdateTimestampsCache. Configuring using the defaultCache settings.
2004-09-17 17:43:05,748 [HttpProcessor[8080][4]] INFO net.sf.hibernate.cache.StandardQueryCache - starting query cache at region: net.sf.hibernate.cache.StandardQueryCache
2004-09-17 17:43:05,748 [HttpProcessor[8080][4]] WARN net.sf.hibernate.cache.EhCache - Could not find configuration for net.sf.hibernate.cache.StandardQueryCache. Configuring using the defaultCache settings.
2004-09-17 17:43:06,129 [HttpProcessor[8080][4]] INFO net.sf.hibernate.cache.StandardQueryCache - starting query cache at region: AllSearchRecordIDs
2004-09-17 17:43:06,129 [HttpProcessor[8080][4]] WARN net.sf.hibernate.cache.EhCache - Could not find configuration for AllSearchRecordIDs. Configuring using the defaultCache settings.
2004-09-17 17:43:06,139 [HttpProcessor[8080][4]] DEBUG net.sf.hibernate.cache.StandardQueryCache - checking cached query results in region: AllSearchRecordIDs
2004-09-17 17:43:06,139 [HttpProcessor[8080][4]] DEBUG net.sf.hibernate.cache.EhCache - key: sql: select colortag0_.SID as x0_0_ from RM_COLOR_TAG colortag0_ order by name asc; parameters: ; named parameters: {}
2004-09-17 17:43:06,139 [HttpProcessor[8080][4]] DEBUG net.sf.hibernate.cache.EhCache - Element for sql: select colortag0_.SID as x0_0_ from RM_COLOR_TAG colortag0_ order by name asc; parameters: ; named parameters: {} is null
2004-09-17 17:43:06,179 [HttpProcessor[8080][4]] DEBUG net.sf.hibernate.cache.StandardQueryCache - query results were not found in cache
2004-09-17 17:43:06,219 [HttpProcessor[8080][4]] DEBUG net.sf.hibernate.cache.StandardQueryCache - caching query results in region: AllSearchRecordIDs
2004-09-17 17:43:06,249 [HttpProcessor[8080][4]] INFO net.sf.hibernate.cache.StandardQueryCache - starting query cache at region: RecordRegion
2004-09-17 17:43:06,249 [HttpProcessor[8080][4]] WARN net.sf.hibernate.cache.EhCache - Could not find configuration for RecordRegion. Configuring using the defaultCache settings.
2004-09-17 17:43:06,269 [HttpProcessor[8080][4]] DEBUG net.sf.hibernate.cache.StandardQueryCache - checking cached query results in region: RecordRegion
2004-09-17 17:43:06,269 [HttpProcessor[8080][4]] DEBUG net.sf.hibernate.cache.EhCache - key: sql: select colortag0_.SID as SID, colortag0_.NAME as NAME, colortag0_.DESCRIPTION as DESCRIPT3_, colortag0_.FACILITY_MAP_CODE as FACILITY4_, colortag0_.STATUS as STATUS from RM_COLOR_TAG colortag0_ where (colortag0_.SID=? ); parameters: 2, ; named parameters: {}
2004-09-17 17:43:06,269 [HttpProcessor[8080][4]] DEBUG net.sf.hibernate.cache.EhCache - Element for sql: select colortag0_.SID as SID, colortag0_.NAME as NAME, colortag0_.DESCRIPTION as DESCRIPT3_, colortag0_.FACILITY_MAP_CODE as FACILITY4_, colortag0_.STATUS as STATUS from RM_COLOR_TAG colortag0_ where (colortag0_.SID=? ); parameters: 2, ; named parameters: {} is null
2004-09-17 17:43:06,269 [HttpProcessor[8080][4]] DEBUG net.sf.hibernate.cache.StandardQueryCache - query results were not found in cache
2004-09-17 17:43:06,329 [HttpProcessor[8080][4]] DEBUG net.sf.hibernate.cache.ReadWriteCache - Caching: 2
2004-09-17 17:43:06,329 [HttpProcessor[8080][4]] DEBUG net.sf.hibernate.cache.EhCache - key: 2
2004-09-17 17:43:06,329 [HttpProcessor[8080][4]] DEBUG net.sf.hibernate.cache.EhCache - Element for 2 is null
2004-09-17 17:43:06,339 [HttpProcessor[8080][4]] DEBUG net.sf.hibernate.cache.ReadWriteCache - Cached: 2
2004-09-17 17:43:06,339 [HttpProcessor[8080][4]] DEBUG net.sf.hibernate.cache.StandardQueryCache - caching query results in region: RecordRegion
2004-09-17 17:43:06,369 [HttpProcessor[8080][4]] DEBUG net.sf.hibernate.cache.StandardQueryCache - checking cached query results in region: net.sf.hibernate.cache.StandardQueryCache
2004-09-17 17:43:06,369 [HttpProcessor[8080][4]] DEBUG net.sf.hibernate.cache.EhCache - key: sql: select colortagfa0_.FACILITY_SID as x0_0_ from RM_COLOR_TAG_FACILITY colortagfa0_ where (colortagfa0_.RM_COLOR_TAG_SID=? ); parameters: 2, ; named parameters: {}
2004-09-17 17:43:06,379 [HttpProcessor[8080][4]] DEBUG net.sf.hibernate.cache.EhCache - Element for sql: select colortagfa0_.FACILITY_SID as x0_0_ from RM_COLOR_TAG_FACILITY colortagfa0_ where (colortagfa0_.RM_COLOR_TAG_SID=? ); parameters: 2, ; named parameters: {} is null
2004-09-17 17:43:06,379 [HttpProcessor[8080][4]] DEBUG net.sf.hibernate.cache.StandardQueryCache - query results were not found in cache
2004-09-17 17:43:06,379 [HttpProcessor[8080][4]] DEBUG net.sf.hibernate.cache.StandardQueryCache - caching query results in region: net.sf.hibernate.cache.StandardQueryCache
2004-09-17 17:43:06,379 [HttpProcessor[8080][4]] DEBUG net.sf.hibernate.cache.StandardQueryCache - checking cached query results in region: RecordRegion
2004-09-17 17:43:06,379 [HttpProcessor[8080][4]] DEBUG net.sf.hibernate.cache.EhCache - key: sql: select colortag0_.SID as SID, colortag0_.NAME as NAME, colortag0_.DESCRIPTION as DESCRIPT3_, colortag0_.FACILITY_MAP_CODE as FACILITY4_, colortag0_.STATUS as STATUS from RM_COLOR_TAG colortag0_ where (colortag0_.SID=? ); parameters: 1, ; named parameters: {}
2004-09-17 17:43:06,389 [HttpProcessor[8080][4]] DEBUG net.sf.hibernate.cache.EhCache - Element for sql: select colortag0_.SID as SID, colortag0_.NAME as NAME, colortag0_.DESCRIPTION as DESCRIPT3_, colortag0_.FACILITY_MAP_CODE as FACILITY4_, colortag0_.STATUS as STATUS from RM_COLOR_TAG colortag0_ where (colortag0_.SID=? ); parameters: 1, ; named parameters: {} is null
2004-09-17 17:43:06,389 [HttpProcessor[8080][4]] DEBUG net.sf.hibernate.cache.StandardQueryCache - query results were not found in cache
2004-09-17 17:43:06,389 [HttpProcessor[8080][4]] DEBUG net.sf.hibernate.cache.ReadWriteCache - Caching: 1
2004-09-17 17:43:06,389 [HttpProcessor[8080][4]] DEBUG net.sf.hibernate.cache.EhCache - key: 1
2004-09-17 17:43:06,389 [HttpProcessor[8080][4]] DEBUG net.sf.hibernate.cache.EhCache - Element for 1 is null
2004-09-17 17:43:06,399 [HttpProcessor[8080][4]] DEBUG net.sf.hibernate.cache.ReadWriteCache - Cached: 1
2004-09-17 17:43:06,399 [HttpProcessor[8080][4]] DEBUG net.sf.hibernate.cache.StandardQueryCache - caching query results in region: RecordRegion
2004-09-17 17:43:06,399 [HttpProcessor[8080][4]] DEBUG net.sf.hibernate.cache.StandardQueryCache - checking cached query results in region: net.sf.hibernate.cache.StandardQueryCache
2004-09-17 17:43:06,399 [HttpProcessor[8080][4]] DEBUG net.sf.hibernate.cache.EhCache - key: sql: select colortagfa0_.FACILITY_SID as x0_0_ from RM_COLOR_TAG_FACILITY colortagfa0_ where (colortagfa0_.RM_COLOR_TAG_SID=? ); parameters: 1, ; named parameters: {}
2004-09-17 17:43:06,399 [HttpProcessor[8080][4]] DEBUG net.sf.hibernate.cache.EhCache - Element for sql: select colortagfa0_.FACILITY_SID as x0_0_ from RM_COLOR_TAG_FACILITY colortagfa0_ where (colortagfa0_.RM_COLOR_TAG_SID=? ); parameters: 1, ; named parameters: {} is null
2004-09-17 17:43:06,399 [HttpProcessor[8080][4]] DEBUG net.sf.hibernate.cache.StandardQueryCache - query results were not found in cache
2004-09-17 17:43:06,479 [HttpProcessor[8080][4]] DEBUG net.sf.hibernate.cache.StandardQueryCache - caching query results in region: net.sf.hibernate.cache.StandardQueryCache
2004-09-17 17:43:43,273 [HttpProcessor[8080][4]] DEBUG net.sf.hibernate.cache.StandardQueryCache - checking cached query results in region: AllSearchRecordIDs
2004-09-17 17:43:43,283 [HttpProcessor[8080][4]] DEBUG net.sf.hibernate.cache.EhCache - key: sql: select suspension0_.SID as x0_0_ from RM_SUSPENSION_TYPE suspension0_ order by name asc; parameters: ; named parameters: {}
2004-09-17 17:43:43,283 [HttpProcessor[8080][4]] DEBUG net.sf.hibernate.cache.EhCache - Element for sql: select suspension0_.SID as x0_0_ from RM_SUSPENSION_TYPE suspension0_ order by name asc; parameters: ; named parameters: {} is null
2004-09-17 17:43:43,283 [HttpProcessor[8080][4]] DEBUG net.sf.hibernate.cache.StandardQueryCache - query results were not found in cache
2004-09-17 17:43:43,283 [HttpProcessor[8080][4]] DEBUG net.sf.hibernate.cache.StandardQueryCache - caching query results in region: AllSearchRecordIDs
2004-09-17 17:43:43,293 [HttpProcessor[8080][4]] DEBUG net.sf.hibernate.cache.StandardQueryCache - checking cached query results in region: RecordRegion
2004-09-17 17:43:43,293 [HttpProcessor[8080][4]] DEBUG net.sf.hibernate.cache.EhCache - key: sql: select suspension0_.SID as SID, suspension0_.NAME as NAME, suspension0_.DESCRIPTION as DESCRIPT3_, suspension0_.STATUS as STATUS from RM_SUSPENSION_TYPE suspension0_ where (suspension0_.SID=? ); parameters: 1, ; named parameters: {}
2004-09-17 17:43:43,293 [HttpProcessor[8080][4]] DEBUG net.sf.hibernate.cache.EhCache - Element for sql: select suspension0_.SID as SID, suspension0_.NAME as NAME, suspension0_.DESCRIPTION as DESCRIPT3_, suspension0_.STATUS as STATUS from RM_SUSPENSION_TYPE suspension0_ where (suspension0_.SID=? ); parameters: 1, ; named parameters: {} is null
2004-09-17 17:43:43,293 [HttpProcessor[8080][4]] DEBUG net.sf.hibernate.cache.StandardQueryCache - query results were not found in cache
2004-09-17 17:43:43,303 [HttpProcessor[8080][4]] DEBUG net.sf.hibernate.cache.ReadWriteCache - Caching: 1
2004-09-17 17:43:43,303 [HttpProcessor[8080][4]] DEBUG net.sf.hibernate.cache.EhCache - key: 1
2004-09-17 17:43:43,303 [HttpProcessor[8080][4]] DEBUG net.sf.hibernate.cache.EhCache - Element for 1 is null
2004-09-17 17:43:43,303 [HttpProcessor[8080][4]] DEBUG net.sf.hibernate.cache.ReadWriteCache - Cached: 1
2004-09-17 17:43:43,303 [HttpProcessor[8080][4]] DEBUG net.sf.hibernate.cache.StandardQueryCache - caching query results in region: RecordRegion
2004-09-17 17:43:45,497 [HttpProcessor[8080][4]] DEBUG net.sf.hibernate.cache.StandardQueryCache - checking cached query results in region: AllSearchRecordIDs
2004-09-17 17:43:45,497 [HttpProcessor[8080][4]] DEBUG net.sf.hibernate.cache.EhCache - key: sql: select colortag0_.SID as x0_0_ from RM_COLOR_TAG colortag0_ order by name asc; parameters: ; named parameters: {}
2004-09-17 17:43:45,497 [HttpProcessor[8080][4]] DEBUG net.sf.hibernate.cache.StandardQueryCache - Checking query spaces for up-to-dateness [[RM_COLOR_TAG]]
2004-09-17 17:43:45,497 [HttpProcessor[8080][4]] DEBUG net.sf.hibernate.cache.EhCache - key: RM_COLOR_TAG
2004-09-17 17:43:45,497 [HttpProcessor[8080][4]] DEBUG net.sf.hibernate.cache.EhCache - Element for RM_COLOR_TAG is null
2004-09-17 17:43:45,497 [HttpProcessor[8080][4]] DEBUG net.sf.hibernate.cache.StandardQueryCache - returning cached query results
2004-09-17 17:43:45,497 [HttpProcessor[8080][4]] DEBUG net.sf.hibernate.cache.StandardQueryCache - checking cached query results in region: RecordRegion
2004-09-17 17:43:45,507 [HttpProcessor[8080][4]] DEBUG net.sf.hibernate.cache.EhCache - key: sql: select colortag0_.SID as SID, colortag0_.NAME as NAME, colortag0_.DESCRIPTION as DESCRIPT3_, colortag0_.FACILITY_MAP_CODE as FACILITY4_, colortag0_.STATUS as STATUS from RM_COLOR_TAG colortag0_ where (colortag0_.SID=? ); parameters: 2, ; named parameters: {}
2004-09-17 17:43:45,507 [HttpProcessor[8080][4]] DEBUG net.sf.hibernate.cache.StandardQueryCache - Checking query spaces for up-to-dateness [[RM_COLOR_TAG]]
2004-09-17 17:43:45,507 [HttpProcessor[8080][4]] DEBUG net.sf.hibernate.cache.EhCache - key: RM_COLOR_TAG
2004-09-17 17:43:45,507 [HttpProcessor[8080][4]] DEBUG net.sf.hibernate.cache.EhCache - Element for RM_COLOR_TAG is null
2004-09-17 17:43:45,507 [HttpProcessor[8080][4]] DEBUG net.sf.hibernate.cache.StandardQueryCache - returning cached query results
2004-09-17 17:43:45,507 [HttpProcessor[8080][4]] DEBUG net.sf.hibernate.cache.ReadWriteCache - Cache lookup: 2
2004-09-17 17:43:45,517 [HttpProcessor[8080][4]] DEBUG net.sf.hibernate.cache.EhCache - key: 2
2004-09-17 17:43:45,517 [HttpProcessor[8080][4]] DEBUG net.sf.hibernate.cache.ReadWriteCache - Cached item was locked: 2
2004-09-17 17:43:45,527 [HttpProcessor[8080][4]] DEBUG net.sf.hibernate.cache.ReadWriteCache - Caching: 2
2004-09-17 17:43:45,527 [HttpProcessor[8080][4]] DEBUG net.sf.hibernate.cache.EhCache - key: 2
2004-09-17 17:43:45,527 [HttpProcessor[8080][4]] DEBUG net.sf.hibernate.cache.ReadWriteCache - Item was already cached: 2




Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 17, 2004 9:15 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Looks to me like you are not ending any transaction, since I don't see CacheConcurrencyStrategy.release() being called.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 20, 2004 1:20 pm 
Newbie

Joined: Fri Sep 17, 2004 2:53 pm
Posts: 7
gavin wrote:
Looks to me like you are not ending any transaction, since I don't see CacheConcurrencyStrategy.release() being called.


Hi Givan,

Thank you very much for your replay.

The debug info I included only related to query actions. There is no insert/update actions were taken. No transactions were used for my query only code. Do you mean I should close sessions? Yes I did for each database accessing.

I just wonder what makes these WARNs come out at the very beginning of my execution?

2004-09-20 10:00:07,186 [HttpProcessor[8080][3]] WARN net.sf.hibernate.cache.EhCache - Could not find configuration for net.sf.hibernate.cache.UpdateTimestampsCache. Configuring using the defaultCache settings.
2004-09-20 10:00:07,196 [HttpProcessor[8080][3]] WARN net.sf.hibernate.cache.EhCache - Could not find configuration for net.sf.hibernate.cache.StandardQueryCache. Configuring using the defaultCache settings.

I checked into the code ReadWriteCache.java the get() and set() functions. They both check the txTimeStamp to decide the cache results.

Could you please point what should be done to make it work right? Thanks!

Sophie


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 20, 2004 1:44 pm 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
You should always use the transaction API (if you are not using CMT). If you want more discussion on this, please search the forum for "always use transactions"


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 20, 2004 2:57 pm 
Newbie

Joined: Fri Sep 17, 2004 2:53 pm
Posts: 7
Yes. I searched and found many of them talking about use transactions.

I added tx = session.beginTransaction(); and tx.commit() to my code. I do not see any changes. It still access database everytime the query was executed.

Sounds like the query to get the primay keys was cached. But the records themself not get cached or at least the results were not returned from the cached.

I am still wonder why I get these messages from ReadWriteCache.java says Cached item was locked or Item was already cached which all mean nothing have been done.

Please give more suggestion. Thanks!

****************************************************
2004-09-20 11:42:31,766 [HttpProcessor[8080][1]] DEBUG net.sf.hibernate.cache.EhCache - key: sql: select colortag0_.SID as SID, colortag0_.NAME as NAME, colortag0_.DESCRIPTION as DESCRIPT3_, colortag0_.FACILITY_MAP_CODE as FACILITY4_, colortag0_.STATUS as STATUS from RM_COLOR_TAG colortag0_ where (colortag0_.SID=? ); parameters: 3, ; named parameters: {}
2004-09-20 11:42:31,766 [HttpProcessor[8080][1]] DEBUG net.sf.hibernate.cache.EhCache - key: RM_COLOR_TAG
2004-09-20 11:42:31,766 [HttpProcessor[8080][1]] DEBUG net.sf.hibernate.cache.EhCache - Element for RM_COLOR_TAG is null
2004-09-20 11:42:31,766 [HttpProcessor[8080][1]] DEBUG net.sf.hibernate.cache.ReadWriteCache - Cache lookup: 3
2004-09-20 11:42:31,776 [HttpProcessor[8080][1]] DEBUG net.sf.hibernate.cache.EhCache - key: 3
2004-09-20 11:42:31,776 [HttpProcessor[8080][1]] DEBUG net.sf.hibernate.cache.ReadWriteCache - Cached item was locked: 3
2004-09-20 11:42:31,776 [HttpProcessor[8080][1]] DEBUG net.sf.hibernate.cache.ReadWriteCache - Caching: 3
2004-09-20 11:42:31,776 [HttpProcessor[8080][1]] DEBUG net.sf.hibernate.cache.EhCache - key: 3
2004-09-20 11:42:31,776 [HttpProcessor[8080][1]] DEBUG net.sf.hibernate.cache.ReadWriteCache - Item was already cached: 3


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 20, 2004 6:18 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Query.setCacheable(true)


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 20, 2004 7:53 pm 
Newbie

Joined: Fri Sep 17, 2004 2:53 pm
Posts: 7
Hi Gavin,

Thanks for you replay. I have done all the following items. It still did not work. From the debug message of EhCache sounds like it could not get the cache. Here is some of the messages:

2004-09-20 16:19:15,243 [HttpProcessor[8080][3]] DEBUG net.sf.hibernate.cache.EhCache - key: RM_PATIENT_LOCATION
2004-09-20 16:19:15,243 [HttpProcessor[8080][3]] DEBUG net.sf.hibernate.cache.EhCache - Element for RM_PATIENT_LOCATION is null

I already have the follwong items setup in my config files and my code.
Could you help to find out what's worng?

Thanks!

1: I already set Query.setCacheable(true) in my code.

2: I set the following properties in my hibernate,cfg.xml file.
<property name="hibernate.cache.use_query_cache">true</property>
<property name="hibernate.cache.provider_class">net.sf.hibernate.cache.EhCacheProvider</property>

3: I put <cache usage="read-write" /> for each of my class entry in the mapping file:

<class name="FileLocation" table="FILE_LOCATION">
<cache usage="read-write" />
<id name="sid" type="int" column="SID" unsaved-value="-1" >
<generator class="identity"/>
</id>

<property name="name">
<column name="NAME" sql-type="varchar(16)" not-null="true" unique="true"/>
</property>

<property name="description">
<column name="DESCRIPTION" sql-type="varchar(256)" not-null="false"/>
</property>

<property name="facilityMapCode">
<column name="FACILITY_MAP_CODE" sql-type="int" />
</property>

<property name="status">
<column name="STATUS" sql-type="int" />
</property>
</class>

4: Also I entry for each class in my ehcache.xml file

<cache name="com.quadramed.topaz.rm.setup.data.hibernatemodel.FileLocation"
maxElementsInMemory="10000"
eternal="false"
timeToIdleSeconds="300"
timeToLiveSeconds="600"
overflowToDisk="true"
/>

Code:
    /**
     * @param objClass
     * @param facilityList
     * @return
     */
    public List getAllRecordsByFacilitySid(Class objClass, String facilityList) {
        Session session = null;
        Transaction tx = null;
        List records = new ArrayList();

        try {
            session = HibernateUtil.currentSession();

            String className = "";
            String facilityClassName = "";
            String query = "";
            if (objClass != null && objClass.getName() != null) {
                className = objClass.getName();
                if (SetupUtil.getFacilityClassName(className) != null) {
                    facilityClassName = SetupUtil.getFacilityClassName(className);
                    query = "select cn from " + className + " cn where cn.facilityMapCode = 1 or (cn.sid in (select fcn." + SetupUtil.getFacilityClassParentSidName(objClass.getName()) + " from " + facilityClassName + " fcn where fcn.facilitySid in (";
                    StringTokenizer st = new StringTokenizer(facilityList, ",");
                    int stCount = st.countTokens();
                    for (int i = 0; i < stCount; i++) {
                        if (i == st.countTokens() - 1) {
                            query += "?";
                        } else {
                            query += "?,";
                        }
                    }
                    query += "))) order by cn.name";
                } else if (SetupUtil.isWithFacilitySID(className) && className.indexOf("DeficiencyStatus") >= 0) {                  // for deficiency_status
                    query = "select cn from " + className + " cn where cn.facilitySid = ? order by cn.seqNum";
                } else if (SetupUtil.isWithFacilitySID(className)) {                  // document_panel tables
                    query = "select cn from " + className + " cn where cn.facilitySid = ? order by cn.name";
                } else if (className.indexOf("DocumentAttribute") >= 0) {
                    query = "select cn from " + className + " cn where cn.facilitySid = ? order by cn.docTypeSid";
                }
            }

            if (query.length() > 0) {
                tx = session.beginTransaction();
                Query q = session.createQuery(query);
                q.setCacheable(true);

                StringTokenizer st = new StringTokenizer(facilityList, ",");
                int stCount = st.countTokens();
                for (int i = 0; i < stCount; i++) {
                    q.setInteger(i, Integer.parseInt((String)st.nextElement()));
                }
                records = q.list();
                tx.commit();
            }
        } catch (HibernateException he) {
            throw new DataAccessException(he);
        } finally{
            HibernateUtil.closeSession(session);
        }
        return records;
    }


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 21, 2004 7:10 pm 
Newbie

Joined: Fri Sep 17, 2004 2:53 pm
Posts: 7
Gavin,

I did debug into the code and found the problem really is the timeStamp issue.

Our application is a really big web based application. We use tomcat and connection pool to configure JDBC connection. So in our code I past the existing JDBC connection.
public static Session currentSession() {
return sessionFactory.openSession(DBUtil.getConnection());
}

In code SessionFactoryImpl.java there serveral openSession() function calls.
Code:
   public Session openSession(Connection connection, Interceptor interceptor) {
      return openSession( connection, false, Long.MIN_VALUE, interceptor );
   }
   
   public Session openSession(Interceptor interceptor) throws HibernateException {
      // note that this timestamp is not correct if the connection provider
      // returns an older JDBC connection that was associated with a
      // transaction that was already begun before openSession() was called
      // (don't know any possible solution to this!)
      long timestamp = settings.getCacheProvider().nextTimestamp();
      return openSession( null, true, timestamp, interceptor );
   }
   
   public Session openSession(Connection connection) {
      return openSession(connection, interceptor); //prevents this session from adding things to cache


Not hard to tell the openSission() calls for my case already pass the long.MIN_VALUE.

This will result ReadWriteCache.java get() function always can not return the cache due to isGettable() always false.

For our case how can we pass a existing JDBC connection and get right time stamp at the same time? Otherwise what can we do to fix this.

Your suggestions will be very appreciated. Thank!


Code:
   public synchronized Object get(Object key, long txTimestamp) throws CacheException {
      
      if ( log.isTraceEnabled() ) log.trace("Cache lookup: " + key);
      
      try {
         cache.lock(key);
         
         Lockable lockable = (Lockable) cache.get(key);
         
         boolean gettable = lockable!=null && lockable.isGettable(txTimestamp);
         
         if (gettable) {
            if ( log.isTraceEnabled() ) log.trace("Cache hit: " + key);
            return ( (Item) lockable ).getValue();
         }
         else {
            if ( log.isTraceEnabled() ) {
               if (lockable==null) {
                  log.trace("Cache miss: " + key);
               }
               else {
                  log.trace("Cached item was locked: " + key);
               }
            }
            return null;
         }
      }
      finally {
         cache.unlock(key);
      }
   }



      public boolean isGettable(long txTimestamp) {
         return freshTimestamp < txTimestamp;
      }


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 8 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.