站内搜索: 请输入搜索关键词
当前页面: 在线文档首页 > Hibernate 2.1.8 正式版 API 英文文档

Environment (Hibernate API Documentation) - Hibernate 2.1.8 正式版 API 英文文档


net.sf.hibernate.cfg
Class Environment

java.lang.Object
  extended bynet.sf.hibernate.cfg.Environment

public final class Environment
extends Object

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 net.sf.hibernate.dialect.Dialect subclass
hibernate.cache.provider_class classname of net.sf.hibernate.cache.CacheProvider subclass (if not specified JCS is used)
hibernate.connection.provider_class classname of net.sf.hibernate.connection.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.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 net.sf.hibernate.transaction.TransactionManagerLookup 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:
SessionFactory

Field Summary
static String BATCH_VERSIONED_DATA
          Should versioned data be included in batching?
static String C3P0_ACQUIRE_INCREMENT
          Number of connections acquired when pool is exhausted
static String C3P0_IDLE_TEST_PERIOD
          Idle time before a C3P0 pooled connection is validated
static String C3P0_MAX_SIZE
          Maximum size of C3P0 connection pool
static String C3P0_MAX_STATEMENTS
          Maximum size of C3P0 statement cache
static String C3P0_MIN_SIZE
          Minimum size of C3P0 connection pool
static String C3P0_TIMEOUT
          Maximum idle time for C3P0 connection pool
static String C3P0_VALIDATE_CONNECTION
          Deprecated. use C3P0_IDLE_TEST_PERIOD
static String CACHE_PROVIDER
          The CacheProvider implementation class
static String CACHE_REGION_PREFIX
          The CacheProvider region name prefix
static String CONNECTION_PREFIX
          prefix for arbitrary JDBC connection properties
static String CONNECTION_PROVIDER
          ConnectionProvider implementor to use when obtaining connections
static String DATASOURCE
          java.sql.Datasource JNDI name
static String DBCP_MAXACTIVE
          Maximum number of checked out connections for DBCP connection pool
static String DBCP_MAXIDLE
          Maximum number of idle connections for DBCP connection pool
static String DBCP_MAXWAIT
          Maximum idle time for connections in DBCP connection pool (ms)
static String DBCP_PS_MAXACTIVE
          Maximum number of checked out statements for DBCP
static String DBCP_PS_MAXIDLE
          Maximum number of idle statements for DBCP
static String DBCP_PS_MAXWAIT
          Maximum idle time for statements in DBCP (ms)
static String DBCP_PS_WHENEXHAUSTED
          Action to take in case of an exhausted DBCP statement pool ( 0 = fail, 1 = block, 2= grow)
static String DBCP_VALIDATION_ONBORROW
          Validate connection when borrowing connection from pool (optional, true or false)
static String DBCP_VALIDATION_ONRETURN
          Validate connection when returning connection to pool (optional, true or false)
static String DBCP_VALIDATION_QUERY
          Query to execute for connection validation (optional, requires either DBCP_VALIDATION_ONBORROW or DBCP_VALIDATION_ONRETURN)
static String DBCP_WHENEXHAUSTED
          Action to take in case of an exhausted DBCP connection pool ( 0 = fail, 1 = block, 2= grow)
static String DEFAULT_SCHEMA
          A default database schema (owner) name to use for unqualified tablenames
static String DIALECT
          Hibernate SQL Dialect class
static String DRIVER
          JDBC driver class
static String HBM2DDL_AUTO
          Auto export/update schema using hbm2ddl tool.
static String ISOLATION
          JDBC transaction isolation level
static String JNDI_CLASS
          JNDI initial context class, Context.INITIAL_CONTEXT_FACTORY
static String JNDI_PREFIX
          prefix for arbitrary JNDI InitialContext properties
static String JNDI_URL
          JNDI provider URL, Context.PROVIDER_URL
static String MAX_FETCH_DEPTH
          Maximum depth of outerjoin fetching
static String OUTPUT_STYLESHEET
          An XSLT resource used to generate "custom" XML
static String PASS
          JDBC password
static String POOL_SIZE
          Maximum number of inactive connections for Hibernate's connection pool
static String PROXOOL_EXISTING_POOL
          Proxool property to configure the Proxool Provider from an already existing pool (true / false)
static String PROXOOL_POOL_ALIAS
          Proxool property with the Proxool pool alias to use (Required for PROXOOL_EXISTING_POOL, PROXOOL_PROPERTIES, or PROXOOL_XML)
static String PROXOOL_PREFIX
          Proxool/Hibernate property prefix
static String PROXOOL_PROPERTIES
          Proxool property to configure the Proxool Provider using a properties file (/path/to/proxool.properties)
static String PROXOOL_XML
          Proxool property to configure the Proxool Provider using an XML (/path/to/file.xml)
static String QUERY_CACHE_FACTORY
          The QueryCacheFactory implementation class.
static String QUERY_IMPORTS
          Deprecated.  
static String QUERY_SUBSTITUTIONS
          A comma-seperated list of token substitutions to use when translating a Hibernate query to SQL
static String SESSION_FACTORY_NAME
          JNDI name to bind to SessionFactory
static String SHOW_SQL
          Enable logging of generated SQL to the console
static String SQL_EXCEPTION_CONVERTER
          The SQLExceptionConverter to use for converting SQLExceptions to Hibernate's JDBCException hierarchy.
static String STATEMENT_BATCH_SIZE
          Maximum JDBC batch size.
static String STATEMENT_CACHE_SIZE
          Deprecated. Hibernate no longer has a built-in prepared statement cache
static String STATEMENT_FETCH_SIZE
          Gives the JDBC driver a hint as to the number of rows that should be fetched from the database when more rows are needed.
static String TRANSACTION_MANAGER_STRATEGY
          TransactionManagerLookup implementor to use for obtaining the TransactionManager
static String TRANSACTION_STRATEGY
          TransactionFactory implementor to use for creating Transactions
static String URL
          JDBC URL
static String USE_GET_GENERATED_KEYS
          Tells the JDBC driver to attempt to retrieve row Id with the JDBC 3.0 PreparedStatement.getGeneratedKeys() method.
static String USE_JDBC_BATCH
          Deprecated.  
static String USE_MINIMAL_PUTS
          Optimize the cache for mimimal puts instead of minimal gets
static String USE_OUTER_JOIN
          Deprecated. use hibernate.max_fetch_depth=0
static String USE_QUERY_CACHE
          Should query caching be truned on?
static String USE_REFLECTION_OPTIMIZER
          Use CGLIB MetaClass to optimize property access
static String USE_SCROLLABLE_RESULTSET
          Use JDBC scrollable ResultSets.
static String USE_STREAMS_FOR_BINARY
          Use java.io streams to read / write binary data from / to JDBC
static String USER
          JDBC user
static String USER_TRANSACTION
          JNDI name of JTA UserTransaction object
static String VERSION
           
static String WRAP_RESULT_SETS
          Should Hibernate wrap result sets in order to speed up column name lookups.
 
Method Summary
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 jvmHasJDK14Timestamp()
          Does this JVM handle Timestamp in the JDK 1.4 compliant way?
static boolean jvmHasTimestampBug()
          Does this JVM have the IBM JDK 1.3.1.
static boolean jvmSupportsGetGeneratedKeys()
           
static boolean jvmSupportsLinkedHashCollections()
          Does this JVM support LinkedHashSet, LinkedHashMap.
static boolean jvmSupportsProxies()
          Does this JVM support dynamic proxies.
static boolean useReflectionOptimizer()
          Should we use CGLIB reflection optimizer.
static boolean useStreamsForBinary()
          Should we use streams to bind binary types to JDBC IN parameters.
static void verifyProperties(Properties props)
          Issues warnings to the user when any obsolete property names are used.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

VERSION

public static final String VERSION
See Also:
Constant Field Values

CONNECTION_PROVIDER

public static final String CONNECTION_PROVIDER
ConnectionProvider implementor to use when obtaining connections

See Also:
Constant Field Values

DRIVER

public static final String DRIVER
JDBC driver class

See Also:
Constant Field Values

ISOLATION

public static final String ISOLATION
JDBC transaction isolation level

See Also:
Constant Field Values

URL

public static final String URL
JDBC URL

See Also:
Constant Field Values

USER

public static final String USER
JDBC user

See Also:
Constant Field Values

PASS

public static final String PASS
JDBC password

See Also:
Constant Field Values

POOL_SIZE

public static final String POOL_SIZE
Maximum number of inactive connections for Hibernate's connection pool

See Also:
Constant Field Values

DATASOURCE

public static final String DATASOURCE
java.sql.Datasource JNDI name

See Also:
Constant Field Values

CONNECTION_PREFIX

public static final String CONNECTION_PREFIX
prefix for arbitrary JDBC connection properties

See Also:
Constant Field Values

STATEMENT_CACHE_SIZE

public static final String STATEMENT_CACHE_SIZE
Deprecated. Hibernate no longer has a built-in prepared statement cache

Maximum size for Hibernate's statement cache

See Also:
Constant Field Values

JNDI_CLASS

public static final String JNDI_CLASS
JNDI initial context class, Context.INITIAL_CONTEXT_FACTORY

See Also:
Constant Field Values

JNDI_URL

public static final String JNDI_URL
JNDI provider URL, Context.PROVIDER_URL

See Also:
Constant Field Values

JNDI_PREFIX

public static final String JNDI_PREFIX
prefix for arbitrary JNDI InitialContext properties

See Also:
Constant Field Values

SESSION_FACTORY_NAME

public static final String SESSION_FACTORY_NAME
JNDI name to bind to SessionFactory

See Also:
Constant Field Values

DIALECT

public static final String DIALECT
Hibernate SQL Dialect class

See Also:
Constant Field Values

DEFAULT_SCHEMA

public static final String DEFAULT_SCHEMA
A default database schema (owner) name to use for unqualified tablenames

See Also:
Constant Field Values

SHOW_SQL

public static final String SHOW_SQL
Enable logging of generated SQL to the console

See Also:
Constant Field Values

USE_OUTER_JOIN

public static final String USE_OUTER_JOIN
Deprecated. use hibernate.max_fetch_depth=0

Enable deep fetching using outerjoins

See Also:
Constant Field Values

MAX_FETCH_DEPTH

public static final String MAX_FETCH_DEPTH
Maximum depth of outerjoin fetching

See Also:
Constant Field Values

USE_STREAMS_FOR_BINARY

public static final String USE_STREAMS_FOR_BINARY
Use java.io streams to read / write binary data from / to JDBC

See Also:
Constant Field Values

USE_SCROLLABLE_RESULTSET

public static final String USE_SCROLLABLE_RESULTSET
Use JDBC scrollable ResultSets. This property is only necessary when there is no ConnectionProvider, ie. the user is supplying JDBC connections.

See Also:
Constant Field Values

USE_GET_GENERATED_KEYS

public static final String USE_GET_GENERATED_KEYS
Tells the JDBC driver to attempt to retrieve row Id with the JDBC 3.0 PreparedStatement.getGeneratedKeys() method. In general, performance will be better if this property is set to true and the underlying JDBC driver supports getGeneratedKeys().

See Also:
Constant Field Values

STATEMENT_FETCH_SIZE

public static final String STATEMENT_FETCH_SIZE
Gives the JDBC driver a hint as to the number of rows that should be fetched from the database when more rows are needed. If 0, JDBC driver default settings will be used.

See Also:
Constant Field Values

STATEMENT_BATCH_SIZE

public static final String STATEMENT_BATCH_SIZE
Maximum JDBC batch size. A nonzero value enables batch updates.

See Also:
Constant Field Values

BATCH_VERSIONED_DATA

public static final String BATCH_VERSIONED_DATA
Should versioned data be included in batching?

See Also:
Constant Field Values

OUTPUT_STYLESHEET

public static final String OUTPUT_STYLESHEET
An XSLT resource used to generate "custom" XML

See Also:
Constant Field Values

C3P0_MAX_SIZE

public static final String C3P0_MAX_SIZE
Maximum size of C3P0 connection pool

See Also:
Constant Field Values

C3P0_MIN_SIZE

public static final String C3P0_MIN_SIZE
Minimum size of C3P0 connection pool

See Also:
Constant Field Values

C3P0_TIMEOUT

public static final String C3P0_TIMEOUT
Maximum idle time for C3P0 connection pool

See Also:
Constant Field Values

C3P0_MAX_STATEMENTS

public static final String C3P0_MAX_STATEMENTS
Maximum size of C3P0 statement cache

See Also:
Constant Field Values

C3P0_ACQUIRE_INCREMENT

public static final String C3P0_ACQUIRE_INCREMENT
Number of connections acquired when pool is exhausted

See Also:
Constant Field Values

C3P0_IDLE_TEST_PERIOD

public static final String C3P0_IDLE_TEST_PERIOD
Idle time before a C3P0 pooled connection is validated

See Also:
Constant Field Values

C3P0_VALIDATE_CONNECTION

public static final String C3P0_VALIDATE_CONNECTION
Deprecated. use C3P0_IDLE_TEST_PERIOD

Should we validate the connection on checkout.

See Also:
Constant Field Values

DBCP_MAXACTIVE

public static final String DBCP_MAXACTIVE
Maximum number of checked out connections for DBCP connection pool

See Also:
Constant Field Values

DBCP_MAXIDLE

public static final String DBCP_MAXIDLE
Maximum number of idle connections for DBCP connection pool

See Also:
Constant Field Values

DBCP_MAXWAIT

public static final String DBCP_MAXWAIT
Maximum idle time for connections in DBCP connection pool (ms)

See Also:
Constant Field Values

DBCP_WHENEXHAUSTED

public static final String DBCP_WHENEXHAUSTED
Action to take in case of an exhausted DBCP connection pool ( 0 = fail, 1 = block, 2= grow)

See Also:
Constant Field Values

DBCP_VALIDATION_ONBORROW

public static final String DBCP_VALIDATION_ONBORROW
Validate connection when borrowing connection from pool (optional, true or false)

See Also:
Constant Field Values

DBCP_VALIDATION_ONRETURN

public static final String DBCP_VALIDATION_ONRETURN
Validate connection when returning connection to pool (optional, true or false)

See Also:
Constant Field Values

DBCP_VALIDATION_QUERY

public static final String DBCP_VALIDATION_QUERY
Query to execute for connection validation (optional, requires either DBCP_VALIDATION_ONBORROW or DBCP_VALIDATION_ONRETURN)

See Also:
Constant Field Values

DBCP_PS_MAXACTIVE

public static final String DBCP_PS_MAXACTIVE
Maximum number of checked out statements for DBCP

See Also:
Constant Field Values

DBCP_PS_MAXIDLE

public static final String DBCP_PS_MAXIDLE
Maximum number of idle statements for DBCP

See Also:
Constant Field Values

DBCP_PS_MAXWAIT

public static final String DBCP_PS_MAXWAIT
Maximum idle time for statements in DBCP (ms)

See Also:
Constant Field Values

DBCP_PS_WHENEXHAUSTED

public static final String DBCP_PS_WHENEXHAUSTED
Action to take in case of an exhausted DBCP statement pool ( 0 = fail, 1 = block, 2= grow)

See Also:
Constant Field Values

PROXOOL_PREFIX

public static final String PROXOOL_PREFIX
Proxool/Hibernate property prefix

See Also:
Constant Field Values

PROXOOL_XML

public static final String PROXOOL_XML
Proxool property to configure the Proxool Provider using an XML (/path/to/file.xml)

See Also:
Constant Field Values

PROXOOL_PROPERTIES

public static final String PROXOOL_PROPERTIES
Proxool property to configure the Proxool Provider using a properties file (/path/to/proxool.properties)

See Also:
Constant Field Values

PROXOOL_EXISTING_POOL

public static final String PROXOOL_EXISTING_POOL
Proxool property to configure the Proxool Provider from an already existing pool (true / false)

See Also:
Constant Field Values

PROXOOL_POOL_ALIAS

public static final String PROXOOL_POOL_ALIAS
Proxool property with the Proxool pool alias to use (Required for PROXOOL_EXISTING_POOL, PROXOOL_PROPERTIES, or PROXOOL_XML)

See Also:
Constant Field Values

TRANSACTION_STRATEGY

public static final String TRANSACTION_STRATEGY
TransactionFactory implementor to use for creating Transactions

See Also:
Constant Field Values

TRANSACTION_MANAGER_STRATEGY

public static final String TRANSACTION_MANAGER_STRATEGY
TransactionManagerLookup implementor to use for obtaining the TransactionManager

See Also:
Constant Field Values

USER_TRANSACTION

public static final String USER_TRANSACTION
JNDI name of JTA UserTransaction object

See Also:
Constant Field Values

CACHE_PROVIDER

public static final String CACHE_PROVIDER
The CacheProvider implementation class

See Also:
Constant Field Values

USE_QUERY_CACHE

public static final String USE_QUERY_CACHE
Should query caching be truned on?

See Also:
Constant Field Values

QUERY_CACHE_FACTORY

public static final String QUERY_CACHE_FACTORY
The QueryCacheFactory implementation class.

See Also:
Constant Field Values

CACHE_REGION_PREFIX

public static final String CACHE_REGION_PREFIX
The CacheProvider region name prefix

See Also:
Constant Field Values

USE_MINIMAL_PUTS

public static final String USE_MINIMAL_PUTS
Optimize the cache for mimimal puts instead of minimal gets

See Also:
Constant Field Values

USE_REFLECTION_OPTIMIZER

public static final String USE_REFLECTION_OPTIMIZER
Use CGLIB MetaClass to optimize property access

See Also:
Constant Field Values

QUERY_SUBSTITUTIONS

public static final String QUERY_SUBSTITUTIONS
A comma-seperated list of token substitutions to use when translating a Hibernate query to SQL

See Also:
Constant Field Values

QUERY_IMPORTS

public static final String QUERY_IMPORTS
Deprecated.  

A comma-seperated list of packages that need not be specified in a query

See Also:
Constant Field Values

HBM2DDL_AUTO

public static final String HBM2DDL_AUTO
Auto export/update schema using hbm2ddl tool. Valid values are update, create and create-drop.

See Also:
Constant Field Values

SQL_EXCEPTION_CONVERTER

public static final String SQL_EXCEPTION_CONVERTER
The SQLExceptionConverter to use for converting SQLExceptions to Hibernate's JDBCException hierarchy. The default is to use the configured Dialect's preferred SQLExceptionConverter.

See Also:
Constant Field Values

WRAP_RESULT_SETS

public static final String WRAP_RESULT_SETS
Should Hibernate wrap result sets in order to speed up column name lookups.

See Also:
Constant Field Values

USE_JDBC_BATCH

public static final String USE_JDBC_BATCH
Deprecated.  

Use JDBC2 batch updates

See Also:
Constant Field Values
Method Detail

verifyProperties

public static void verifyProperties(Properties props)
Issues warnings to the user when any obsolete property names are used.


jvmSupportsProxies

public static boolean jvmSupportsProxies()
Does this JVM support dynamic proxies. (Now return true because CGLIB proxies work on all supported JDK)


jvmHasTimestampBug

public static boolean jvmHasTimestampBug()
Does this JVM have the IBM JDK 1.3.1. The bug is new Timestamp(x).getTime()!=x.


jvmHasJDK14Timestamp

public static boolean jvmHasJDK14Timestamp()
Does this JVM handle Timestamp in the JDK 1.4 compliant way?


jvmSupportsLinkedHashCollections

public static boolean jvmSupportsLinkedHashCollections()
Does this JVM support LinkedHashSet, LinkedHashMap.

See Also:
LinkedHashSet, LinkedHashMap

jvmSupportsGetGeneratedKeys

public static boolean jvmSupportsGetGeneratedKeys()

useStreamsForBinary

public static boolean useStreamsForBinary()
Should we use streams to bind binary types to JDBC IN parameters. Property hibernate.jdbc.use_streams_for_binary.

See Also:
USE_STREAMS_FOR_BINARY

useReflectionOptimizer

public static boolean useReflectionOptimizer()
Should we use CGLIB reflection optimizer. Property hibernate.jdbc.use_refection_optimizer.

See Also:
USE_REFLECTION_OPTIMIZER

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