A Simple Scenario explaining the Usage and Performance, when using EhCache (2nd Level Cache of along with Hibernate in a Spring environment. The performance results are taken using mySQL as the Database.
Though this Example is from Spring 2.5.x and Hibernate 3.x and EhCache 1.4, MySQL 5.0 => The Concepts Demonstrated will Continue to Hold Good for any Version of any Make of Second Level Cache Product with Hibernate (Optionally, Spring) such as Infinispan, Redis, Hazelcast, …
[Download Sample Code] Please be informed that the size is about 10MB; as i have provided all the dependencies.
In this example, I need to retrieve close to 5,000 records in a single fetch and then cache this information. As usual, setup Spring contexts in your Spring configuration file. I have just one class, which is a Hibernate DAO, _HibernateDoctorDAO.java. _The dependency injection hierarchy is dataSource **> **sessionFactory **> **hibernateTemplate. hibernateTemplate is then injected into the _HibernateDoctorDAO.java _at runtime by the Spring Framework.
#hibernate #j2ee #core java #java performance #ehcache #mysql ( 5 ) #data caching #java persistence #spring 2.5 #hibernate caching