Top Description Fields Constructors Methods
org.hibernate.cfg

public final Class Environment

extends Object
implements AvailableSettings
Class Inheritance
All Implemented Interfaces
org.hibernate.cfg.AvailableSettings, org.hibernate.jpa.AvailableSettings
Imports
java.io.IOException, .InputStream, java.util.Map, .Properties, org.hibernate.HibernateException, .Version, org.hibernate.bytecode.spi.BytecodeProvider, org.hibernate.engine.jdbc.connections.internal.ConnectionProviderInitiator, org.hibernate.internal.CoreMessageLogger, org.hibernate.internal.log.UnsupportedLogger, org.hibernate.internal.util.ConfigHelper, org.hibernate.internal.util.config.ConfigurationHelper, org.jboss.logging.Logger

Deprecated

as a consequence of AvailableSettings being deprecated. See corresponding docs for further information.

Provides access to configuration info passed in Properties objects.

Hibernate has two property scopes: The only system-level properties are 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 is controlled by the following properties. Properties may be either be System properties, properties defined in a resource named /hibernate.properties or an instance of java.util.Properties passed to Configuration.build()

propertymeaning
hibernate.dialect classname of org.hibernate.dialect.Dialect subclass
hibernate.connection.provider_class classname of ConnectionProvider subclass (if not specified heuristics are used)
hibernate.connection.usernamedatabase username
hibernate.connection.passworddatabase password
hibernate.connection.url JDBC URL (when using java.sql.DriverManager)
hibernate.connection.driver_class classname of JDBC driver
hibernate.connection.isolation JDBC transaction isolation level (only when using java.sql.DriverManager)
hibernate.connection.pool_size the maximum size of the connection pool (only when using java.sql.DriverManager)
hibernate.connection.datasource datasource JNDI name (when using javax.sql.Datasource)
hibernate.jndi.urlJNDI InitialContext URL
hibernate.jndi.classJNDI InitialContext classname
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_scrollable_resultset enable use of JDBC2 scrollable resultsets (you only need to specify this property when using user supplied connections)
hibernate.jdbc.use_getGeneratedKeys enable use of JDBC3 PreparedStatement.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.session_factory_name If set, the factory attempts to bind this name to itself in the JNDI context. This name is also used to support cross JVM Session (de)serialization.
hibernate.transaction.jta.platform classname of org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform implementor
hibernate.transaction.factory_class the factory to use for instantiating Transactions. (Defaults to JdbcTransactionFactory.)
hibernate.query.substitutionsquery language token substitutions
Author
Gavin King
See Also
org.hibernate.SessionFactory

Field Summary

Modifier and TypeField and Description
private static final BytecodeProvider
public static final String
public static final String
public static final String
public static final String
private static final boolean
private static final boolean
private static final boolean
private static final Properties
private static final CoreMessageLogger

Constructor Summary

AccessConstructor and Description
private
Environment()

Disallow instantiation

Method Summary

Modifier and TypeMethod and Description
public static BytecodeProvider
private static BytecodeProvider
public static BytecodeProvider
getBytecodeProvider()

Deprecated Deprecated to indicate that the method will be moved to org.hibernate.boot.spi.SessionFactoryOptions / org.hibernate.boot.SessionFactoryBuilder - probably in 6.0.
public static Properties

Returns:

Properties
getProperties
()

Return System properties, extended by any properties specified in hibernate.properties.

public static String
public static boolean

Returns:

false
jvmHasTimestampBug
()

Deprecated removed as unnecessary
This will be removed soon; currently just returns false as no known JVM exhibits this bug and is also able to run this version of Hibernate ORM.
public static boolean

Returns:

True if global option org.hibernate.cfg.AvailableSettings#ENFORCE_LEGACY_PROXY_CLASSNAMES was enabled
useLegacyProxyClassnames
()

Deprecated This option will be removed soon and should not be relied on.
public static boolean

Returns:

True if reflection optimization should be used; false otherwise.
useReflectionOptimizer
()

Deprecated Deprecated to indicate that the method will be moved to org.hibernate.boot.spi.SessionFactoryOptions / org.hibernate.boot.SessionFactoryBuilder - probably in 6.0.
Should we use reflection optimization?
public static boolean

Returns:

True if streams should be used for binary data handling; false otherwise.
useStreamsForBinary
()

Deprecated Deprecated to indicate that the method will be moved to org.hibernate.boot.spi.SessionFactoryOptions / org.hibernate.boot.SessionFactoryBuilder - probably in 6.0.
Should we use streams to bind binary types to JDBC IN parameters?
public static void
verifyProperties(Map<?, ?>
The specified properties.
configurationValues
)

Deprecated without replacement. Such verification is best done ad hoc, case by case.
No longer effective.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

BYTECODE_PROVIDER_INSTANCEback to summary
private static final BytecodeProvider BYTECODE_PROVIDER_INSTANCE
BYTECODE_PROVIDER_NAME_BYTEBUDDYback to summary
public static final String BYTECODE_PROVIDER_NAME_BYTEBUDDY
BYTECODE_PROVIDER_NAME_DEFAULTback to summary
public static final String BYTECODE_PROVIDER_NAME_DEFAULT
BYTECODE_PROVIDER_NAME_JAVASSISTback to summary
public static final String BYTECODE_PROVIDER_NAME_JAVASSIST
BYTECODE_PROVIDER_NAME_NONEback to summary
public static final String BYTECODE_PROVIDER_NAME_NONE
ENABLE_BINARY_STREAMSback to summary
private static final boolean ENABLE_BINARY_STREAMS
ENABLE_LEGACY_PROXY_CLASSNAMESback to summary
private static final boolean ENABLE_LEGACY_PROXY_CLASSNAMES
ENABLE_REFLECTION_OPTIMIZERback to summary
private static final boolean ENABLE_REFLECTION_OPTIMIZER
GLOBAL_PROPERTIESback to summary
private static final Properties GLOBAL_PROPERTIES
LOGback to summary
private static final CoreMessageLogger LOG

Constructor Detail

Environmentback to summary
private Environment()

Disallow instantiation

Method Detail

buildBytecodeProviderback to summary
public static BytecodeProvider buildBytecodeProvider(Properties properties)
buildBytecodeProviderback to summary
private static BytecodeProvider buildBytecodeProvider(String providerName)
getBytecodeProviderback to summary
public static BytecodeProvider getBytecodeProvider()

Deprecated

Deprecated to indicate that the method will be moved to org.hibernate.boot.spi.SessionFactoryOptions / org.hibernate.boot.SessionFactoryBuilder - probably in 6.0. See HHH-12194 and HHH-12193 for details

Annotations
@Deprecated
getPropertiesback to summary
public static Properties getProperties()

Return System properties, extended by any properties specified in hibernate.properties.

Returns:Properties

Properties

isolationLevelToStringback to summary
public static String isolationLevelToString(int isolation)
Annotations
@Deprecated
jvmHasTimestampBugback to summary
public static boolean jvmHasTimestampBug()

Deprecated

removed as unnecessary

This will be removed soon; currently just returns false as no known JVM exhibits this bug and is also able to run this version of Hibernate ORM.

Returns:boolean

false

Annotations
@Deprecated
useLegacyProxyClassnamesback to summary
public static boolean useLegacyProxyClassnames()

Deprecated

This option will be removed soon and should not be relied on.

Returns:boolean

True if global option org.hibernate.cfg.AvailableSettings#ENFORCE_LEGACY_PROXY_CLASSNAMES was enabled

Annotations
@Deprecated
useReflectionOptimizerback to summary
public static boolean useReflectionOptimizer()

Deprecated

Deprecated to indicate that the method will be moved to org.hibernate.boot.spi.SessionFactoryOptions / org.hibernate.boot.SessionFactoryBuilder - probably in 6.0. See HHH-12194 and HHH-12193 for details

Should we use reflection optimization?

Returns:boolean

True if reflection optimization should be used; false otherwise.

Annotations
@Deprecated
See Also
USE_REFLECTION_OPTIMIZER, getBytecodeProvider(), BytecodeProvider#getReflectionOptimizer
useStreamsForBinaryback to summary
public static boolean useStreamsForBinary()

Deprecated

Deprecated to indicate that the method will be moved to org.hibernate.boot.spi.SessionFactoryOptions / org.hibernate.boot.SessionFactoryBuilder - probably in 6.0. See HHH-12194 and HHH-12193 for details

Should we use streams to bind binary types to JDBC IN parameters?

Returns:boolean

True if streams should be used for binary data handling; false otherwise.

Annotations
@Deprecated
See Also
USE_STREAMS_FOR_BINARY
verifyPropertiesback to summary
public static void verifyProperties(Map<?, ?> configurationValues)

Deprecated

without replacement. Such verification is best done ad hoc, case by case.

No longer effective.

Parameters
configurationValues:Map<?, ?>

The specified properties.

Annotations
@Deprecated