In an earlier post, I showed you how to integrate Hibernate with Spring using the annotation oriented persistence. For those still interested in the standard way I outline how you can accomplish that below. The key to the standard way is to use a Hibernate org.hibernate.SessionFactory for all access to the database through the domain objects. The Java configuration for the SessionFactory is shown below. Java Code: package com.acme.springexamples.car.dao.config;
In our previous tip, I gave an introduction to Spring’s persistence technology agnostic approach to data access. In this tip, we will show you how to use Spring with one of the most popular persistence technologies, Hibernate. Hibernate is an open source persistence framework that is one of the most successful persistence frameworks in the developer community. The reason for this is that it is a full featured object relational mapping (ORM) tool. It provides all the features you’d expect from a
Hibernate uses fetching strategy for retrieving associated objects when an application needs to navigate the association. Fetch strategies are declared in the object relational mapping metadata, or over-ridden by a particular HQL or Criteria query.
Hibernate defines following fetching strategies:
- Join fetching is used to retrieve the associated instance or collection in the same SELECT, using an OUTER JOIN.
- Select fetching is used