img
Major concepts of ORMs using Hibernate: We will go through the major concepts of
·
how to use Hibernate to map a POJO to the underlying relational database
structure. Some commonly used relationships, including one-to-many and many-
to-many, will also be discussed.
Data operations: We will go through a number of examples of how to perform data
·
operations (query, insert, update, delete) using Hibernate in the Spring
environment. When working with Hibernate, its Session interface is the major
interface that we will interact with.
Note When defining object-to-relational mappings, Hibernate supports two configuration styles. One is putting
the mapping information in XML files, and the other is using Java annotations within the entity classes (in the ORM
or JPA world, a Java class that is mapped to the underlying relational database structure is called an entity class).
Nowadays, the annotation approach is a much more popular one. So, in this chapter, we will focus on using the
annotation approach for object-relational mapping. For the mapping annotation, we will use the JPA standards
(e.g., under the javax.persistence package), because they are interchangeable with Hibernate's own
annotations and will help you with future migrations to a JPA environment.
Create a Hibernate Utility Project in STS
Just like Spring, Hibernate is a big library and is packaged into a number of modules (such as Hibernate
Core, Entity Manager, and so on). Sometimes you may find it difficult to identify which Hibernate
modules are required in your application. Fortunately, STS provides a simple way for you to create
common types of projects based on Spring, and a template project with Hibernate is also provided.
To create a project using Spring with Hibernate support, in STS simply create a new project using
the Simple Spring Hibernate Utility Project template, which you can find by selecting New Project
Spring Template Project (see Figure 9-1).
Search WWH :
Custom Search
Previous Page
Spring Framework 3 Topic Index
Next Page
Spring Framework 3 Bookmarks
Home