org.hibernate.cfg
Class Environment

java.lang.Object
  extended by org.hibernate.cfg.Environment
All Implemented Interfaces:
AvailableSettings

public final class Environment
extends Object
implements AvailableSettings

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.buildSessionFactory()

propertymeaning
hibernate.dialect classname of org.hibernate.dialect.Dialect subclass
hibernate.connection.provider_class classname of org.hibernate.service.jdbc.connections.spi.ConnectionProvider subclass (if not specified hueristics 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 databasource 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 this 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.manager_lookup_class classname of org.hibernate.transaction.TransactionManagerLookup implementor
hibernate.transaction.factory_class the factory to use for instantiating Transactions. (Defaults to JdbcTransactionFactory.)
hibernate.query.substitutionsquery language token substitutions

See Also:
SessionFactory

Field Summary
 
Fields inherited from interface org.hibernate.cfg.AvailableSettings
APP_CLASSLOADER, AUTO_CLOSE_SESSION, AUTOCOMMIT, BATCH_STRATEGY, BATCH_VERSIONED_DATA, BYTECODE_PROVIDER, C3P0_ACQUIRE_INCREMENT, C3P0_CONFIG_PREFIX, C3P0_IDLE_TEST_PERIOD, C3P0_MAX_SIZE, C3P0_MAX_STATEMENTS, C3P0_MIN_SIZE, C3P0_TIMEOUT, CACHE_NAMESPACE, CACHE_PROVIDER_CONFIG, CACHE_REGION_FACTORY, CACHE_REGION_PREFIX, CHECK_NULLABILITY, CONNECTION_PREFIX, CONNECTION_PROVIDER, CURRENT_SESSION_CONTEXT_CLASS, CUSTOM_ENTITY_DIRTINESS_STRATEGY, DATASOURCE, DEFAULT_BATCH_FETCH_SIZE, DEFAULT_CACHE_CONCURRENCY_STRATEGY, DEFAULT_CATALOG, DEFAULT_ENTITY_MODE, DEFAULT_SCHEMA, DIALECT, DIALECT_RESOLVERS, DRIVER, ENVIRONMENT_CLASSLOADER, FLUSH_BEFORE_COMPLETION, FORCE_DISCRIMINATOR_IN_SELECTS_BY_DEFAULT, FORMAT_SQL, GENERATE_STATISTICS, GLOBALLY_QUOTED_IDENTIFIERS, HBM2DDL_AUTO, HBM2DDL_IMPORT_FILES, HBM2DDL_IMPORT_FILES_SQL_EXTRACTOR, HIBERNATE_CLASSLOADER, ISOLATION, JACC_CONTEXTID, JMX_AGENT_ID, JMX_DEFAULT_OBJ_NAME_DOMAIN, JMX_DOMAIN_NAME, JMX_ENABLED, JMX_PLATFORM_SERVER, JMX_SF_NAME, JNDI_CLASS, JNDI_PREFIX, JNDI_URL, JPAQL_STRICT_COMPLIANCE, JTA_CACHE_TM, JTA_CACHE_UT, JTA_PLATFORM, MAX_FETCH_DEPTH, MULTI_TENANT, MULTI_TENANT_CONNECTION_PROVIDER, MULTI_TENANT_IDENTIFIER_RESOLVER, NON_CONTEXTUAL_LOB_CREATION, ORDER_INSERTS, ORDER_UPDATES, OUTPUT_STYLESHEET, PASS, POOL_SIZE, PREFER_POOLED_VALUES_LO, PROXOOL_CONFIG_PREFIX, PROXOOL_EXISTING_POOL, PROXOOL_POOL_ALIAS, PROXOOL_PREFIX, PROXOOL_PROPERTIES, PROXOOL_XML, QUERY_CACHE_FACTORY, QUERY_PLAN_CACHE_MAX_SIZE, QUERY_PLAN_CACHE_MAX_SOFT_REFERENCES, QUERY_PLAN_CACHE_MAX_STRONG_REFERENCES, QUERY_PLAN_CACHE_PARAMETER_METADATA_MAX_SIZE, QUERY_STARTUP_CHECKING, QUERY_SUBSTITUTIONS, QUERY_TRANSLATOR, RELEASE_CONNECTIONS, RESOURCES_CLASSLOADER, SESSION_FACTORY_NAME, SESSION_FACTORY_NAME_IS_JNDI, SHOW_SQL, SQL_EXCEPTION_CONVERTER, STATEMENT_BATCH_SIZE, STATEMENT_FETCH_SIZE, TRANSACTION_MANAGER_STRATEGY, TRANSACTION_STRATEGY, URL, USE_GET_GENERATED_KEYS, USE_IDENTIFIER_ROLLBACK, USE_MINIMAL_PUTS, USE_NEW_ID_GENERATOR_MAPPINGS, USE_QUERY_CACHE, USE_REFLECTION_OPTIMIZER, USE_SCROLLABLE_RESULTSET, USE_SECOND_LEVEL_CACHE, USE_SQL_COMMENTS, USE_STREAMS_FOR_BINARY, USE_STRUCTURED_CACHE, USER, USER_TRANSACTION, WRAP_RESULT_SETS
 
Method Summary
static BytecodeProvider buildBytecodeProvider(Properties properties)
           
static BytecodeProvider getBytecodeProvider()
           
static Properties getProperties()
          Return System properties, extended by any properties specified in hibernate.properties.
static String isolationLevelToString(int isolation)
          Get the name of a JDBC transaction isolation level
static boolean jvmHasTimestampBug()
          Does this JVM's implementation of Timestamp have a bug in which the following is true: new java.sql.Timestamp( x ).getTime() != x

NOTE : IBM JDK 1.3.1 the only known JVM to exhibit this behavior.

static boolean useReflectionOptimizer()
          Should we use reflection optimization?
static boolean useStreamsForBinary()
          Should we use streams to bind binary types to JDBC IN parameters?
static void verifyProperties(Map<?,?> configurationValues)
          Issues warnings to the user when any obsolete or renamed property names are used.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

verifyProperties

public static void verifyProperties(Map<?,?> configurationValues)
Issues warnings to the user when any obsolete or renamed property names are used.

Parameters:
configurationValues - The specified properties.

getBytecodeProvider

public static BytecodeProvider getBytecodeProvider()

jvmHasTimestampBug

public static boolean jvmHasTimestampBug()
Does this JVM's implementation of Timestamp have a bug in which the following is true: new java.sql.Timestamp( x ).getTime() != x

NOTE : IBM JDK 1.3.1 the only known JVM to exhibit this behavior.

Returns:
True if the JVM's Timestamp implementa

useStreamsForBinary

public static boolean useStreamsForBinary()
Should we use streams to bind binary types to JDBC IN parameters?

Returns:
True if streams should be used for binary data handling; false otherwise.
See Also:
AvailableSettings.USE_STREAMS_FOR_BINARY

useReflectionOptimizer

public static boolean useReflectionOptimizer()
Should we use reflection optimization?

Returns:
True if reflection optimization should be used; false otherwise.
See Also:
AvailableSettings.USE_REFLECTION_OPTIMIZER, getBytecodeProvider(), BytecodeProvider.getReflectionOptimizer(java.lang.Class, java.lang.String[], java.lang.String[], java.lang.Class[])

getProperties

public static Properties getProperties()
Return System properties, extended by any properties specified in hibernate.properties.

Returns:
Properties

isolationLevelToString

public static String isolationLevelToString(int isolation)
Get the name of a JDBC transaction isolation level

Parameters:
isolation - as defined by java.sql.Connection
Returns:
a human-readable name
See Also:
Connection

buildBytecodeProvider

public static BytecodeProvider buildBytecodeProvider(Properties properties)


Copyright © 2001-2012 Red Hat, Inc. All Rights Reserved.