Configuring Hibernate

As you saw in Chapter 3, you must configure Hibernate before you can use it. The configuration is represented by an object of type org.hibernate.Configuration. This object wraps all of the configuration settings and is used in the next step for building a SessionFactory object. (We'll discuss a useful strategy for creating the SessionFactory at the end of this chapter.) To configure Hibernate, you first need to instantiate a configuration object:

Configuration cfg = new Configuration();

The actual configuration settings can be divided into two parts:

  • Hibernate properties: These include all of the database-related properties that Hibernate should consider while connecting to the database, as we saw earlier.
  • Hibernate mappings: ...

Get Spring Persistence with Hibernate now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.