alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  
* <tr> * <td>hibernate.dialect * <td>classname of org.hibernate.dialect.Dialect subclass * </tr> * <tr> * <td>hibernate.connection.provider_class * <td>classname of org.hibernate.service.jdbc.connections.spi.ConnectionProvider * subclass (if not specified hueristics are used)</td> * </tr> * <tr> * <tr> * <tr> * <td>hibernate.connection.url * <td>JDBC URL (when using java.sql.DriverManager) * </tr> * <tr> * <td>hibernate.connection.driver_class * <td>classname of JDBC driver * </tr> * <tr> * <td>hibernate.connection.isolation * <td>JDBC transaction isolation level (only when using * <tt>java.sql.DriverManager) * </td> * </tr> * <td>hibernate.connection.pool_size * <td>the maximum size of the connection pool (only when using * <tt>java.sql.DriverManager) * </td> * </tr> * <tr> * <td>hibernate.connection.datasource * <td>databasource JNDI name (when using javax.sql.Datasource) * </tr> * <tr> * <td>hibernate.jndi.url * </tr> * <tr> * <td>hibernate.jndi.class * </tr> * <tr> * <td>hibernate.max_fetch_depth * <td>maximum depth of outer join fetching * </tr> * <tr> * <td>hibernate.jdbc.batch_size * <td>enable use of JDBC2 batch API for drivers which support it * </tr> * <tr> * <td>hibernate.jdbc.fetch_size * <td>set the JDBC fetch size * </tr> * <tr> * <td>hibernate.jdbc.use_scrollable_resultset * <td>enable use of JDBC2 scrollable resultsets (you only need this specify * this property when using user supplied connections)</td> * </tr> * <tr> * <td>hibernate.jdbc.use_getGeneratedKeys * <td>enable use of JDBC3 PreparedStatement.getGeneratedKeys() to retrieve * natively generated keys after insert. Requires JDBC3+ driver and JRE1.4+</td> * </tr> * <tr> * <td>hibernate.hbm2ddl.auto * <td>enable auto DDL export * </tr> * <tr> * <td>hibernate.default_schema * <td>use given schema name for unqualified tables (always optional) * </tr> * <tr> * <td>hibernate.default_catalog * <td>use given catalog name for unqualified tables (always optional) * </tr> * <tr> * <td>hibernate.session_factory_name * <td>If set, the factory attempts to bind this name to itself in the * JNDI context. This name is also used to support cross JVM <tt> * Session</tt> (de)serialization. * </tr> * <tr> * <td>hibernate.transaction.manager_lookup_class * <td>classname of org.hibernate.transaction.TransactionManagerLookup * implementor</td> * </tr> * <tr> * <td>hibernate.transaction.factory_class * <td>the factory to use for instantiating Transactions. * (Defaults to <tt>JdbcTransactionFactory.) * </tr> * <tr> * <td>hibernate.query.substitutions * </tr> * </table> * * @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<Integer,String> ISOLATION_LEVELS; 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(); Map<Integer,String> temp = new HashMap(); temp.put( Connection.TRANSACTION_NONE, "NONE" ); temp.put( Connection.TRANSACTION_READ_UNCOMMITTED, "READ_UNCOMMITTED" ); temp.put( Connection.TRANSACTION_READ_COMMITTED, "READ_COMMITTED" ); temp.put( Connection.TRANSACTION_REPEATABLE_READ, "REPEATABLE_READ" ); temp.put( Connection.TRANSACTION_SERIALIZABLE, "SERIALIZABLE" ); ISOLATION_LEVELS = Collections.unmodifiableMap( temp ); 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 { GLOBAL_PROPERTIES.putAll( System.getProperties() ); } 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:<code> * new java.sql.Timestamp( x ).getTime() != x * </code> * <p/> * NOTE : IBM JDK 1.3.1 the only known JVM to exhibit this behavior. * * @return True if the JVM's {@link Timestamp} implementa */ public static boolean jvmHasTimestampBug() { return JVM_HAS_TIMESTAMP_BUG; } /** * Should we use streams to bind binary types to JDBC IN parameters? * * @return True if streams should be used for binary data handling; false otherwise. * * @see #USE_STREAMS_FOR_BINARY */ public static boolean useStreamsForBinary() { return ENABLE_BINARY_STREAMS; } /** * Should we use reflection optimization? * * @return True if reflection optimization should be used; false otherwise. * * @see #USE_REFLECTION_OPTIMIZER * @see #getBytecodeProvider() * @see BytecodeProvider#getReflectionOptimizer */ public static boolean useReflectionOptimizer() { return ENABLE_REFLECTION_OPTIMIZER; } /** * Disallow instantiation */ private Environment() { throw new UnsupportedOperationException(); } /** * Return <tt>System properties, extended by any properties specified * in <tt>hibernate.properties. * @return Properties */ public static Properties getProperties() { Properties copy = new Properties(); copy.putAll(GLOBAL_PROPERTIES); return copy; } /** * Get the name of a JDBC transaction isolation level * * @see java.sql.Connection * @param isolation as defined by <tt>java.sql.Connection * @return a human-readable name */ public static String isolationLevelToString(int isolation) { return ISOLATION_LEVELS.get( isolation ); } public static BytecodeProvider buildBytecodeProvider(Properties properties) { String provider = ConfigurationHelper.getString( BYTECODE_PROVIDER, properties, "javassist" ); LOG.bytecodeProvider(provider); return buildBytecodeProvider( provider ); } private static BytecodeProvider buildBytecodeProvider(String providerName) { if ( "javassist".equals( providerName ) ) { return new org.hibernate.bytecode.internal.javassist.BytecodeProviderImpl(); } LOG.unknownBytecodeProvider( providerName ); return new org.hibernate.bytecode.internal.javassist.BytecodeProviderImpl(); } }

Other Hibernate examples (source code examples)

Here is a short list of links related to this Hibernate Environment.java source code file:

Hibernate example source code file (Environment.java)

This example Hibernate source code file (Environment.java) is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Java - Hibernate tags/keywords

bytecode_provider_instance, bytecodeprovider, enable_binary_streams, enable_reflection_optimizer, global_properties, global_properties, hashmap, io, jdbc, jvm_has_timestamp_bug, jvm_has_timestamp_bug, map, map, object, properties, properties, sql, util

The Hibernate Environment.java source code

/*
 * Hibernate, Relational Persistence for Idiomatic Java
 *
 * Copyright (c) 2010, Red Hat Inc. or third-party contributors as
 * indicated by the @author tags or express copyright attribution
 * statements applied by the authors.  All third-party contributions are
 * distributed under license by Red Hat Inc.
 *
 * This copyrighted material is made available to anyone wishing to use, modify,
 * copy, or redistribute it subject to the terms and conditions of the GNU
 * Lesser General Public License, as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
 * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License
 * for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this distribution; if not, write to:
 * Free Software Foundation, Inc.
 * 51 Franklin Street, Fifth Floor
 * Boston, MA  02110-1301  USA
 */
package org.hibernate.cfg;

import java.io.IOException;
import java.io.InputStream;
import java.sql.Connection;
import java.sql.Timestamp;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;

import org.jboss.logging.Logger;

import org.hibernate.HibernateException;
import org.hibernate.Version;
import org.hibernate.bytecode.spi.BytecodeProvider;
import org.hibernate.internal.CoreMessageLogger;
import org.hibernate.internal.util.ConfigHelper;
import org.hibernate.internal.util.config.ConfigurationHelper;


/**
 * Provides access to configuration info passed in <tt>Properties objects.
 * <br>
* Hibernate has two property scopes: * <ul> * <li>Factory-level properties may be passed to the SessionFactory when it * instantiated. Each instance might have different property values. If no * properties are specified, the factory calls <tt>Environment.getProperties(). * <li>System-level properties are shared by all factory instances and are always * determined by the <tt>Environment properties. * </ul> * The only system-level properties are * <ul> * <li>hibernate.jdbc.use_streams_for_binary * <li>hibernate.cglib.use_reflection_optimizer * </ul> * <tt>Environment properties are populated by calling System.getProperties() * and then from a resource named <tt>/hibernate.properties if it exists. System * properties override properties specified in <tt>hibernate.properties.
* <br> * The <tt>SessionFactory is controlled by the following properties. * Properties may be either be <tt>System properties, properties * defined in a resource named <tt>/hibernate.properties or an instance of * <tt>java.util.Properties passed to * <tt>Configuration.buildSessionFactory()
* <br> * <table> * <tr>
propertymeaning
hibernate.connection.usernamedatabase username
hibernate.connection.passworddatabase password
JNDI InitialContext URLJNDI InitialContext classnamequery language token substitutions
... this post is sponsored by my books ...

#1 New Release!

FP Best Seller

 

new blog posts

 

Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.