aspose file tools*
The moose likes Object Relational Mapping and the fly likes Hibernate Caching Ehcache Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Hibernate Caching Ehcache " Watch "Hibernate Caching Ehcache " New topic
Author

Hibernate Caching Ehcache

daphna deutsch
Greenhorn

Joined: Nov 17, 2005
Posts: 17
Hello,

I'm trying to implement the Hibernate Caching Ehcache, and I have a few problem/questions.
In my test, I have two tables – Country & Airports, while the relation between them is one-to-many.

In both hbm file (for Country & Airports) I set <cache usage="read-only"/>


And also for the relation from country to airports I set


I run a test method that request all countries in a loop, and counting the time for each quires.
To make sure caching is working I also set the property hibernate.show_sql to true in the hibernate configuration file.

The result – the first iteration perform one query for the COUNTRY table, and about 1000 quires for the AIRPORT table.
The other iteration perform only one query for the COUNTRY table.

My questions are:
1) Why does the first iteration run the same query on the airport table so many times.
2) Why does the other queries still run the query on the country table.
3) I notice that the behavior remains the same whether I put <cache usage="read-only"/> in the country.hbm file or not. Do I need to set this?

Also – I tried to set the ehcache.xml file, placing it on the same path as the hibernate configuration file, but it looks like it being ignored.
How can I use this file?

Thanks in advanced

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Hibernate Caching Ehcache