Class Environment

java.lang.Object
org.hibernate.cfg.Environment
All Implemented Interfaces:
AgroalSettings, AvailableSettings, BatchSettings, BytecodeSettings, C3p0Settings, CacheSettings, EnvironmentSettings, FetchSettings, HikariCPSettings, JdbcSettings, JpaComplianceSettings, ManagedBeanSettings, MappingSettings, MultiTenancySettings, PersistenceSettings, ProxoolSettings, QuerySettings, SchemaToolingSettings, SessionEventSettings, StatisticsSettings, TransactionSettings, ValidationSettings

@Internal public final class Environment extends Object implements AvailableSettings
Provides access to configuration properties passed in Properties objects.

Hibernate has two property scopes:

  • Factory-level properties are specified when a SessionFactory is configured and instantiated. Each instance might have different property values.
  • System-level properties are shared by all factory instances and are always determined by the Environment properties in getProperties().

Environment properties are populated by calling System.getProperties() and then from a resource named /hibernate.properties, if it exists. System properties override properties specified in hibernate.properties.

The SessionFactory obtains properties from:

Configuration properties
PropertyInterpretation
"hibernate.dialect" name of Dialect subclass
"hibernate.connection.provider_class" name of a ConnectionProvider subclass (if not specified heuristics are used)
"hibernate.connection.username"database username
"hibernate.connection.password"database password
"hibernate.connection.url" JDBC URL (when using DriverManager)
"hibernate.connection.driver_class" classname of JDBC driver
"hibernate.connection.isolation" JDBC transaction isolation level (only when using DriverManager)
"hibernate.connection.pool_size" the maximum size of the connection pool (only when using DriverManager)
"hibernate.connection.datasource" datasource JNDI name (when using DataSource)
"hibernate.jndi.url"JNDI InitialContext URL
"hibernate.jndi.class"JNDI InitialContext class name
"hibernate.max_fetch_depth" maximum depth of outer join fetching
"hibernate.jdbc.batch_size" enable use of JDBC2 batch API for drivers which support it
"hibernate.jdbc.fetch_size" set the JDBC fetch size
"hibernate.jdbc.use_get_generated_keys" enable use of JDBC3 Statement.getGeneratedKeys() to retrieve natively generated keys after insert. Requires JDBC3+ driver and JRE1.4+
"hibernate.hbm2ddl.auto" enable auto DDL export
"hibernate.default_schema" use given schema name for unqualified tables (always optional)
"hibernate.default_catalog" use given catalog name for unqualified tables (always optional)
"hibernate.transaction.jta.platform" name of JtaPlatform implementation
See Also:
API Note:
This is really considered an internal contract, but leaving in place in this package as many applications use it historically. However, consider migrating to use AvailableSettings instead.
  • Method Details

    • getProperties

      public static Properties getProperties()
      The system properties, extended with all additional properties specified in hibernate.properties.