Environment.java

Index Score
org.hibernate.cfg
Hibernate

View: Reasons, Metrics, Source Code

These are the metrics that contribute to the Enerjy Score for this file, ranked by impact. So the metrics listed at the top influence the score to a greater extent that the metrics listed at the bottom.

MetricDescription
DECL_COMMENTSComments in declarations
DOC_COMMENTNumber of javadoc comment lines
COMMENTSComment lines
SIZESize of the file in bytes
UNIQUE_OPERANDSNumber of unique operands
LINESNumber of lines in the source file
JAVA0110JAVA0110 Incorrect javadoc: no @return tag
PROGRAM_VOCABHalstead program vocabulary
JAVA0144JAVA0144 Line exceeds maximum M characters
LOGICAL_LINESNumber of statements
JAVA0116JAVA0116 Missing javadoc: field 'field'
JAVA0177JAVA0177 Variable declaration missing initializer
PROGRAM_VOLUMEHalstead program volume
EXEC_COMMENTSComments in executable code
JAVA0126JAVA0126 Method declares unchecked exception in throws
LINE_COMMENTNumber of line comments
COMPARISONSNumber of comparison operators
INTERFACE_COMPLEXITYInterface complexity
LOOPSNumber of loops
JAVA0254JAVA0254 Use enhanced for loop construct instead of Iterator
CYCLOMATICCyclomatic complexity
PARAMSNumber of formal parameter declarations
RETURNSNumber of return points from functions
/* * Hibernate, Relational Persistence for Idiomatic Java * * Copyright (c) 2008, Red Hat Middleware LLC 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 Middleware LLC. * * 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.Statement; import java.sql.Timestamp; import java.util.HashMap; import java.util.Iterator; import java.util.Map; import java.util.Properties; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.hibernate.HibernateException; import org.hibernate.bytecode.BytecodeProvider; import org.hibernate.util.ConfigHelper; import org.hibernate.util.PropertiesHelper; /** * Provides access to configuration info passed in <tt>Properties</tt> objects. * <br><br> * Hibernate has two property scopes: * <ul> * <li><b>Factory-level</b> properties may be passed to the <tt>SessionFactory</tt> when it * instantiated. Each instance might have different property values. If no * properties are specified, the factory calls <tt>Environment.getProperties()</tt>. * <li><b>System-level</b> properties are shared by all factory instances and are always * determined by the <tt>Environment</tt> properties. * </ul> * The only system-level properties are * <ul> * <li><tt>hibernate.jdbc.use_streams_for_binary</tt> * <li><tt>hibernate.cglib.use_reflection_optimizer</tt> * </ul> * <tt>Environment</tt> properties are populated by calling <tt>System.getProperties()</tt> * and then from a resource named <tt>/hibernate.properties</tt> if it exists. System * properties override properties specified in <tt>hibernate.properties</tt>.<br> * <br> * The <tt>SessionFactory</tt> is controlled by the following properties. * Properties may be either be <tt>System</tt> properties, properties * defined in a resource named <tt>/hibernate.properties</tt> or an instance of * <tt>java.util.Properties</tt> passed to * <tt>Configuration.buildSessionFactory()</tt><br> * <br> * <table> * <tr><td><b>property</b></td><td><b>meaning</b></td></tr> * <tr> * <td><tt>hibernate.dialect</tt></td> * <td>classname of <tt>org.hibernate.dialect.Dialect</tt> subclass</td> * </tr> * <tr> * <td><tt>hibernate.cache.provider_class</tt></td> * <td>classname of <tt>org.hibernate.cache.CacheProvider</tt> * subclass (if not specified EHCache is used)</td> * </tr> * <tr> * <td><tt>hibernate.connection.provider_class</tt></td> * <td>classname of <tt>org.hibernate.connection.ConnectionProvider</tt> * subclass (if not specified hueristics are used)</td> * </tr> * <tr><td><tt>hibernate.connection.username</tt></td><td>database username</td></tr> * <tr><td><tt>hibernate.connection.password</tt></td><td>database password</td></tr> * <tr> * <td><tt>hibernate.connection.url</tt></td> * <td>JDBC URL (when using <tt>java.sql.DriverManager</tt>)</td> * </tr> * <tr> * <td><tt>hibernate.connection.driver_class</tt></td> * <td>classname of JDBC driver</td> * </tr> * <tr> * <td><tt>hibernate.connection.isolation</tt></td> * <td>JDBC transaction isolation level (only when using * <tt>java.sql.DriverManager</tt>) * </td> * </tr> * <td><tt>hibernate.connection.pool_size</tt></td> * <td>the maximum size of the connection pool (only when using * <tt>java.sql.DriverManager</tt>) * </td> * </tr> * <tr> * <td><tt>hibernate.connection.datasource</tt></td> * <td>databasource JNDI name (when using <tt>javax.sql.Datasource</tt>)</td> * </tr> * <tr> * <td><tt>hibernate.jndi.url</tt></td><td>JNDI <tt>InitialContext</tt> URL</td> * </tr> * <tr> * <td><tt>hibernate.jndi.class</tt></td><td>JNDI <tt>InitialContext</tt> classname</td> * </tr> * <tr> * <td><tt>hibernate.max_fetch_depth</tt></td> * <td>maximum depth of outer join fetching</td> * </tr> * <tr> * <td><tt>hibernate.jdbc.batch_size</tt></td> * <td>enable use of JDBC2 batch API for drivers which support it</td> * </tr> * <tr> * <td><tt>hibernate.jdbc.fetch_size</tt></td> * <td>set the JDBC fetch size</td> * </tr> * <tr> * <td><tt>hibernate.jdbc.use_scrollable_resultset</tt></td> * <td>enable use of JDBC2 scrollable resultsets (you only need this specify * this property when using user supplied connections)</td> * </tr> * <tr> * <td><tt>hibernate.jdbc.use_getGeneratedKeys</tt></td> * <td>enable use of JDBC3 PreparedStatement.getGeneratedKeys() to retrieve * natively generated keys after insert. Requires JDBC3+ driver and JRE1.4+</td> * </tr> * <tr> * <td><tt>hibernate.hbm2ddl.auto</tt></td> * <td>enable auto DDL export</td> * </tr> * <tr> * <td><tt>hibernate.default_schema</tt></td> * <td>use given schema name for unqualified tables (always optional)</td> * </tr> * <tr> * <td><tt>hibernate.default_catalog</tt></td> * <td>use given catalog name for unqualified tables (always optional)</td> * </tr> * <tr> * <td><tt>hibernate.session_factory_name</tt></td> * <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.</td> * </tr> * <tr> * <td><tt>hibernate.transaction.manager_lookup_class</tt></td> * <td>classname of <tt>org.hibernate.transaction.TransactionManagerLookup</tt> * implementor</td> * </tr> * <tr> * <td><tt>hibernate.transaction.factory_class</tt></td> * <td>the factory to use for instantiating <tt>Transaction</tt>s. * (Defaults to <tt>JDBCTransactionFactory</tt>.)</td> * </tr> * <tr> * <td><tt>hibernate.query.substitutions</tt></td><td>query language token substitutions</td> * </tr> * </table> * * @see org.hibernate.SessionFactory * @author Gavin King */ public final class Environment { public static final String VERSION = "3.3.0.GA"; /** * <tt>ConnectionProvider</tt> implementor to use when obtaining connections */ public static final String CONNECTION_PROVIDER ="hibernate.connection.provider_class"; /** * JDBC driver class */ public static final String DRIVER ="hibernate.connection.driver_class"; /** * JDBC transaction isolation level */ public static final String ISOLATION ="hibernate.connection.isolation"; /** * JDBC URL */ public static final String URL ="hibernate.connection.url"; /** * JDBC user */ public static final String USER ="hibernate.connection.username"; /** * JDBC password */ public static final String PASS ="hibernate.connection.password"; /** * JDBC autocommit mode */ public static final String AUTOCOMMIT ="hibernate.connection.autocommit"; /** * Maximum number of inactive connections for Hibernate's connection pool */ public static final String POOL_SIZE ="hibernate.connection.pool_size"; /** * <tt>java.sql.Datasource</tt> JNDI name */ public static final String DATASOURCE ="hibernate.connection.datasource"; /** * prefix for arbitrary JDBC connection properties */ public static final String CONNECTION_PREFIX = "hibernate.connection"; /** * JNDI initial context class, <tt>Context.INITIAL_CONTEXT_FACTORY</tt> */ public static final String JNDI_CLASS ="hibernate.jndi.class"; /** * JNDI provider URL, <tt>Context.PROVIDER_URL</tt> */ public static final String JNDI_URL ="hibernate.jndi.url"; /** * prefix for arbitrary JNDI <tt>InitialContext</tt> properties */ public static final String JNDI_PREFIX = "hibernate.jndi"; /** * JNDI name to bind to <tt>SessionFactory</tt> */ public static final String SESSION_FACTORY_NAME = "hibernate.session_factory_name"; /** * Hibernate SQL <tt>Dialect</tt> class */ public static final String DIALECT ="hibernate.dialect"; /** * A default database schema (owner) name to use for unqualified tablenames */ public static final String DEFAULT_SCHEMA = "hibernate.default_schema"; /** * A default database catalog name to use for unqualified tablenames */ public static final String DEFAULT_CATALOG = "hibernate.default_catalog"; /** * Enable logging of generated SQL to the console */ public static final String SHOW_SQL ="hibernate.show_sql"; /** * Enable formatting of SQL logged to the console */ public static final String FORMAT_SQL ="hibernate.format_sql"; /** * Add comments to the generated SQL */ public static final String USE_SQL_COMMENTS ="hibernate.use_sql_comments"; /** * Maximum depth of outer join fetching */ public static final String MAX_FETCH_DEPTH = "hibernate.max_fetch_depth"; /** * The default batch size for batch fetching */ public static final String DEFAULT_BATCH_FETCH_SIZE = "hibernate.default_batch_fetch_size"; /** * Use <tt>java.io</tt> streams to read / write binary data from / to JDBC */ public static final String USE_STREAMS_FOR_BINARY = "hibernate.jdbc.use_streams_for_binary"; /** * Use JDBC scrollable <tt>ResultSet</tt>s. This property is only necessary when there is * no <tt>ConnectionProvider</tt>, ie. the user is supplying JDBC connections. */ public static final String USE_SCROLLABLE_RESULTSET = "hibernate.jdbc.use_scrollable_resultset"; /** * 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(). */ public static final String USE_GET_GENERATED_KEYS = "hibernate.jdbc.use_get_generated_keys"; /** * 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 <tt>0</tt>, JDBC driver default settings will be used. */ public static final String STATEMENT_FETCH_SIZE = "hibernate.jdbc.fetch_size"; /** * Maximum JDBC batch size. A nonzero value enables batch updates. */ public static final String STATEMENT_BATCH_SIZE = "hibernate.jdbc.batch_size"; /** * Select a custom batcher. */ public static final String BATCH_STRATEGY = "hibernate.jdbc.factory_class"; /** * Should versioned data be included in batching? */ public static final String BATCH_VERSIONED_DATA = "hibernate.jdbc.batch_versioned_data"; /** * An XSLT resource used to generate "custom" XML */ public static final String OUTPUT_STYLESHEET ="hibernate.xml.output_stylesheet"; /** * Maximum size of C3P0 connection pool */ public static final String C3P0_MAX_SIZE = "hibernate.c3p0.max_size"; /** * Minimum size of C3P0 connection pool */ public static final String C3P0_MIN_SIZE = "hibernate.c3p0.min_size"; /** * Maximum idle time for C3P0 connection pool */ public static final String C3P0_TIMEOUT = "hibernate.c3p0.timeout"; /** * Maximum size of C3P0 statement cache */ public static final String C3P0_MAX_STATEMENTS = "hibernate.c3p0.max_statements"; /** * Number of connections acquired when pool is exhausted */ public static final String C3P0_ACQUIRE_INCREMENT = "hibernate.c3p0.acquire_increment"; /** * Idle time before a C3P0 pooled connection is validated */ public static final String C3P0_IDLE_TEST_PERIOD = "hibernate.c3p0.idle_test_period"; /** * Proxool/Hibernate property prefix */ public static final String PROXOOL_PREFIX = "hibernate.proxool"; /** * Proxool property to configure the Proxool Provider using an XML (<tt>/path/to/file.xml</tt>) */ public static final String PROXOOL_XML = "hibernate.proxool.xml"; /** * Proxool property to configure the Proxool Provider using a properties file (<tt>/path/to/proxool.properties</tt>) */ public static final String PROXOOL_PROPERTIES = "hibernate.proxool.properties"; /** * Proxool property to configure the Proxool Provider from an already existing pool (<tt>true</tt> / <tt>false</tt>) */ public static final String PROXOOL_EXISTING_POOL = "hibernate.proxool.existing_pool"; /** * Proxool property with the Proxool pool alias to use * (Required for <tt>PROXOOL_EXISTING_POOL</tt>, <tt>PROXOOL_PROPERTIES</tt>, or * <tt>PROXOOL_XML</tt>) */ public static final String PROXOOL_POOL_ALIAS = "hibernate.proxool.pool_alias"; /** * Enable automatic session close at end of transaction */ public static final String AUTO_CLOSE_SESSION = "hibernate.transaction.auto_close_session"; /** * Enable automatic flush during the JTA <tt>beforeCompletion()</tt> callback */ public static final String FLUSH_BEFORE_COMPLETION = "hibernate.transaction.flush_before_completion"; /** * Specifies how Hibernate should release JDBC connections. */ public static final String RELEASE_CONNECTIONS = "hibernate.connection.release_mode"; /** * Context scoping impl for {@link org.hibernate.SessionFactory#getCurrentSession()} processing. */ public static final String CURRENT_SESSION_CONTEXT_CLASS = "hibernate.current_session_context_class"; /** * <tt>TransactionFactory</tt> implementor to use for creating <tt>Transaction</tt>s */ public static final String TRANSACTION_STRATEGY = "hibernate.transaction.factory_class"; /** * <tt>TransactionManagerLookup</tt> implementor to use for obtaining the <tt>TransactionManager</tt> */ public static final String TRANSACTION_MANAGER_STRATEGY = "hibernate.transaction.manager_lookup_class"; /** * JNDI name of JTA <tt>UserTransaction</tt> object */ public static final String USER_TRANSACTION = "jta.UserTransaction"; /** * The <tt>CacheProvider</tt> implementation class */ public static final String CACHE_PROVIDER = "hibernate.cache.provider_class"; /** * The {@link org.hibernate.cache.RegionFactory} implementation class */ public static final String CACHE_REGION_FACTORY = "hibernate.cache.region.factory_class"; /** * The <tt>CacheProvider</tt> implementation class */ public static final String CACHE_PROVIDER_CONFIG = "hibernate.cache.provider_configuration_file_resource_path"; /** * The <tt>CacheProvider</tt> JNDI namespace, if pre-bound to JNDI. */ public static final String CACHE_NAMESPACE = "hibernate.cache.jndi"; /** * Enable the query cache (disabled by default) */ public static final String USE_QUERY_CACHE = "hibernate.cache.use_query_cache"; /** * The <tt>QueryCacheFactory</tt> implementation class. */ public static final String QUERY_CACHE_FACTORY = "hibernate.cache.query_cache_factory"; /** * Enable the second-level cache (enabled by default) */ public static final String USE_SECOND_LEVEL_CACHE = "hibernate.cache.use_second_level_cache"; /** * Optimize the cache for mimimal puts instead of minimal gets */ public static final String USE_MINIMAL_PUTS = "hibernate.cache.use_minimal_puts"; /** * The <tt>CacheProvider</tt> region name prefix */ public static final String CACHE_REGION_PREFIX = "hibernate.cache.region_prefix"; /** * Enable use of structured second-level cache entries */ public static final String USE_STRUCTURED_CACHE = "hibernate.cache.use_structured_entries"; /** * Enable statistics collection */ public static final String GENERATE_STATISTICS = "hibernate.generate_statistics"; public static final String USE_IDENTIFIER_ROLLBACK = "hibernate.use_identifier_rollback"; /** * Use bytecode libraries optimized property access */ public static final String USE_REFLECTION_OPTIMIZER = "hibernate.bytecode.use_reflection_optimizer"; /** * The classname of the HQL query parser factory */ public static final String QUERY_TRANSLATOR = "hibernate.query.factory_class"; /** * A comma-seperated list of token substitutions to use when translating a Hibernate * query to SQL */ public static final String QUERY_SUBSTITUTIONS = "hibernate.query.substitutions"; /** * Should named queries be checked during startup (the default is enabled). * <p/> * Mainly intended for test environments. */ public static final String QUERY_STARTUP_CHECKING = "hibernate.query.startup_check"; /** * Auto export/update schema using hbm2ddl tool. Valid values are <tt>update</tt>, * <tt>create</tt>, <tt>create-drop</tt> and <tt>validate</tt>. */ public static final String HBM2DDL_AUTO = "hibernate.hbm2ddl.auto"; /** * The {@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 SQL_EXCEPTION_CONVERTER = "hibernate.jdbc.sql_exception_converter"; /** * Enable wrapping of JDBC result sets in order to speed up column name lookups for * broken JDBC drivers */ public static final String WRAP_RESULT_SETS = "hibernate.jdbc.wrap_result_sets"; /** * Enable ordering of update statements by primary key value */ public static final String ORDER_UPDATES = "hibernate.order_updates"; /** * Enable ordering of insert statements for the purpose of more effecient JDBC batching. */ public static final String ORDER_INSERTS = "hibernate.order_inserts"; /** * The EntityMode in which set the Session opened from the SessionFactory. */ public static final String DEFAULT_ENTITY_MODE = "hibernate.default_entity_mode"; /** * The jacc context id of the deployment */ public static final String JACC_CONTEXTID = "hibernate.jacc_context_id"; public static final String BYTECODE_PROVIDER = "hibernate.bytecode.provider"; public static final String JPAQL_STRICT_COMPLIANCE= "hibernate.query.jpaql_strict_compliance"; 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_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 = new HashMap(); private static final Map OBSOLETE_PROPERTIES = new HashMap(); private static final Map RENAMED_PROPERTIES = new HashMap(); private static final Logger log = LoggerFactory.getLogger(Environment.class); /** * Issues warnings to the user when any obsolete property names are used. */ public static void verifyProperties(Properties props) { 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); } static { 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"); } } public static BytecodeProvider getBytecodeProvider() { return BYTECODE_PROVIDER_INSTANCE; } /** * Does this JVM have the IBM JDK 1.3.1. The bug is <tt>new Timestamp(x).getTime()!=x</tt>. */ public static boolean jvmHasTimestampBug() { return JVM_HAS_TIMESTAMP_BUG; } /** * Does this JVM handle <tt>Timestamp</tt> in the JDK 1.4 compliant way? */ public static boolean jvmHasJDK14Timestamp() { return JVM_HAS_JDK14_TIMESTAMP; } /** * Does this JVM support <tt>LinkedHashSet</tt>, <tt>LinkedHashMap</tt>. * @see java.util.LinkedHashSet * @see java.util.LinkedHashMap */ public static boolean jvmSupportsLinkedHashCollections() { return JVM_SUPPORTS_LINKED_HASH_COLLECTIONS; } public static boolean jvmSupportsGetGeneratedKeys() { return JVM_SUPPORTS_GET_GENERATED_KEYS; } /** * Should we use streams to bind binary types to JDBC IN parameters. * Property <tt>hibernate.jdbc.use_streams_for_binary</tt>. * @see Environment#USE_STREAMS_FOR_BINARY */ public static boolean useStreamsForBinary() { return ENABLE_BINARY_STREAMS; } /** * Should we use CGLIB reflection optimizer. * Property <tt>hibernate.jdbc.use_refection_optimizer</tt>. * @see Environment#USE_REFLECTION_OPTIMIZER */ public static boolean useReflectionOptimizer() { return ENABLE_REFLECTION_OPTIMIZER; } private Environment() { throw new UnsupportedOperationException(); } /** * Return <tt>System</tt> properties, extended by any properties specified * in <tt>hibernate.properties</tt>. * @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</tt> * @return a human-readable name */ public static String isolationLevelToString(int isolation) { return (String) ISOLATION_LEVELS.get( new Integer(isolation) ); } public static BytecodeProvider buildBytecodeProvider(Properties properties) { String provider = PropertiesHelper.getString( BYTECODE_PROVIDER, properties, "javassist" ); log.info( "Bytecode provider name : " + provider ); return buildBytecodeProvider( provider ); } private static BytecodeProvider buildBytecodeProvider(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(); } log.warn( "unrecognized bytecode provider [" + providerName + "], using javassist by default" ); return new org.hibernate.bytecode.javassist.BytecodeProviderImpl(); } }

The table below shows all metrics for Environment.java.

MetricValueDescription
BLOCKS37.00Number of blocks
BLOCK_COMMENT24.00Number of block comment lines
COMMENTS415.00Comment lines
COMMENT_DENSITY 1.98Comment density
COMPARISONS 9.00Number of comparison operators
CYCLOMATIC31.00Cyclomatic complexity
DECL_COMMENTS80.00Comments in declarations
DOC_COMMENT390.00Number of javadoc comment lines
ELOC210.00Effective lines of code
EXEC_COMMENTS 1.00Comments in executable code
EXITS33.00Procedure exits
FUNCTIONS13.00Number of function declarations
HALSTEAD_DIFFICULTY33.92Halstead difficulty
HALSTEAD_EFFORT 0.00Halstead effort
INTERFACE_COMPLEXITY20.00Interface complexity
JAVA0001 0.00JAVA0001 Package name does not contain only lower case letters
JAVA0002 0.00JAVA0002 Package name does not begin with a top level domain name or country code
JAVA0003 0.00JAVA0003 Minimize use of on-demand (.*) imports
JAVA0004 0.00JAVA0004 Unnecessary import from java.lang
JAVA0005 1.00JAVA0005 Imports not in specified order
JAVA0006 0.00JAVA0006 Empty finally block
JAVA0007 0.00JAVA0007 Should not declare public field
JAVA0008 0.00JAVA0008 Empty catch block
JAVA0009 0.00JAVA0009 Protected member in final class
JAVA0010 0.00JAVA0010 Non-instantiable class does not contain a non-private static member
JAVA0011 0.00JAVA0011 Abstract class does not contain an abstract method
JAVA0012 0.00JAVA0012 Non-constructor method with same name as declaring class
JAVA0013 0.00JAVA0013 Non-blank final field is not static
JAVA0014 0.00JAVA0014 Class with only static members has non-private constructor
JAVA0015 0.00JAVA0015 Package class contains public nested type
JAVA0016 0.00JAVA0016 Abstract class contains public constructor
JAVA0017 0.00JAVA0017 Class name does not have required form
JAVA0018 0.00JAVA0018 Method name does not have required form
JAVA0019 0.00JAVA0019 Interface name does not have required form
JAVA0020 0.00JAVA0020 Field name does not have required form
JAVA0021 0.00JAVA0021 Interface method name does not have required form
JAVA0022 0.00JAVA0022 Static final field name does not have required form
JAVA0023 0.00JAVA0023 Empty finalize method
JAVA0024 0.00JAVA0024 Empty class
JAVA0025 0.00JAVA0025 Method override is empty
JAVA0026 0.00JAVA0026 Finalize method with parameters
JAVA0029 0.00JAVA0029 Private method not used
JAVA0030 0.00JAVA0030 Private field not used
JAVA0031 0.00JAVA0031 Case statement not properly closed
JAVA0032 0.00JAVA0032 Switch statement missing default
JAVA0033 0.00JAVA0033 default: not last case in switch statement
JAVA0034 3.00JAVA0034 Missing braces in if statement
JAVA0035 0.00JAVA0035 Missing braces in for statement
JAVA0036 0.00JAVA0036 Missing braces in while statement
JAVA0038 0.00JAVA0038 Non-case label in switch statement
JAVA0039 0.00JAVA0039 Break statement with label
JAVA0040 0.00JAVA0040 Switch statement contains N cases (maximum: M)
JAVA0041 0.00JAVA0041 Nested synchronized block
JAVA0042 0.00JAVA0042 Empty synchronized statement
JAVA0043 0.00JAVA0043 Inner class does not use outer class
JAVA0044 0.00JAVA0044 Serializable class with no instance variables
JAVA0045 0.00JAVA0045 Serializable class with only transient fields
JAVA0046 0.00JAVA0046 Name of class not derived from Exception ends with 'Exception'
JAVA0047 0.00JAVA0047 Serializable class derives from invalid base class
JAVA0048 0.00JAVA0048 Name of class derived from Exception does not end with 'Exception'
JAVA0049 0.00JAVA0049 Nested block at depth N (maximum: M)
JAVA0050 0.00JAVA0050 Class derives from java.lang.Error
JAVA0051 0.00JAVA0051 Class derives from java.lang.RuntimeException
JAVA0052 0.00JAVA0052 Class derives from java.lang.Throwable
JAVA0053 0.00JAVA0053 Unused label
JAVA0054 0.00JAVA0054 Inheritance depth N exceeds maximum M
JAVA0055 0.00JAVA0055 Class should be interface
JAVA0056 0.00JAVA0056 Unnecessary abstract modifier for interface or annotation
JAVA0057 0.00JAVA0057 Unnecessary default constructor
JAVA0058 0.00JAVA0058 Constructor calls super()
JAVA0059 0.00JAVA0059 Method override only calls super()
JAVA0061 0.00JAVA0061 Inaccessible member in anonymous class
JAVA0062 0.00JAVA0062 Public class missing public member or protected constructor
JAVA0063 0.00JAVA0063 Identifier name should not contain '$'
JAVA0064 1.00JAVA0064 N variations of identifier name (maximum: M)
JAVA0065 0.00JAVA0065 Unnecessary final modifier for method in final class
JAVA0066 0.00JAVA0066 Unnecessary modifier for interface nested type
JAVA0067 0.00JAVA0067 Array descriptor on identifier name
JAVA0068 0.00JAVA0068 Modifiers not declared in recommended order
JAVA0071 0.00JAVA0071 Strings compared with ==
JAVA0073 0.00JAVA0073 Integer division in floating-point context
JAVA0074 0.00JAVA0074 Use of Object.notify()
JAVA0075 0.00JAVA0075 Method parameter hides field
JAVA0076 2.00JAVA0076 Use of magic number
JAVA0077 0.00JAVA0077 Private field not used in declaring class
JAVA0078 0.00JAVA0078 Floating point values compared with ==
JAVA0079 0.00JAVA0079 Use of instance to reference static member
JAVA0080 0.00JAVA0080 Import declaration not used
JAVA0081 0.00JAVA0081 Boolean literal in comparison
JAVA0082 0.00JAVA0082 Unnecessary widening cast
JAVA0083 0.00JAVA0083 Unnecessary instanceof test
JAVA0084 0.00JAVA0084 Should use compound assignment operator
JAVA0085 0.00JAVA0085 Use of sun.* class
JAVA0087 0.00JAVA0087 Use of Thread.sleep()
JAVA0089 0.00JAVA0089 Use of restricted package
JAVA0092 0.00JAVA0092 Use of restricted type
JAVA0093 0.00JAVA0093 Redundant assignment
JAVA0094 0.00JAVA0094 Field hides a superclass field
JAVA0095 0.00JAVA0095 Uninitialized private field
JAVA0096 0.00JAVA0096 Field in nested class hides outer field
JAVA0098 0.00JAVA0098 Minimize use of implicit field initializers
JAVA0100 0.00JAVA0100 Class contains N non-final fields (maximum: M)
JAVA0101 0.00JAVA0101 Unnecessary modifier for field in interface
JAVA0102 0.00JAVA0102 Last statement in finalize() not super.finalize()
JAVA0103 0.00JAVA0103 Explicit call to finalize()
JAVA0104 0.00JAVA0104 finalize() only calls super.finalize()
JAVA0105 0.00JAVA0105 Duplicate import declaration
JAVA0106 0.00JAVA0106 Unnecessary import from current package
JAVA0108 1.00JAVA0108 Incorrect javadoc: no @param tag for 'parameter'
JAVA0109 0.00JAVA0109 Incorrect javadoc: no parameter 'parameter'
JAVA0110 5.00JAVA0110 Incorrect javadoc: no @return tag
JAVA0111 0.00JAVA0111 Incorrect javadoc: @return tag for void method
JAVA0112 0.00JAVA0112 Incorrect javadoc: no exception 'exception' in throws
JAVA0113 0.00JAVA0113 Incorrect javadoc: no @author tag
JAVA0114 1.00JAVA0114 Incorrect javadoc: no @version tag
JAVA0115 0.00JAVA0115 Incorrect javadoc: no @throws or @exception tag for 'exception'
JAVA0116 4.00JAVA0116 Missing javadoc: field 'field'
JAVA0117 3.00JAVA0117 Missing javadoc: method 'method'
JAVA0118 0.00JAVA0118 Missing javadoc: type 'type'
JAVA0119 0.00JAVA0119 Control variable changed within body of for loop
JAVA0123 0.00JAVA0123 Use all three components of for loop
JAVA0125 0.00JAVA0125 Continue statement with label
JAVA0126 0.00JAVA0126 Method declares unchecked exception in throws
JAVA0128 0.00JAVA0128 Public constructor in non-public class
JAVA0130 0.00JAVA0130 Non-static method does not use instance fields
JAVA0131 0.00JAVA0131 Compatible method does not override base
JAVA0132 0.00JAVA0132 Method overload with compatible signature
JAVA0133 0.00JAVA0133 Non-synchronized method overrides synchronized method
JAVA0135 0.00JAVA0135 Only one of Object.equals and Object.hashCode defined: missing 'method'
JAVA0136 0.00JAVA0136 N methods defined in class (maximum: M)
JAVA0137 0.00JAVA0137 Non-abstract class missing constructor
JAVA0138 0.00JAVA0138 N parameters defined for method (maximum: M)
JAVA0139 0.00JAVA0139 Definition of main other than public static void main(java.lang.String[])
JAVA0141 0.00JAVA0141 Unnecessary modifier for method in interface
JAVA0143 0.00JAVA0143 Synchronized method
JAVA0144 3.00JAVA0144 Line exceeds maximum M characters
JAVA0145661.00JAVA0145 Tab character used in source file
JAVA0150 0.00JAVA0150 java.lang.Error (or subclass) thrown
JAVA0153 0.00JAVA0153 Inefficient conversion of integer to string
JAVA0159 0.00JAVA0159 Inefficient conversion of string to integer
JAVA0160 0.00JAVA0160 Method does not throw specified exception
JAVA0161 0.00JAVA0161 Conditional wait() not in loop
JAVA0163 0.00JAVA0163 Empty statement
JAVA0165 0.00JAVA0165 Conflicting return statement in finally block
JAVA0166 1.00JAVA0166 Generic exception caught
JAVA0167 0.00JAVA0167 ThreadDeath not rethrown
JAVA0169 0.00JAVA0169 Unnecessary catch block: exception 'exception'
JAVA0170 0.00JAVA0170 Caught exception not derived from java.lang.Exception
JAVA0171 0.00JAVA0171 Unused local variable
JAVA0173 0.00JAVA0173 Unused method parameter
JAVA0174 0.00JAVA0174 Assigned local variable never used
JAVA0175 0.00JAVA0175 Successive assignment to variable
JAVA0176 0.00JAVA0176 Local variable name does not have required form
JAVA0177 2.00JAVA0177 Variable declaration missing initializer
JAVA0179 0.00JAVA0179 Local variable hides visible field
JAVA0233 0.00JAVA0233 Definition of serialVersionUID other than 'private static final long serialVersionUID'
JAVA0234 0.00JAVA0234 Class is Serializable but does not define serialVersionUID
JAVA0235 0.00JAVA0235 Class defines serialVersionUID but does not implement Serializable
JAVA0236 0.00JAVA0236 Attempt to clone an object which does not implement Cloneable
JAVA0237 0.00JAVA0237 Class implements Cloneable but does not have public clone method
JAVA0238 0.00JAVA0238 Clone method does not call super.clone()
JAVA0239 0.00JAVA0239 Class declares 'readObject' or 'writeObject' but does not implement Serializable
JAVA0240 0.00JAVA0240 Serializable class which declares readObject or writeObject but not both
JAVA0241 0.00JAVA0241 'readObject' or 'writeObject' should be declared private in Serializable class
JAVA0242 0.00JAVA0242 Transient field in non-Serializable class
JAVA0243 0.00JAVA0243 'readResolve' or 'writeReplace' should be declared private or protected
JAVA0244 0.00JAVA0244 Field or method name in subclass differs only by case from inherited field or method
JAVA0245 0.00JAVA0245 JUnit TestCase with non-trivial constructor
JAVA0246 0.00JAVA0246 JUnit assertXXX statement missing message parameter
JAVA0247 0.00JAVA0247 JUnit 'setUp()' and 'tearDown()' should call super method
JAVA0248 0.00JAVA0248 JUnit method 'setUp' or 'tearDown' with incorrect signature
JAVA0249 0.00JAVA0249 JUnit TestCase 'suite()' should be declared static
JAVA0250 0.00JAVA0250 JUnit TestCase declares testXXX method with incorrect signature
JAVA0251 0.00JAVA0251 Use '%n' for line breaks in printf/format for platform independence
JAVA0252 0.00JAVA0252 'enum' is a Java 1.5 reserved word
JAVA0253 0.00JAVA0253 Not all enum constants consumed in switch statement
JAVA0254 1.00JAVA0254 Use enhanced for loop construct instead of Iterator
JAVA0255 0.00JAVA0255 Result of method invocation not used
JAVA0256 0.00JAVA0256 Assignment of external collection/array to field
JAVA0257 0.00JAVA0257 Use of 'Constant Interface' anti-pattern
JAVA0258 0.00JAVA0258 Implement Iterable for foreach compatibility
JAVA0259 0.00JAVA0259 Return of collection/array field
JAVA0260 0.00JAVA0260 Use 'enum' instead of Enumerated Type pattern
JAVA0261 0.00JAVA0261 Use specialized Enum collection types
JAVA0262 0.00JAVA0262 Use of char in integer context
JAVA0263 0.00JAVA0263 Long literal ends with 'l' instead of 'L'
JAVA0264 0.00JAVA0264 Integer math in long context - check for overflow
JAVA0265 0.00JAVA0265 Use of Throwable.printStackTrace()
JAVA0266 0.00JAVA0266 Use of System.out
JAVA0267 0.00JAVA0267 Use of System.err
JAVA0269 0.00JAVA0269 Contents of StringBuffer never used
JAVA0270 0.00JAVA0270 Use Java 5.0 enhanced for loop construct to iterate over all elements in an array
JAVA0271 0.00JAVA0271 Minimize use of on-demand (.*) static imports
JAVA0272 0.00JAVA0272 Thread.run() called
JAVA0273 0.00JAVA0273 Non-final derivative of Thread calls start() in constructor
JAVA0274 0.00JAVA0274 Serializable class has a synchronized readObject()
JAVA0275 0.00JAVA0275 Serializable class has a synchronized writeObject() and no other synchronized methods
JAVA0276 0.00JAVA0276 Unnecessary use of String constructor
JAVA0277 0.00JAVA0277 Iterator.next() implementation does not throw NoSuchElementException
JAVA0278 0.00JAVA0278 Unnecessary use of Boolean constructor
JAVA0279 0.00JAVA0279 Serialization method readObject or readObjectNoData calls an overridable method
JAVA0280 0.00JAVA0280 IllegalMonitorStateException caught
JAVA0281 0.00JAVA0281 Iterator.next() not called in loop
JAVA0282 0.00JAVA0282 Call to Iterator.next() in loop which does not test Iterator.hasNext()
JAVA0283 0.00JAVA0283 Control variable not updated in loop body
JAVA0284 0.00JAVA0284 Explicit garbage collection
JAVA0285 0.00JAVA0285 Dereference of potentially null variable
JAVA0286 0.00JAVA0286 Dereference of null variable
JAVA0287 0.00JAVA0287 Unnecessary null check
JAVA0288 0.00JAVA0288 Inconsistent null check
LINES725.00Number of lines in the source file
LINE_COMMENT 1.00Number of line comments
LOC247.00Lines of code
LOGICAL_LINES173.00Number of statements
LOOPS 1.00Number of loops
NEST_DEPTH 4.00Maximum nesting depth
OPERANDS599.00Number of operands
OPERATORS1094.00Number of operators
PARAMS 4.00Number of formal parameter declarations
PROGRAM_LENGTH1693.00Halstead program length
PROGRAM_VOCAB344.00Halstead program vocabulary
PROGRAM_VOLUME 0.00Halstead program volume
RETURNS16.00Number of return points from functions
SIZE26177.00Size of the file in bytes
UNIQUE_OPERANDS309.00Number of unique operands
UNIQUE_OPERATORS35.00Number of unique operators
WHITESPACE63.00Number of whitespace lines