org.hibernate.cfg.AvailableSettings enumerates all the
configuration properties recognized by Hibernate.
org.hibernate.cfg.Configuration provides a simplified
API for bootstrapping Hibernate, as an alternative to the more
extensive facilities defined under org.hibernate.boot .
Note that all the real meat behind these APIs is defined in the package
org..
Configuration properties may be specified:
persistence.xml,
hibernate.cfg.xml,
hibernate.properties, or
We now present a couple of example configuration files.
persistence.xml:
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
version="2.0">
<persistence-unit name="postgresql-example" transaction-type="RESOURCE_LOCAL">
<class>org.hibernate.orm.example.Author</class>
<class>org.hibernate.orm.example.Book</class>
<properties>
<!-- PostgreSQL -->
<property name="javax.persistence.jdbc.url"
value="jdbc:postgresql://localhost/library"/>
<!-- Credentials -->
<property name="javax.persistence.jdbc.user"
value="hibernate"/>
<property name="javax.persistence.jdbc.password"
value="hibernate"/>
<!-- Agroal connection pool config -->
<property name="hibernate.agroal.maxSize"
value="10"/>
<property name="hibernate.agroal.acquisitionTimeout"
value="PT1s"/>
<property name="hibernate.agroal.reapTimeout"
value="PT10s"/>
<!-- Automatic schema export -->
<property name="javax.persistence.schema-generation.database.action"
value="drop-and-create"/>
<!-- SQL statement logging -->
<property name="hibernate.show_sql" value="true"/>
<property name="hibernate.format_sql" value="true"/>
<property name="hibernate.highlight_sql" value="true"/>
</properties>
</persistence-unit>
</persistence>
The JPA configuration file is necessary when bootstrapping Hibernate via
jakarta.persistence.Persistence#createEntityManagerFactory(java.lang.String) .
hibernate.cfg.xml:
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<!-- PostgreSQL -->
<property name="javax.persistence.jdbc.url">jdbc:postgresql://localhost/library</property>
<!-- Credentials -->
<property name="hibernate.connection.username">hibernate</property>
<property name="hibernate.connection.password">hibernate</property>
<!-- Agroal connection pool config -->
<property name="hibernate.agroal.maxSize">10</property>
<property name="hibernate.agroal.acquisitionTimeout">PT1s</property>
<property name="hibernate.agroal.reapTimeout">PT10s</property>
<!-- Automatic schema export -->
<property name="hibernate.hbm2ddl.auto">create</property>
<!-- SQL statement logging -->
<property name="hibernate.show_sql">true</property>
<property name="hibernate.format_sql">true</property>
<property name="hibernate.highlight_sql">true</property>
<!-- Maximum JDBC batch size -->
<property name="hibernate.jdbc.batch_size">10</property>
<!-- Entity classes -->
<mapping class="org.hibernate.orm.example.Author"/>
<mapping class="org.hibernate.orm.example.Book"/>
</session-factory>
</hibernate-configuration>
The native configuration file is used when configuring Hibernate via
org.hibernate.cfg.Configuration#configure() or
org.hibernate.boot.registry.StandardServiceRegistryBuilder#configure() .
| Modifier and Type | Interface and Description |
|---|---|
| public interface | AvailableSettings
Enumerates the configuration properties supported by Hibernate, including properties defined by the JPA specification. |
| public interface | |
| public interface | BytecodeSettings
Settings which control the |
| public interface | |
| public interface | CacheSettings
Settings for Hibernate's second-level caching |
| public interface | DialectSpecificSettings
Settings used as fallback to configure aspects of specific |
| public interface | |
| public interface | |
| public interface | JdbcSettings
Settings related to JDBC, Connections, pools, Dialects, etc |
| public interface | |
| public interface | |
| public interface | |
| public interface | |
| public interface | NamingStrategy
Deprecated
for removal since 6. A set of rules for determining the physical column
and table names given the information in the mapping
document.
org.
and org. should
be used instead.
|
| public interface | PersistenceSettings
Settings related to persistence-units |
| public interface | |
| public interface | |
| public interface | |
| public interface | SecondPass
Deprecated
for removal since 6. Use Hibernate builds its build-time model
incrementally, often delaying operations until other pieces of information
are available.
org. instead
|
| public interface | |
| public interface | |
| public interface | |
| public interface |
| Modifier and Type | Class and Description |
|---|---|
| public class | Configuration
A convenience API making it easier to bootstrap an instance of Hibernate. |
| public class | DefaultComponentSafeNamingStrategy
Deprecated
NamingStrategy itself has been deprecated
|
| public class | DefaultNamingStrategy
Deprecated
The default NamingStrategy itself has been deprecated
NamingStrategy
|
| public class | Environment
Provides access to configuration properties passed in |
| public class | ImprovedNamingStrategy
Deprecated
An improved naming strategy that prefers embedded
underscores to mixed case names
NamingStrategy itself has been deprecated
|
| public class | PersistenceStandardNamingStrategy
Deprecated
Naming strategy implementing the EJB3 standards
NamingStrategy itself has been deprecated
|
| public class | RecoverableException
Deprecated
Was only ever referenced in a single place, in an extremely dubious way.
An exception that indicates a condition where the hope is that subsequent processing will be able to
recover from it.
|
| Modifier and Type | Enum and Description |
|---|---|
| public enum | MetadataSourceType
Deprecated
for removal since 6. Enumeration of the types of sources of mapping metadata
hbm.xml mappings are no longer supported, making this attribute irrelevant
|