-->
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.  [ 2 posts ] 
Author Message
 Post subject: Native SQL and 2nd Level Caching
PostPosted: Thu Aug 07, 2008 4:43 am 
Newbie

Joined: Thu Aug 07, 2008 4:23 am
Posts: 5
Hibernate Version: 3.3
Cache Provider: Ehcahce
App Server: Websphere 6.1 + EJB 3 FTP

Hi All,

I just want to confirm that the use of native SQL queries via session.createSQLQuery(x).executeUpdate() will not cause problems with the 2nd Level cache becoming out of sync.

Will both HQL and SQL updates be correctly sync'ed with the 2nd level cache?

Thanks in advance.

--
Karl


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 07, 2008 11:37 am 
Newbie

Joined: Thu Aug 07, 2008 4:23 am
Posts: 5
Following on from this;

My system correctly loads my objects during startup into the cache, output shown below:

Code:
IA-PERSISTENCE: ****** 2nd Level Cache Stats ******
IA-PERSISTENCE: Region Names: [hibernate.test.OrderProxy]
IA-PERSISTENCE: Elements in Memory: [6]
IA-PERSISTENCE: Elements on disk: [0]
IA-PERSISTENCE: Hit Count: [0]
IA-PERSISTENCE: Miss Count: [0]
IA-PERSISTENCE: Size in Memory: [20891]
IA-PERSISTENCE: Size in Memory: [20891]
IA-PERSISTENCE: ****** Session Factory Stats ******


Shows 6 objects are currently in memory;

I have the query cache enabled and my config is shown below

Code:
    <cache name="hibernate.test.OrderProxy"
        maxElementsInMemory="10000"
        eternal="false"
        timeToIdleSeconds="0"
        timeToLiveSeconds="0"
        overflowToDisk="false"
        />


I have a process that run every 60 seconds to execute a database update, example code shown below;

Code:
            session = sessionManager.acquireSession();
            SQLQuery query = sssion.createSQLQuery(UPDATE_BMPOINT_ORDER_STATUS_SQL);

            query.setParameter(0, toOrderStatus.getType());           
            int effectedRows = query.executeUpdate();
...
finally {
            session = sessionManager.releaseSession(session);                         
        }



This is running without problem and currently no rows are being reported as updated. Running this query seems to clear all objects from the cache.

Can anyone please help to explain why the cache is being cleared even though no rows are being updated by my SQLQuery.

Many thanks[/code]


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.