Hibernate.orgCommunity Documentation

Chapter 1. Database Access

1.1. JDBC Connections
1.1.1. Using connection pooling
1.1.2. Using javax.sql.DataSource
1.2. Database Dialects
1.2.1. Specifying the Dialect to use
1.2.2. Dialect resolution
1.2.3. Custom Dialects
1.3. Database Schema

Hibernate understands how to connect to a database through an interface org.hibernate.connection.ConnectionProvider. While org.hibernate.connection.ConnectionProvider is considered an extension SPI, Hibernate comes with a number of built-in providers.

A Dialect informs Hibernate of the capabilities of the underlying database. This role is fulfilled by an instance of a org.hibernate.dialect.Dialect subclass. The Dialect is one of the most important pieces of information given to the Hibernate org.hibernate.Sessionfactory during startup as it allows Hibernate to properly plan how it needs to communicate with the database.

Assuming a org.hibernate.connection.ConnectionProvider has been set up according to Section 1.1, “JDBC Connections” then Hibernate will attempt to automatically determine the Dialect to use based on the java.sql.DatabaseMetaData reported by a java.sql.Connection obtained from that org.hibernate.connection.ConnectionProvider.

This functionality is provided by a series of org.hibernate.dialect.resolver.DialectResolver instances registered with Hibernate internally. Hibernate comes with a standard set of recognitions. If your application requires extra Dialect resolution capabilities, it would simply register a custom implementation of org.hibernate.dialect.resolver.DialectResolver as follows


Registered org.hibernate.dialect.resolver.DialectResolver are prepended to an internal list of resolvers, so they take precedence before any already registered resolvers including the standard one.

To be continued...