-->
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.  [ 3 posts ] 
Author Message
 Post subject: why I can't use oscache in hibernate?
PostPosted: Sun Aug 08, 2004 1:53 am 
Senior
Senior

Joined: Wed Dec 17, 2003 4:24 am
Posts: 188
2.15

<hibernate-mapping>

<class name="test.child" table="child">
<cache usage="read-write"/>
<id name="childid" type="string">
<column name="childid" length="200"/>
<generator class="uuid.hex"/>
</id>
<property name="name"/>
<property name="email"/>

</class>
</hibernate-mapping>


Configuration cfg=new Configuration().configure();
sf=cfg.buildSessionFactory();
//new SchemaExport(cfg).create(true,true);
Session s=sf.openSession();
Transaction t=s.beginTransaction();
Iterator iter=s.iterate("select c from child as c");
t.commit();
s.close();


14:02:36,084 INFO SettingsFactory:128 - cache provider: net.sf.hibernate.cache.
OSCacheProvider
14:02:36,144 INFO Configuration:1080 - instantiating and configuring caches
14:02:36,565 INFO SessionFactoryImpl:119 - building session factory
14:02:37,426 INFO SessionFactoryObjectFactory:82 - no JNDI name configured
14:02:37,436 INFO UpdateTimestampsCache:35 - starting update timestamps cache a
t region: net.sf.hibernate.cache.UpdateTimestampsCache
14:02:37,446 INFO QueryCache:39 - starting query cache at region: net.sf.hibern
ate.cache.QueryCache
Hibernate: select child0_.childid as x0_0_ from child child0_
Hibernate: select child0_.childid as childid0_, child0_.name as name0_, child0_.
email as email0_ from child child0_ where child0_.childid=?
.... .............


mysql4.0.1 alpha:

Debug level Hibernate log excerpt:

Hibernate query database everytime when I run the code.Why oscache can't work?
My hibernate.properties:
Code:
#hibernate.cache.provider_class net.sf.ehcache.hibernate.Provider
#hibernate.cache.provider_class net.sf.hibernate.cache.EmptyCacheProvider
#hibernate.cache.provider_class net.sf.hibernate.cache.HashtableCacheProvider
#hibernate.cache.provider_class net.sf.hibernate.cache.TreeCacheProvider
hibernate.cache.provider_class net.sf.hibernate.cache.OSCacheProvider
#hibernate.cache.provider_class net.sf.hibernate.cache.JCSCacheProvider
#hibernate.cache.provider_class net.sf.hibernate.cache.SwarmCacheProvider

I also place the cache.ccf in the src and class . The code in cache.ccf is:
Code:
# DEFAULT CACHE REGION (memory cache)
jcs.default=DC
jcs.default.cacheattributes=org.apache.jcs.engine.CompositeCacheAttributes
jcs.default.cacheattributes.MaxObjects=2000
jcs.default.cacheattributes.MemoryCacheName=org.apache.jcs.engine.memory.lru.LRUMemoryCache
jcs.default.elementattributes=org.apache.jcs.engine.ElementAttributes
jcs.default.elementattributes.IsEternal=false
jcs.default.elementattributes.MaxLifeSeconds=240
jcs.default.elementattributes.IdleTime=1800
jcs.default.elementattributes.IsSpool=true
jcs.default.elementattributes.IsRemote=false
jcs.default.elementattributes.IsLateral=false

# System CACHE REGION
jcs.system.groupIdCache=DC
jcs.system.groupIdCache.cacheattributes=org.apache.jcs.engine.CompositeCacheAttributes
jcs.system.groupIdCache.cacheattributes.MaxObjects=10000
jcs.system.groupIdCache.cacheattributes.MemoryCacheName=org.apache.jcs.engine.memory.lru.LRUMemoryCache

#Auxiliary CACHE (disk cache)
#jcs.auxiliary.DC=org.apache.jcs.auxiliary.disk.indexed.IndexedDiskCacheFactory
#jcs.auxiliary.DC.attributes=org.apache.jcs.auxiliary.disk.indexed.IndexedDiskCacheAttributes
#jcs.auxiliary.DC.attributes.DiskPath=cache


Why Hibernate query database everytime and it can't use oscache?
Thks!

_________________
You are not alone...


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 09, 2004 2:19 am 
Expert
Expert

Joined: Thu Jan 29, 2004 2:31 am
Posts: 362
Location: Switzerland, Bern
Hi

What do you exactly mean by
Quote:
Hibernate query database everytime when I run the code.


a) running the same piece of code several times within the same JVM run
b) restart of the JVM

By default the OSCache doesn't do any disk caching.

HTH
Ernst


Top
 Profile  
 
 Post subject: Thks
PostPosted: Tue Aug 10, 2004 8:13 pm 
Senior
Senior

Joined: Wed Dec 17, 2003 4:24 am
Posts: 188
It is within the same JVM.


I means that :


First I query the database, Hibernate send query sql to database.
Second I query ,Hibernate also send query sql to database. It don't use Cache at all!


I mean Hibernate shouldn't query database everytime .Because I had used oscache. Oscache maybe don't work.

How to make oscache work property? Thks

_________________
You are not alone...


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