Hibernate.orgCommunity Documentation

Preface

This document is focused on the use of the JBoss Cache clustered transactional caching library as a tool for caching data in a Hibernate-based application.

Working with object-oriented software and a relational database can be cumbersome and time consuming in today's enterprise environments. Hibernate is an object/relational mapping tool for Java environments. The term object/relational mapping (ORM) refers to the technique of mapping a data representation from an object model to a relational data model with a SQL-based schema.

Hibernate not only takes care of the mapping from Java classes to database tables (and from Java data types to SQL data types), but also provides data query and retrieval facilities and can significantly reduce development time otherwise spent with manual data handling in SQL and JDBC.

In any application that works with a relational database, caching data retrieved from the database can potentially improve application performance. Hibernate provides a number of facilities for caching data on the database client side, i.e. in the Java process in which Hibernate is running. The primary facility is the Hibernate Session itself, which maintains a transaction-scoped cache of persistent data. If you wish to cache data beyond the scope of a transaction, it is possible to configure a cluster or JVM-level (technically a SessionFactory-level) cache on a class-by-class, collection-by-collection and query-by-query basis. This type of cache is referred to as a Second Level Cache.

Hibernate provides a pluggable architecture for implementing its Second Level Cache, allowing it to integrate with a number of third-party caching libraries. This document is focused on the use of the JBoss Cache clustered transactional caching library as an implementation of the Second Level Cache. It specifically focuses on JBoss Cache 3.

If you are new to Hibernate and Object/Relational Mapping or even Java, please follow these steps:

  1. Read the Hibernate Reference Documentation, particularly the Introduction and Architecture sections.

  2. Have a look at the eg/ directory in the Hibernate distribution, it contains a simple standalone application. Copy your JDBC driver to the lib/ directory and edit etc/hibernate.properties, specifying correct values for your database. From a command prompt in the distribution directory, type ant eg (using Ant), or under Windows, type build eg.

  3. Use the Hibernate Reference Documentation as your primary source of information. Consider reading Java Persistence with Hibernate (http://www.manning.com/bauer2) if you need more help with application design or if you prefer a step-by-step tutorial. Also visit http://caveatemptor.hibernate.org and download the example application for Java Persistence with Hibernate.

  4. FAQs are answered on the Hibernate website.

  5. Third party demos, examples, and tutorials are linked on the Hibernate website.

  6. The Community Area on the Hibernate website is a good resource for design patterns and various integration solutions (Tomcat, JBoss AS, Struts, EJB, etc.).

If you are new to the Hibernate Second Level Cache or to JBoss Cache, please follow these steps:

  1. Read the Hibernate Reference Documentation, particularly the Second Level Cache and Configuration sections.

  2. Read the JBoss Cache User Guide, Core Edition.

  3. Use this guide as your primary source of information on the usage of JBoss Cache 3 as a Hibernate Second Level Cache.

If you have questions, use the user forum linked on the Hibernate website. The user forum on the JBoss Cache website is also useful. We also provide a JIRA issue tracking system for bug reports and feature requests. If you are interested in the development of Hibernate, join the developer mailing list. If you are interested in translating this documentation into your language, contact us on the developer mailing list.

Commercial development support, production support, and training for Hibernate is available through Red Hat, Inc. (see http://www.hibernate.org/SupportTraining/). Hibernate is a Professional Open Source project and a critical component of the JBoss Enterprise Application Platform.