-->
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: ehcache.xml: QueryCache configuration
PostPosted: Wed May 19, 2004 4:16 am 
Expert
Expert

Joined: Fri Feb 06, 2004 7:49 am
Posts: 255
Location: Moscow, Russia
Hi there!

I would like to ask how to configure QueryCache in the ehcache.xml?
Quote:
WARN [net.sf.ehcache.hibernate.Plugin] Could not find configuration for net.sf.hibernate.cache.QueryCache. Configuring using the defaultCache settings.

In addition, what is this cache region?
Code:
query.setCacheable(true).setCacheRegion("cahe-region");

and where I have to configure it?

In the 14.3.1. Cache mappings said:
"Alternatively (preferrably?), you may specify <class-cache> and <collection-cache> elements in hibernate.cfg.xml."
Can anybody share an example of <class-cahe>,<collection-cache> configuration? And is this configuration an alternative or preferrable one? I think that using class-cahe and collection-cache is preferrable approach, I don't like to mix mapping and cache configuration in hbm.xml files, for me it would be more suitable to configure caches in the hibernate.cfg.xml and ehcache.xml.

Thanks,
Leonid


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 19, 2004 5:15 am 
Expert
Expert

Joined: Fri Feb 06, 2004 7:49 am
Posts: 255
Location: Moscow, Russia
It is funny (too simple:), the following code for QueryCache configuration works:

Code:
<cache name="net.sf.hibernate.cache.QueryCache"
      maxElementsInMemory="10000"
      eternal="false"
      timeToIdleSeconds="300"
      timeToLiveSeconds="600"
      overflowToDisk="false"
      />


DEBUG [net.sf.ehcache.store.MemoryStore] initialized MemoryStore for net.sf.hibernate.cache.QueryCache
...
INFO [net.sf.hibernate.cache.QueryCache] starting query cache at region: net.sf.hibernate.cache.QueryCache

But what about the second part of my previous post, about cache region, class-cache and collection-cache?

--
Leonid


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 19, 2004 5:30 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
The query cache is for caching query results (does not cache the whole objects, only the ids), the class-cache and collection-cache are specifically for making classes cachable, this affects the query cache, too (does not make much sense to use a query cache without making the returned classes cachable)


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 19, 2004 5:42 am 
Expert
Expert

Joined: Fri Feb 06, 2004 7:49 am
Posts: 255
Location: Moscow, Russia
michael wrote:
The query cache is for caching query results (does not cache the whole objects, only the ids), the class-cache and collection-cache are specifically for making classes cachable, this affects the query cache, too (does not make much sense to use a query cache without making the returned classes cachable)


Yeah, it is fine, but I read it in the documentation :)
What about cache regions and examples of class-cache, collection-cache in hibernate.cfg.xml?

Thanks,
Leonid


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 19, 2004 5:49 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
Well, query.setCacheRegion() just overrides the default region "net.sf.hibernate.cache.QueryCache".


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 19, 2004 5:54 am 
Expert
Expert

Joined: Fri Feb 06, 2004 7:49 am
Posts: 255
Location: Moscow, Russia
michael wrote:
Well, query.setCacheRegion() just overrides the default region "net.sf.hibernate.cache.QueryCache".

Thanks.

In the 14.3.1. Cache mappings said:
"Alternatively (preferrably?), you may specify <class-cache> and <collection-cache> elements in hibernate.cfg.xml."

Is is an alternative or preferrable approach? And where it is documented (DTD has no comments).

--
Leonid


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 19, 2004 6:02 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
Alternative, maybe preferable. It's your decission if you like it better or not. It is actually quite simple to use. To set up a cache for class yyy.XXX, instead of putting a <cache> element inside the Mapping, put

Code:
<class-cache class="yyy.XXX" usage="read-only"/>


inside the hibernate.cfg.xml. Same goes for collection zzz of class yyy.XXX, instead of putting a cache mapping inside of the collection mapping, you can put

Code:
<collection-cache collection="yyy.XXX.zzz" usage="transactional"/>


inside the hibernate.cfg.xml


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 19, 2004 7:42 am 
Expert
Expert

Joined: Fri Feb 06, 2004 7:49 am
Posts: 255
Location: Moscow, Russia
Well, and further. Does collection cache consist only IDs of objects (that should be cached too), like query cache?

--
Leonid


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.