This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
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?