Fields Summary |
---|
public static final String | VERSION |
public static final String | CONNECTION_PROVIDERConnectionProvider implementor to use when obtaining connections |
public static final String | DRIVERJDBC driver class |
public static final String | ISOLATIONJDBC transaction isolation level |
public static final String | URLJDBC URL |
public static final String | USERJDBC user |
public static final String | PASSJDBC password |
public static final String | AUTOCOMMITJDBC autocommit mode |
public static final String | POOL_SIZEMaximum number of inactive connections for Hibernate's connection pool |
public static final String | DATASOURCEjava.sql.Datasource JNDI name |
public static final String | CONNECTION_PREFIXprefix for arbitrary JDBC connection properties |
public static final String | JNDI_CLASSJNDI initial context class, Context.INITIAL_CONTEXT_FACTORY |
public static final String | JNDI_URLJNDI provider URL, Context.PROVIDER_URL |
public static final String | JNDI_PREFIXprefix for arbitrary JNDI InitialContext properties |
public static final String | SESSION_FACTORY_NAMEJNDI name to bind to SessionFactory |
public static final String | DIALECTHibernate SQL Dialect class |
public static final String | DEFAULT_SCHEMAA default database schema (owner) name to use for unqualified tablenames |
public static final String | DEFAULT_CATALOGA default database catalog name to use for unqualified tablenames |
public static final String | SHOW_SQLEnable logging of generated SQL to the console |
public static final String | FORMAT_SQLEnable formatting of SQL logged to the console |
public static final String | USE_SQL_COMMENTSAdd comments to the generated SQL |
public static final String | MAX_FETCH_DEPTHMaximum depth of outer join fetching |
public static final String | DEFAULT_BATCH_FETCH_SIZEThe default batch size for batch fetching |
public static final String | USE_STREAMS_FOR_BINARYUse java.io streams to read / write binary data from / to JDBC |
public static final String | USE_SCROLLABLE_RESULTSETUse JDBC scrollable ResultSets. This property is only necessary when there is
no ConnectionProvider, ie. the user is supplying JDBC connections. |
public static final String | USE_GET_GENERATED_KEYSTells 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(). |
public static final String | STATEMENT_FETCH_SIZEGives 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. |
public static final String | STATEMENT_BATCH_SIZEMaximum JDBC batch size. A nonzero value enables batch updates. |
public static final String | BATCH_STRATEGYSelect a custom batcher. |
public static final String | BATCH_VERSIONED_DATAShould versioned data be included in batching? |
public static final String | OUTPUT_STYLESHEETAn XSLT resource used to generate "custom" XML |
public static final String | C3P0_MAX_SIZEMaximum size of C3P0 connection pool |
public static final String | C3P0_MIN_SIZEMinimum size of C3P0 connection pool |
public static final String | C3P0_TIMEOUTMaximum idle time for C3P0 connection pool |
public static final String | C3P0_MAX_STATEMENTSMaximum size of C3P0 statement cache |
public static final String | C3P0_ACQUIRE_INCREMENTNumber of connections acquired when pool is exhausted |
public static final String | C3P0_IDLE_TEST_PERIODIdle time before a C3P0 pooled connection is validated |
public static final String | PROXOOL_PREFIXProxool/Hibernate property prefix |
public static final String | PROXOOL_XMLProxool property to configure the Proxool Provider using an XML (/path/to/file.xml) |
public static final String | PROXOOL_PROPERTIESProxool property to configure the Proxool Provider using a properties file (/path/to/proxool.properties) |
public static final String | PROXOOL_EXISTING_POOLProxool property to configure the Proxool Provider from an already existing pool (true / false) |
public static final String | PROXOOL_POOL_ALIASProxool property with the Proxool pool alias to use
(Required for PROXOOL_EXISTING_POOL, PROXOOL_PROPERTIES, or
PROXOOL_XML) |
public static final String | AUTO_CLOSE_SESSIONEnable automatic session close at end of transaction |
public static final String | FLUSH_BEFORE_COMPLETIONEnable automatic flush during the JTA beforeCompletion() callback |
public static final String | RELEASE_CONNECTIONSSpecifies how Hibernate should release JDBC connections. |
public static final String | CURRENT_SESSION_CONTEXT_CLASSContext scoping impl for {@link org.hibernate.SessionFactory#getCurrentSession()} processing. |
public static final String | TRANSACTION_STRATEGYTransactionFactory implementor to use for creating Transactions |
public static final String | TRANSACTION_MANAGER_STRATEGYTransactionManagerLookup implementor to use for obtaining the TransactionManager |
public static final String | USER_TRANSACTIONJNDI name of JTA UserTransaction object |
public static final String | CACHE_PROVIDERThe CacheProvider implementation class |
public static final String | CACHE_PROVIDER_CONFIGThe CacheProvider implementation class |
public static final String | CACHE_NAMESPACEThe CacheProvider JNDI namespace, if pre-bound to JNDI. |
public static final String | USE_QUERY_CACHEEnable the query cache (disabled by default) |
public static final String | QUERY_CACHE_FACTORYThe QueryCacheFactory implementation class. |
public static final String | USE_SECOND_LEVEL_CACHEEnable the second-level cache (enabled by default) |
public static final String | USE_MINIMAL_PUTSOptimize the cache for mimimal puts instead of minimal gets |
public static final String | CACHE_REGION_PREFIXThe CacheProvider region name prefix |
public static final String | USE_STRUCTURED_CACHEEnable use of structured second-level cache entries |
public static final String | GENERATE_STATISTICSEnable statistics collection |
public static final String | USE_IDENTIFIER_ROLLBACK |
public static final String | USE_REFLECTION_OPTIMIZERUse bytecode libraries optimized property access |
public static final String | QUERY_TRANSLATORThe classname of the HQL query parser factory |
public static final String | QUERY_SUBSTITUTIONSA comma-seperated list of token substitutions to use when translating a Hibernate
query to SQL |
public static final String | QUERY_STARTUP_CHECKINGShould named queries be checked during startup (the default is enabled).
Mainly intended for test environments. |
public static final String | HBM2DDL_AUTOAuto export/update schema using hbm2ddl tool. Valid values are update,
create, create-drop and validate. |
public static final String | SQL_EXCEPTION_CONVERTERThe {@link org.hibernate.exception.SQLExceptionConverter} to use for converting SQLExceptions
to Hibernate's JDBCException hierarchy. The default is to use the configured
{@link org.hibernate.dialect.Dialect}'s preferred SQLExceptionConverter. |
public static final String | WRAP_RESULT_SETSEnable wrapping of JDBC result sets in order to speed up column name lookups for
broken JDBC drivers |
public static final String | ORDER_UPDATESEnable ordering of update statements by primary key value |
public static final String | ORDER_INSERTSEnable ordering of insert statements for the purpose of more effecient JDBC batching. |
public static final String | DEFAULT_ENTITY_MODEThe EntityMode in which set the Session opened from the SessionFactory. |
public static final String | JACC_CONTEXTIDThe jacc context id of the deployment |
public static final String | BYTECODE_PROVIDER |
public static final String | JPAQL_STRICT_COMPLIANCE |
private static final org.hibernate.bytecode.BytecodeProvider | BYTECODE_PROVIDER_INSTANCE |
private static final boolean | ENABLE_BINARY_STREAMS |
private static final boolean | ENABLE_REFLECTION_OPTIMIZER |
private static final boolean | JVM_SUPPORTS_LINKED_HASH_COLLECTIONS |
private static final boolean | JVM_HAS_TIMESTAMP_BUG |
private static final boolean | JVM_HAS_JDK14_TIMESTAMP |
private static final boolean | JVM_SUPPORTS_GET_GENERATED_KEYS |
private static final Properties | GLOBAL_PROPERTIES |
private static final HashMap | ISOLATION_LEVELS |
private static final Map | OBSOLETE_PROPERTIES |
private static final Map | RENAMED_PROPERTIES |
private static final Log | log |
Methods Summary |
---|
public static org.hibernate.bytecode.BytecodeProvider | buildBytecodeProvider(java.util.Properties properties)
String provider = PropertiesHelper.getString( Environment.BYTECODE_PROVIDER, properties, "cglib" );
log.info( "Bytecode provider name : " + provider );
return buildBytecodeProvider( provider );
|
private static org.hibernate.bytecode.BytecodeProvider | buildBytecodeProvider(java.lang.String providerName)
if ( "javassist".equals( providerName ) ) {
return new org.hibernate.bytecode.javassist.BytecodeProviderImpl();
}
else if ( "cglib".equals( providerName ) ) {
return new org.hibernate.bytecode.cglib.BytecodeProviderImpl();
}
else {
log.warn( "unrecognized bytecode provider [" + providerName + "], using cglib by default" );
return new org.hibernate.bytecode.cglib.BytecodeProviderImpl();
}
|
public static org.hibernate.bytecode.BytecodeProvider | getBytecodeProvider()
log.info("Hibernate " + VERSION);
RENAMED_PROPERTIES.put( "hibernate.cglib.use_reflection_optimizer", USE_REFLECTION_OPTIMIZER );
ISOLATION_LEVELS.put( new Integer(Connection.TRANSACTION_NONE), "NONE" );
ISOLATION_LEVELS.put( new Integer(Connection.TRANSACTION_READ_UNCOMMITTED), "READ_UNCOMMITTED" );
ISOLATION_LEVELS.put( new Integer(Connection.TRANSACTION_READ_COMMITTED), "READ_COMMITTED" );
ISOLATION_LEVELS.put( new Integer(Connection.TRANSACTION_REPEATABLE_READ), "REPEATABLE_READ" );
ISOLATION_LEVELS.put( new Integer(Connection.TRANSACTION_SERIALIZABLE), "SERIALIZABLE" );
GLOBAL_PROPERTIES = new Properties();
//Set USE_REFLECTION_OPTIMIZER to false to fix HHH-227
GLOBAL_PROPERTIES.setProperty( USE_REFLECTION_OPTIMIZER, Boolean.FALSE.toString() );
try {
InputStream stream = ConfigHelper.getResourceAsStream("/hibernate.properties");
try {
GLOBAL_PROPERTIES.load(stream);
log.info( "loaded properties from resource hibernate.properties: " + PropertiesHelper.maskOut(GLOBAL_PROPERTIES, PASS) );
}
catch (Exception e) {
log.error("problem loading properties from hibernate.properties");
}
finally {
try{
stream.close();
}
catch (IOException ioe){
log.error("could not close stream on hibernate.properties", ioe);
}
}
}
catch (HibernateException he) {
log.info("hibernate.properties not found");
}
try {
GLOBAL_PROPERTIES.putAll( System.getProperties() );
}
catch (SecurityException se) {
log.warn("could not copy system properties, system properties will be ignored");
}
verifyProperties(GLOBAL_PROPERTIES);
ENABLE_BINARY_STREAMS = PropertiesHelper.getBoolean(USE_STREAMS_FOR_BINARY, GLOBAL_PROPERTIES);
ENABLE_REFLECTION_OPTIMIZER = PropertiesHelper.getBoolean(USE_REFLECTION_OPTIMIZER, GLOBAL_PROPERTIES);
if (ENABLE_BINARY_STREAMS) {
log.info("using java.io streams to persist binary types");
}
if (ENABLE_REFLECTION_OPTIMIZER) {
log.info("using bytecode reflection optimizer");
}
BYTECODE_PROVIDER_INSTANCE = buildBytecodeProvider( GLOBAL_PROPERTIES );
boolean getGeneratedKeysSupport;
try {
Statement.class.getMethod("getGeneratedKeys", null);
getGeneratedKeysSupport = true;
}
catch (NoSuchMethodException nsme) {
getGeneratedKeysSupport = false;
}
JVM_SUPPORTS_GET_GENERATED_KEYS = getGeneratedKeysSupport;
if (!JVM_SUPPORTS_GET_GENERATED_KEYS) log.info("JVM does not support Statement.getGeneratedKeys()");
boolean linkedHashSupport;
try {
Class.forName("java.util.LinkedHashSet");
linkedHashSupport = true;
}
catch (ClassNotFoundException cnfe) {
linkedHashSupport = false;
}
JVM_SUPPORTS_LINKED_HASH_COLLECTIONS = linkedHashSupport;
if (!JVM_SUPPORTS_LINKED_HASH_COLLECTIONS) log.info("JVM does not support LinkedHasMap, LinkedHashSet - ordered maps and sets disabled");
JVM_HAS_TIMESTAMP_BUG = new Timestamp(123456789).getTime() != 123456789;
if (JVM_HAS_TIMESTAMP_BUG) log.info("using workaround for JVM bug in java.sql.Timestamp");
Timestamp t = new Timestamp(0);
t.setNanos(5 * 1000000);
JVM_HAS_JDK14_TIMESTAMP = t.getTime() == 5;
if (JVM_HAS_JDK14_TIMESTAMP) {
log.info("using JDK 1.4 java.sql.Timestamp handling");
}
else {
log.info("using pre JDK 1.4 java.sql.Timestamp handling");
}
return BYTECODE_PROVIDER_INSTANCE;
|
public static java.util.Properties | getProperties()Return System properties, extended by any properties specified
in hibernate.properties.
Properties copy = new Properties();
copy.putAll(GLOBAL_PROPERTIES);
return copy;
|
public static java.lang.String | isolationLevelToString(int isolation)Get the name of a JDBC transaction isolation level
return (String) ISOLATION_LEVELS.get( new Integer(isolation) );
|
public static boolean | jvmHasJDK14Timestamp()Does this JVM handle Timestamp in the JDK 1.4 compliant way?
return JVM_HAS_JDK14_TIMESTAMP;
|
public static boolean | jvmHasTimestampBug()Does this JVM have the IBM JDK 1.3.1. The bug is new Timestamp(x).getTime()!=x.
return JVM_HAS_TIMESTAMP_BUG;
|
public static boolean | jvmSupportsGetGeneratedKeys()
return JVM_SUPPORTS_GET_GENERATED_KEYS;
|
public static boolean | jvmSupportsLinkedHashCollections()Does this JVM support LinkedHashSet, LinkedHashMap.
return JVM_SUPPORTS_LINKED_HASH_COLLECTIONS;
|
public static boolean | useReflectionOptimizer()Should we use CGLIB reflection optimizer.
Property hibernate.jdbc.use_refection_optimizer.
return ENABLE_REFLECTION_OPTIMIZER;
|
public static boolean | useStreamsForBinary()Should we use streams to bind binary types to JDBC IN parameters.
Property hibernate.jdbc.use_streams_for_binary.
return ENABLE_BINARY_STREAMS;
|
public static void | verifyProperties(java.util.Properties props)Issues warnings to the user when any obsolete property names are used.
Iterator iter = props.keySet().iterator();
Map propertiesToAdd = new HashMap();
while ( iter.hasNext() ) {
final Object propertyName = iter.next();
Object newPropertyName = OBSOLETE_PROPERTIES.get( propertyName );
if ( newPropertyName != null ) {
log.warn( "Usage of obsolete property: " + propertyName + " no longer supported, use: " + newPropertyName );
}
newPropertyName = RENAMED_PROPERTIES.get( propertyName );
if ( newPropertyName != null ) {
log.warn( "Property [" + propertyName + "] has been renamed to [" + newPropertyName + "]; update your properties appropriately" );
if ( ! props.containsKey( newPropertyName ) ) {
propertiesToAdd.put( newPropertyName, props.get( propertyName ) );
}
}
}
props.putAll(propertiesToAdd);
|