* property | meaning |
*
* hibernate.dialect |
* classname of org.hibernate.dialect.Dialect subclass |
*
*
* hibernate.connection.provider_class |
* classname of ConnectionProvider
* subclass (if not specified hueristics are used) |
*
* hibernate.connection.username | database username |
* hibernate.connection.password | database 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.url | JNDI InitialContext URL |
*
*
* hibernate.jndi.class | JNDI 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 afterQuery 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.substitutions | query language token substitutions |
*
*
*
* @see org.hibernate.SessionFactory
* @author Gavin King
*/
public final class Environment implements AvailableSettings {
private static final CoreMessageLogger LOG = Logger.getMessageLogger( CoreMessageLogger.class, Environment.class.getName());
private static final BytecodeProvider BYTECODE_PROVIDER_INSTANCE;
private static final boolean ENABLE_BINARY_STREAMS;
private static final boolean ENABLE_REFLECTION_OPTIMIZER;
private static final boolean JVM_HAS_TIMESTAMP_BUG;
private static final Properties GLOBAL_PROPERTIES;
private static final Map OBSOLETE_PROPERTIES = new HashMap();
private static final Map RENAMED_PROPERTIES = new HashMap();
/**
* Issues warnings to the user when any obsolete or renamed property names are used.
*
* @param configurationValues The specified properties.
*/
public static void verifyProperties(Map configurationValues) {
final Map propertiesToAdd = new HashMap();
for ( Map.Entry entry : configurationValues.entrySet() ) {
final Object replacementKey = OBSOLETE_PROPERTIES.get( entry.getKey() );
if ( replacementKey != null ) {
LOG.unsupportedProperty( entry.getKey(), replacementKey );
}
final Object renamedKey = RENAMED_PROPERTIES.get( entry.getKey() );
if ( renamedKey != null ) {
LOG.renamedProperty( entry.getKey(), renamedKey );
propertiesToAdd.put( renamedKey, entry.getValue() );
}
}
configurationValues.putAll( propertiesToAdd );
}
static {
Version.logVersion();
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.propertiesLoaded( ConfigurationHelper.maskOut( GLOBAL_PROPERTIES, PASS ) );
}
catch (Exception e) {
LOG.unableToLoadProperties();
}
finally {
try{
stream.close();
}
catch (IOException ioe){
LOG.unableToCloseStreamError( ioe );
}
}
}
catch (HibernateException he) {
LOG.propertiesNotFound();
}
try {
Properties systemProperties = System.getProperties();
// Must be thread-safe in case an application changes System properties during Hibernate initialization.
// See HHH-8383.
synchronized (systemProperties) {
GLOBAL_PROPERTIES.putAll(systemProperties);
}
}
catch (SecurityException se) {
LOG.unableToCopySystemProperties();
}
verifyProperties(GLOBAL_PROPERTIES);
ENABLE_BINARY_STREAMS = ConfigurationHelper.getBoolean(USE_STREAMS_FOR_BINARY, GLOBAL_PROPERTIES);
if ( ENABLE_BINARY_STREAMS ) {
LOG.usingStreams();
}
ENABLE_REFLECTION_OPTIMIZER = ConfigurationHelper.getBoolean(USE_REFLECTION_OPTIMIZER, GLOBAL_PROPERTIES);
if ( ENABLE_REFLECTION_OPTIMIZER ) {
LOG.usingReflectionOptimizer();
}
BYTECODE_PROVIDER_INSTANCE = buildBytecodeProvider( GLOBAL_PROPERTIES );
long x = 123456789;
JVM_HAS_TIMESTAMP_BUG = new Timestamp(x).getTime() != x;
if ( JVM_HAS_TIMESTAMP_BUG ) {
LOG.usingTimestampWorkaround();
}
}
public static BytecodeProvider getBytecodeProvider() {
return BYTECODE_PROVIDER_INSTANCE;
}
/**
* Does this JVM's implementation of {@link java.sql.Timestamp} have a bug in which the following is true: