From bec88716d68e2434b13c332476de5bd887f466f8 Mon Sep 17 00:00:00 2001 From: Strong Liu Date: Wed, 2 Nov 2011 14:16:02 +0800 Subject: [PATCH] HHH-6791 tiny improvement, in favor of java auto-box instead of create new instance --- .../internal/C3P0ConnectionProvider.java | 4 +-- .../javassist/FieldInterceptorImpl.java | 4 +-- .../javassist/ProxyFactoryFactoryImpl.java | 4 +-- .../cache/internal/StandardQueryCache.java | 2 +- .../cache/spi/UpdateTimestampsCache.java | 4 +-- .../cache/spi/entry/StructuredCacheEntry.java | 2 +- .../java/org/hibernate/cfg/HbmBinder.java | 4 +-- .../cfg/NamedSQLQuerySecondPass.java | 4 +-- .../internal/PersistentArrayHolder.java | 6 ++-- .../internal/PersistentIdentifierBag.java | 36 +++++++++---------- .../collection/internal/PersistentList.java | 12 +++---- .../org/hibernate/engine/jdbc/BlobProxy.java | 2 +- .../org/hibernate/engine/jdbc/ClobProxy.java | 2 +- .../engine/query/spi/ParameterParser.java | 2 +- .../engine/query/spi/QueryPlanCache.java | 2 +- .../internal/ast/tree/BooleanLiteralNode.java | 2 +- .../hql/internal/ast/util/ASTPrinter.java | 2 +- .../hql/internal/ast/util/ASTUtil.java | 4 +-- .../id/IdentifierGeneratorHelper.java | 18 +++++----- .../hibernate/internal/AbstractQueryImpl.java | 30 ++++++++-------- .../FetchingScrollableResultsImpl.java | 2 +- .../AbstractCollectionPersister.java | 4 +-- .../proxy/pojo/BasicLazyInitializer.java | 2 +- .../java/org/hibernate/type/ByteType.java | 2 +- .../java/org/hibernate/type/LongType.java | 4 +-- .../java/org/hibernate/type/ShortType.java | 2 +- .../org/hibernate/ejb/AbstractQueryImpl.java | 2 +- .../org/hibernate/ejb/Ejb3Configuration.java | 2 +- 28 files changed, 83 insertions(+), 83 deletions(-) diff --git a/hibernate-c3p0/src/main/java/org/hibernate/service/jdbc/connections/internal/C3P0ConnectionProvider.java b/hibernate-c3p0/src/main/java/org/hibernate/service/jdbc/connections/internal/C3P0ConnectionProvider.java index 49a8c3f30c..12dc31e2ae 100644 --- a/hibernate-c3p0/src/main/java/org/hibernate/service/jdbc/connections/internal/C3P0ConnectionProvider.java +++ b/hibernate-c3p0/src/main/java/org/hibernate/service/jdbc/connections/internal/C3P0ConnectionProvider.java @@ -212,8 +212,8 @@ public class C3P0ConnectionProvider implements ConnectionProvider, Configurable, String i = (String) props.get( Environment.ISOLATION ); if (i == null) isolation = null; else { - isolation = new Integer( i ); - LOG.jdbcIsolationLevel(Environment.isolationLevelToString(isolation.intValue())); + isolation = Integer.valueOf( i ); + LOG.jdbcIsolationLevel(Environment.isolationLevelToString(isolation)); } } diff --git a/hibernate-core/src/main/java/org/hibernate/bytecode/instrumentation/internal/javassist/FieldInterceptorImpl.java b/hibernate-core/src/main/java/org/hibernate/bytecode/instrumentation/internal/javassist/FieldInterceptorImpl.java index 8407b62715..c593a53e75 100644 --- a/hibernate-core/src/main/java/org/hibernate/bytecode/instrumentation/internal/javassist/FieldInterceptorImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/bytecode/instrumentation/internal/javassist/FieldInterceptorImpl.java @@ -57,7 +57,7 @@ public final class FieldInterceptorImpl extends AbstractFieldInterceptor impleme // FieldHandler impl ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ public boolean readBoolean(Object target, String name, boolean oldValue) { - return ( ( Boolean ) intercept( target, name, oldValue ? Boolean.TRUE : Boolean.FALSE ) ) + return ( ( Boolean ) intercept( target, name, oldValue ) ) .booleanValue(); } @@ -107,7 +107,7 @@ public final class FieldInterceptorImpl extends AbstractFieldInterceptor impleme public boolean writeBoolean(Object target, String name, boolean oldValue, boolean newValue) { dirty(); - intercept( target, name, oldValue ? Boolean.TRUE : Boolean.FALSE ); + intercept( target, name, oldValue ); return newValue; } diff --git a/hibernate-core/src/main/java/org/hibernate/bytecode/internal/javassist/ProxyFactoryFactoryImpl.java b/hibernate-core/src/main/java/org/hibernate/bytecode/internal/javassist/ProxyFactoryFactoryImpl.java index 5fce7a5887..73db828ef9 100644 --- a/hibernate-core/src/main/java/org/hibernate/bytecode/internal/javassist/ProxyFactoryFactoryImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/bytecode/internal/javassist/ProxyFactoryFactoryImpl.java @@ -118,10 +118,10 @@ public class ProxyFactoryFactoryImpl implements ProxyFactoryFactory { return proxiedClassName + "@" + System.identityHashCode( object ); } else if ( "equals".equals( name ) ) { - return proxiedObject == object ? Boolean.TRUE : Boolean.FALSE; + return proxiedObject == object; } else if ( "hashCode".equals( name ) ) { - return new Integer( System.identityHashCode( object ) ); + return System.identityHashCode( object ); } boolean hasGetterSignature = method.getParameterTypes().length == 0 && method.getReturnType() != null; boolean hasSetterSignature = method.getParameterTypes().length == 1 && ( method.getReturnType() == null || method.getReturnType() == void.class ); diff --git a/hibernate-core/src/main/java/org/hibernate/cache/internal/StandardQueryCache.java b/hibernate-core/src/main/java/org/hibernate/cache/internal/StandardQueryCache.java index a36089f41a..c80e8853ba 100644 --- a/hibernate-core/src/main/java/org/hibernate/cache/internal/StandardQueryCache.java +++ b/hibernate-core/src/main/java/org/hibernate/cache/internal/StandardQueryCache.java @@ -91,7 +91,7 @@ public class StandardQueryCache implements QueryCache { boolean isNaturalKeyLookup, SessionImplementor session) throws HibernateException { if (isNaturalKeyLookup && result.size() == 0) return false; - Long ts = new Long(session.getFactory().getSettings().getRegionFactory().nextTimestamp()); + Long ts = session.getFactory().getSettings().getRegionFactory().nextTimestamp(); LOG.debugf( "Caching query results in region: %s; timestamp=%s", cacheRegion.getName(), ts ); diff --git a/hibernate-core/src/main/java/org/hibernate/cache/spi/UpdateTimestampsCache.java b/hibernate-core/src/main/java/org/hibernate/cache/spi/UpdateTimestampsCache.java index c8d21999e4..6b47692f6b 100644 --- a/hibernate-core/src/main/java/org/hibernate/cache/spi/UpdateTimestampsCache.java +++ b/hibernate-core/src/main/java/org/hibernate/cache/spi/UpdateTimestampsCache.java @@ -73,7 +73,7 @@ public class UpdateTimestampsCache { readWriteLock.writeLock().lock(); try { - Long ts = new Long( region.nextTimestamp() + region.getTimeout() ); + Long ts = region.nextTimestamp() + region.getTimeout(); for ( Serializable space : spaces ) { LOG.debugf( "Pre-invalidating space [%s]", space ); //put() has nowait semantics, is this really appropriate? @@ -94,7 +94,7 @@ public class UpdateTimestampsCache { readWriteLock.writeLock().lock(); try { - Long ts = new Long( region.nextTimestamp() ); + Long ts = region.nextTimestamp(); for (Serializable space : spaces) { LOG.debugf( "Invalidating space [%s], timestamp: %s", space, ts ); //put() has nowait semantics, is this really appropriate? diff --git a/hibernate-core/src/main/java/org/hibernate/cache/spi/entry/StructuredCacheEntry.java b/hibernate-core/src/main/java/org/hibernate/cache/spi/entry/StructuredCacheEntry.java index 040bc3ac06..095f91606c 100755 --- a/hibernate-core/src/main/java/org/hibernate/cache/spi/entry/StructuredCacheEntry.java +++ b/hibernate-core/src/main/java/org/hibernate/cache/spi/entry/StructuredCacheEntry.java @@ -61,7 +61,7 @@ public class StructuredCacheEntry implements CacheEntryStructure { Map map = new HashMap(names.length+2); map.put( "_subclass", entry.getSubclass() ); map.put( "_version", entry.getVersion() ); - map.put( "_lazyPropertiesUnfetched", entry.areLazyPropertiesUnfetched() ? Boolean.TRUE : Boolean.FALSE ); + map.put( "_lazyPropertiesUnfetched", entry.areLazyPropertiesUnfetched() ); for ( int i=0; i arraySize ) { - for ( int i=arraySize; i list.size() ) { for ( int i=list.size(); i implements TypedQuery { else if ( SPEC_HINT_TIMEOUT.equals( hintName ) ) { // convert milliseconds to seconds int timeout = (int)Math.round(ConfigurationHelper.getInteger( value ).doubleValue() / 1000.0 ); - applyTimeout( new Integer(timeout) ); + applyTimeout( timeout ); } else if ( HINT_COMMENT.equals( hintName ) ) { applyComment( (String) value ); diff --git a/hibernate-entitymanager/src/main/java/org/hibernate/ejb/Ejb3Configuration.java b/hibernate-entitymanager/src/main/java/org/hibernate/ejb/Ejb3Configuration.java index 1144591026..054bac22f4 100644 --- a/hibernate-entitymanager/src/main/java/org/hibernate/ejb/Ejb3Configuration.java +++ b/hibernate-entitymanager/src/main/java/org/hibernate/ejb/Ejb3Configuration.java @@ -660,7 +660,7 @@ public class Ejb3Configuration implements Serializable, Referenceable { } if ( ! overridenDatasource && ( info.getJtaDataSource() != null || info.getNonJtaDataSource() != null ) ) { - isJTA = info.getJtaDataSource() != null ? Boolean.TRUE : Boolean.FALSE; + isJTA = info.getJtaDataSource() != null; this.setDataSource( isJTA ? info.getJtaDataSource() : info.getNonJtaDataSource() );