-->
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.  [ 4 posts ] 
Author Message
 Post subject: Collections are not getting cached.
PostPosted: Tue Sep 06, 2005 8:49 am 
Newbie

Joined: Tue Apr 12, 2005 12:07 pm
Posts: 6
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

[b]The problem we are facing is very straight forward but we are not able to find the solution of the problem.

The cache we are using is EHCache. The collections we are using in our hibernate class is getting cached.[/b]

[b]Scenario:[/b]
We have a product class which maps to the product table in the database. A product have assets(images) related to it which are stored in seprate table and we have ProductAsset class for that table. These Assets are present as List in the class and mapped as bag in hbm.xml one more thing to note down is that this collection has lazy="true" settings.

[b]Problem:[/b]
Now if i query for first time for a product using any Criteria i got a list of products and those are getting cached as well, the i call an API to get list of assets say product.getAssets(), hibernate again fires the query for getting assets which is fine and assets are also getting cahced. But if i fire the same thing again then only products are getting resolved from the second-level cache and not the assets for assets hibernate is again firing queries.

We are just clueless why it is happening, we have implemented the hashcode() and equals() method as well properly and have properly defined ehcahe settings.

Please provide us help ASAP as our perfomance is not getting improved.

[b]Hibernate version: 2.1 [/b]

[b]Mapping documents:[/b]

[b]Code between sessionFactory.openSession() and session.close():[/b]

[b]Full stack trace of any exception that occurs:[/b]

[b]Name and version of the database you are using:[/b]

[b]The generated SQL (show_sql=true):[/b]

[b]Debug level Hibernate log excerpt:[/b]


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 15, 2005 2:13 am 
Newbie

Joined: Sun Feb 13, 2005 6:39 am
Posts: 11
Location: Belgium
Caching the collections is done by defening the <cache> tag for each Set/Bag or whatever type of collection you want to get cached.

So you do not only need to set this at <class> level.

However, I now have the problem that the cached collections are not getting fetched when I perform the same query again.

Hope the first part helps you out.
Nico


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 15, 2005 6:12 am 
Newbie

Joined: Tue Apr 12, 2005 12:07 pm
Posts: 6
I used that as well but i have noticed scenarios that it is some how not working with Criteria queries.

Can somebody verify that please. We are already using setCacheable(true) in our code.

Thanks,
Namish


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 15, 2005 7:04 am 
Newbie

Joined: Sun Feb 13, 2005 6:39 am
Posts: 11
Location: Belgium
We do not use the setCacheable(true) in our code, but did define it in the HibernateTemplate of the Springframework. If you are not using then ofcourse the call should be placed in your code to activate it.

However I you want some caching of the queries tou need to activate the QueryCache, as this is by default deactivated.

You activate the QeuryCache by setting the following property to true
hibernate.cache.provider_class=org.hibernate.cache.EhCacheProvider

hibernate.cache.use_query_cache=true

Hope this helps,
Regards,
Nico[/i]


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