• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
  • Mikalai Zaikin

Hibernate Caching Ehcache

Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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

Don't get me started about those stupid light bulbs.
    Bookmark Topic Watch Topic
  • New Topic