Spring, Hibernate, EhCache Recipe
Integration of Spring and Hibernate with Second Level Cache (EhCache) is Demonstrated using a Simple Example. Check for Yourself the Positive Impact of a Second Level Cache in Hibernate.
Join the DZone community and get the full member experience.Join For Free
[Download Sample Code] Please be informed that the size is about 10MB; as i have provided all the dependencies.
QUERY FETCH TIME (INITIAL): 0.599
QUERY FETCH TIME (HIBERNATE CACHE): 0.212
QUERY FETCH TIME (2ND LEVEL CACHE): 0.091
Instructions: Unzip the file and start by creating the database. Any mySQL database that is compatible with the MySQL Connector 5.0.8 is fine for this example. You will have to create the database data_explosion (USERNAME: root, PASSWORD: architect.2012) and the table DOCTOR_TABLE. You can use the provided doctor.sql as reference. Then run the java standalone com.sumsoft.spring.orm.hibernate.dataload.JDBCDataLoader to create and load a large number of arbitary records into the DOCTOR_TABLE. You can ignore or remove every invocation that is to PATIENT_TABLE, as this is only additional for this example. Then use spring_hibernate_cache.bat to run the application. Though not tested on UNIX, you may write a script similar to the batch file to run this application.
Published at DZone with permission of Sumith Puri, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.