Hibernate Configuration

Hibernate Configuration

Hibernate needs to know where to look for the mapping information that determines how your Java classes relate to database tables ahead of time. Hibernate also requires a set of databases and other associated parameter configuration settings. This information is usually provided in a hibernate—properties file in Java or a hibernate.cfg.xml file in XML.

My examples will use the XML-formatted file hibernate.cfg.xml to specify required Hibernate properties. Most properties have default values, so setting them in the property file isn't necessary unless it's necessary.

Hibernate Properties

As a solo database administrator, you will need to set up the following properties:

  • hibernate.dialect: This field tells Hibernate which SQL dialect to use for the selected database.
  • hibernate.connection.driver_class: The JDBC driver class is hibernate.connection.driver class.
  • hibernate.connection.url: JDBC URL for the database instance specified by hibernate.connection.url
  • hibernate.connection.username: Hibernate connection username.
  • hibernate.connection.password: The database password for hibernate.connection.password.
  • hibernate.connection.pool_size: The number of connections waiting in the Hibernate database connection pool can be limited with this property.
  • hibernate.connection.autocommit: JDBC connection autocommit mode is enabled via hibernate.connection.autocommit.