HHH-6791 tiny improvement, in favor of java auto-box instead of create new instance

This commit is contained in:
Strong Liu 2011-11-02 14:16:02 +08:00
parent 388ceaf186
commit bec88716d6
28 changed files with 83 additions and 83 deletions

View File

@ -212,8 +212,8 @@ public class C3P0ConnectionProvider implements ConnectionProvider, Configurable,
String i = (String) props.get( Environment.ISOLATION ); String i = (String) props.get( Environment.ISOLATION );
if (i == null) isolation = null; if (i == null) isolation = null;
else { else {
isolation = new Integer( i ); isolation = Integer.valueOf( i );
LOG.jdbcIsolationLevel(Environment.isolationLevelToString(isolation.intValue())); LOG.jdbcIsolationLevel(Environment.isolationLevelToString(isolation));
} }
} }

View File

@ -57,7 +57,7 @@ public final class FieldInterceptorImpl extends AbstractFieldInterceptor impleme
// FieldHandler impl ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // FieldHandler impl ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
public boolean readBoolean(Object target, String name, boolean oldValue) { 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(); .booleanValue();
} }
@ -107,7 +107,7 @@ public final class FieldInterceptorImpl extends AbstractFieldInterceptor impleme
public boolean writeBoolean(Object target, String name, boolean oldValue, boolean newValue) { public boolean writeBoolean(Object target, String name, boolean oldValue, boolean newValue) {
dirty(); dirty();
intercept( target, name, oldValue ? Boolean.TRUE : Boolean.FALSE ); intercept( target, name, oldValue );
return newValue; return newValue;
} }

View File

@ -118,10 +118,10 @@ public class ProxyFactoryFactoryImpl implements ProxyFactoryFactory {
return proxiedClassName + "@" + System.identityHashCode( object ); return proxiedClassName + "@" + System.identityHashCode( object );
} }
else if ( "equals".equals( name ) ) { else if ( "equals".equals( name ) ) {
return proxiedObject == object ? Boolean.TRUE : Boolean.FALSE; return proxiedObject == object;
} }
else if ( "hashCode".equals( name ) ) { 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 hasGetterSignature = method.getParameterTypes().length == 0 && method.getReturnType() != null;
boolean hasSetterSignature = method.getParameterTypes().length == 1 && ( method.getReturnType() == null || method.getReturnType() == void.class ); boolean hasSetterSignature = method.getParameterTypes().length == 1 && ( method.getReturnType() == null || method.getReturnType() == void.class );

View File

@ -91,7 +91,7 @@ public class StandardQueryCache implements QueryCache {
boolean isNaturalKeyLookup, boolean isNaturalKeyLookup,
SessionImplementor session) throws HibernateException { SessionImplementor session) throws HibernateException {
if (isNaturalKeyLookup && result.size() == 0) return false; 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 ); LOG.debugf( "Caching query results in region: %s; timestamp=%s", cacheRegion.getName(), ts );

View File

@ -73,7 +73,7 @@ public class UpdateTimestampsCache {
readWriteLock.writeLock().lock(); readWriteLock.writeLock().lock();
try { try {
Long ts = new Long( region.nextTimestamp() + region.getTimeout() ); Long ts = region.nextTimestamp() + region.getTimeout();
for ( Serializable space : spaces ) { for ( Serializable space : spaces ) {
LOG.debugf( "Pre-invalidating space [%s]", space ); LOG.debugf( "Pre-invalidating space [%s]", space );
//put() has nowait semantics, is this really appropriate? //put() has nowait semantics, is this really appropriate?
@ -94,7 +94,7 @@ public class UpdateTimestampsCache {
readWriteLock.writeLock().lock(); readWriteLock.writeLock().lock();
try { try {
Long ts = new Long( region.nextTimestamp() ); Long ts = region.nextTimestamp();
for (Serializable space : spaces) { for (Serializable space : spaces) {
LOG.debugf( "Invalidating space [%s], timestamp: %s", space, ts ); LOG.debugf( "Invalidating space [%s], timestamp: %s", space, ts );
//put() has nowait semantics, is this really appropriate? //put() has nowait semantics, is this really appropriate?

View File

@ -61,7 +61,7 @@ public class StructuredCacheEntry implements CacheEntryStructure {
Map map = new HashMap(names.length+2); Map map = new HashMap(names.length+2);
map.put( "_subclass", entry.getSubclass() ); map.put( "_subclass", entry.getSubclass() );
map.put( "_version", entry.getVersion() ); map.put( "_version", entry.getVersion() );
map.put( "_lazyPropertiesUnfetched", entry.areLazyPropertiesUnfetched() ? Boolean.TRUE : Boolean.FALSE ); map.put( "_lazyPropertiesUnfetched", entry.areLazyPropertiesUnfetched() );
for ( int i=0; i<names.length; i++ ) { for ( int i=0; i<names.length; i++ ) {
map.put( names[i], entry.getDisassembledState()[i] ); map.put( names[i], entry.getDisassembledState()[i] );
} }

View File

@ -2643,9 +2643,9 @@ public final class HbmBinder {
boolean cacheable = "true".equals( queryElem.attributeValue( "cacheable" ) ); boolean cacheable = "true".equals( queryElem.attributeValue( "cacheable" ) );
String region = queryElem.attributeValue( "cache-region" ); String region = queryElem.attributeValue( "cache-region" );
Attribute tAtt = queryElem.attribute( "timeout" ); Attribute tAtt = queryElem.attribute( "timeout" );
Integer timeout = tAtt == null ? null : new Integer( tAtt.getValue() ); Integer timeout = tAtt == null ? null : Integer.valueOf( tAtt.getValue() );
Attribute fsAtt = queryElem.attribute( "fetch-size" ); Attribute fsAtt = queryElem.attribute( "fetch-size" );
Integer fetchSize = fsAtt == null ? null : new Integer( fsAtt.getValue() ); Integer fetchSize = fsAtt == null ? null : Integer.valueOf( fsAtt.getValue() );
Attribute roAttr = queryElem.attribute( "read-only" ); Attribute roAttr = queryElem.attribute( "read-only" );
boolean readOnly = roAttr != null && "true".equals( roAttr.getValue() ); boolean readOnly = roAttr != null && "true".equals( roAttr.getValue() );
Attribute cacheModeAtt = queryElem.attribute( "cache-mode" ); Attribute cacheModeAtt = queryElem.attribute( "cache-mode" );

View File

@ -62,9 +62,9 @@ public class NamedSQLQuerySecondPass extends ResultSetMappingBinder implements Q
boolean cacheable = "true".equals( queryElem.attributeValue( "cacheable" ) ); boolean cacheable = "true".equals( queryElem.attributeValue( "cacheable" ) );
String region = queryElem.attributeValue( "cache-region" ); String region = queryElem.attributeValue( "cache-region" );
Attribute tAtt = queryElem.attribute( "timeout" ); Attribute tAtt = queryElem.attribute( "timeout" );
Integer timeout = tAtt == null ? null : new Integer( tAtt.getValue() ); Integer timeout = tAtt == null ? null : Integer.valueOf( tAtt.getValue() );
Attribute fsAtt = queryElem.attribute( "fetch-size" ); Attribute fsAtt = queryElem.attribute( "fetch-size" );
Integer fetchSize = fsAtt == null ? null : new Integer( fsAtt.getValue() ); Integer fetchSize = fsAtt == null ? null : Integer.valueOf( fsAtt.getValue() );
Attribute roAttr = queryElem.attribute( "read-only" ); Attribute roAttr = queryElem.attribute( "read-only" );
boolean readOnly = roAttr != null && "true".equals( roAttr.getValue() ); boolean readOnly = roAttr != null && "true".equals( roAttr.getValue() );
Attribute cacheModeAtt = queryElem.attribute( "cache-mode" ); Attribute cacheModeAtt = queryElem.attribute( "cache-mode" );

View File

@ -211,14 +211,14 @@ public class PersistentArrayHolder extends AbstractPersistentCollection {
int arraySize = Array.getLength(array); int arraySize = Array.getLength(array);
int end; int end;
if ( snSize > arraySize ) { if ( snSize > arraySize ) {
for ( int i=arraySize; i<snSize; i++ ) deletes.add( new Integer(i) ); for ( int i=arraySize; i<snSize; i++ ) deletes.add( i );
end = arraySize; end = arraySize;
} }
else { else {
end = snSize; end = snSize;
} }
for ( int i=0; i<end; i++ ) { for ( int i=0; i<end; i++ ) {
if ( Array.get(array, i)==null && Array.get(sn, i)!=null ) deletes.add( new Integer(i) ); if ( Array.get(array, i)==null && Array.get(sn, i)!=null ) deletes.add( i );
} }
return deletes.iterator(); return deletes.iterator();
} }
@ -237,7 +237,7 @@ public class PersistentArrayHolder extends AbstractPersistentCollection {
} }
public Object getIndex(Object entry, int i, CollectionPersister persister) { public Object getIndex(Object entry, int i, CollectionPersister persister) {
return new Integer(i); return i;
} }
public Object getElement(Object entry) { public Object getElement(Object entry) {

View File

@ -87,7 +87,7 @@ public class PersistentIdentifierBag extends AbstractPersistentCollection implem
beforeInitialize( persister, size ); beforeInitialize( persister, size );
for ( int i = 0; i < size; i+=2 ) { for ( int i = 0; i < size; i+=2 ) {
identifiers.put( identifiers.put(
new Integer(i/2), (i/2),
persister.getIdentifierType().assemble( array[i], getSession(), owner ) persister.getIdentifierType().assemble( array[i], getSession(), owner )
); );
values.add( persister.getElementType().assemble( array[i+1], getSession(), owner ) ); values.add( persister.getElementType().assemble( array[i+1], getSession(), owner ) );
@ -95,7 +95,7 @@ public class PersistentIdentifierBag extends AbstractPersistentCollection implem
} }
public Object getIdentifier(Object entry, int i) { public Object getIdentifier(Object entry, int i) {
return identifiers.get( new Integer(i) ); return identifiers.get( i );
} }
public boolean isWrapper(Object collection) { public boolean isWrapper(Object collection) {
@ -200,7 +200,7 @@ public class PersistentIdentifierBag extends AbstractPersistentCollection implem
int i=0; int i=0;
for (int j=0; j< values.size(); j++) { for (int j=0; j< values.size(); j++) {
Object value = values.get(j); Object value = values.get(j);
result[i++] = persister.getIdentifierType().disassemble( identifiers.get( new Integer(j) ), getSession(), null ); result[i++] = persister.getIdentifierType().disassemble( identifiers.get( j ), getSession(), null );
result[i++] = persister.getElementType().disassemble( value, getSession(), null ); result[i++] = persister.getElementType().disassemble( value, getSession(), null );
} }
return result; return result;
@ -224,7 +224,7 @@ public class PersistentIdentifierBag extends AbstractPersistentCollection implem
if ( snap.size()!= values.size() ) return false; if ( snap.size()!= values.size() ) return false;
for ( int i=0; i<values.size(); i++ ) { for ( int i=0; i<values.size(); i++ ) {
Object value = values.get(i); Object value = values.get(i);
Object id = identifiers.get( new Integer(i) ); Object id = identifiers.get( i );
if (id==null) return false; if (id==null) return false;
Object old = snap.get(id); Object old = snap.get(id);
if ( elementType.isDirty( old, value, getSession() ) ) return false; if ( elementType.isDirty( old, value, getSession() ) ) return false;
@ -240,7 +240,7 @@ public class PersistentIdentifierBag extends AbstractPersistentCollection implem
Map snap = (Map) getSnapshot(); Map snap = (Map) getSnapshot();
List deletes = new ArrayList( snap.keySet() ); List deletes = new ArrayList( snap.keySet() );
for ( int i=0; i<values.size(); i++ ) { for ( int i=0; i<values.size(); i++ ) {
if ( values.get(i)!=null ) deletes.remove( identifiers.get( new Integer(i) ) ); if ( values.get(i)!=null ) deletes.remove( identifiers.get( i ) );
} }
return deletes.iterator(); return deletes.iterator();
} }
@ -255,7 +255,7 @@ public class PersistentIdentifierBag extends AbstractPersistentCollection implem
public Object getSnapshotElement(Object entry, int i) { public Object getSnapshotElement(Object entry, int i) {
Map snap = (Map) getSnapshot(); Map snap = (Map) getSnapshot();
Object id = identifiers.get( new Integer(i) ); Object id = identifiers.get( i );
return snap.get(id); return snap.get(id);
} }
@ -263,7 +263,7 @@ public class PersistentIdentifierBag extends AbstractPersistentCollection implem
throws HibernateException { throws HibernateException {
Map snap = (Map) getSnapshot(); Map snap = (Map) getSnapshot();
Object id = identifiers.get( new Integer(i) ); Object id = identifiers.get( i );
return entry!=null && ( id==null || snap.get(id)==null ); return entry!=null && ( id==null || snap.get(id)==null );
} }
@ -271,7 +271,7 @@ public class PersistentIdentifierBag extends AbstractPersistentCollection implem
if (entry==null) return false; if (entry==null) return false;
Map snap = (Map) getSnapshot(); Map snap = (Map) getSnapshot();
Object id = identifiers.get( new Integer(i) ); Object id = identifiers.get( i );
if (id==null) return false; if (id==null) return false;
Object old = snap.get(id); Object old = snap.get(id);
return old!=null && elemType.isDirty( old, entry, getSession() ); return old!=null && elemType.isDirty( old, entry, getSession() );
@ -287,7 +287,7 @@ public class PersistentIdentifierBag extends AbstractPersistentCollection implem
Object element = persister.readElement( rs, owner, descriptor.getSuffixedElementAliases(), getSession() ); Object element = persister.readElement( rs, owner, descriptor.getSuffixedElementAliases(), getSession() );
Object old = identifiers.put( Object old = identifiers.put(
new Integer( values.size() ), values.size(),
persister.readIdentifier( rs, descriptor.getSuffixedIdentifierAlias(), getSession() ) persister.readIdentifier( rs, descriptor.getSuffixedIdentifierAlias(), getSession() )
); );
if ( old==null ) values.add(element); //maintain correct duplication if loaded in a cartesian product if ( old==null ) values.add(element); //maintain correct duplication if loaded in a cartesian product
@ -301,7 +301,7 @@ public class PersistentIdentifierBag extends AbstractPersistentCollection implem
while ( iter.hasNext() ) { while ( iter.hasNext() ) {
Object value = iter.next(); Object value = iter.next();
map.put( map.put(
identifiers.get( new Integer(i++) ), identifiers.get( i++ ),
persister.getElementType().deepCopy(value, persister.getFactory()) persister.getElementType().deepCopy(value, persister.getFactory())
); );
} }
@ -318,7 +318,7 @@ public class PersistentIdentifierBag extends AbstractPersistentCollection implem
int i=0; int i=0;
while ( iter.hasNext() ) { while ( iter.hasNext() ) {
Object entry = iter.next(); Object entry = iter.next();
Integer loc = new Integer(i++); Integer loc = i++;
if ( !identifiers.containsKey(loc) ) { //TODO: native ids if ( !identifiers.containsKey(loc) ) { //TODO: native ids
Serializable id = persister.getIdentifierGenerator().generate( getSession(), entry ); Serializable id = persister.getIdentifierGenerator().generate( getSession(), entry );
identifiers.put(loc, id); identifiers.put(loc, id);
@ -371,25 +371,25 @@ public class PersistentIdentifierBag extends AbstractPersistentCollection implem
} }
private void beforeRemove(int index) { private void beforeRemove(int index) {
Object removedId = identifiers.get( new Integer(index) ); Object removedId = identifiers.get( index );
int last = values.size()-1; int last = values.size()-1;
for ( int i=index; i<last; i++ ) { for ( int i=index; i<last; i++ ) {
Object id = identifiers.get( new Integer(i+1) ); Object id = identifiers.get( i+1 );
if ( id==null ) { if ( id==null ) {
identifiers.remove( new Integer(i) ); identifiers.remove( i );
} }
else { else {
identifiers.put( new Integer(i), id ); identifiers.put( i, id );
} }
} }
identifiers.put( new Integer(last), removedId ); identifiers.put( last, removedId );
} }
private void beforeAdd(int index) { private void beforeAdd(int index) {
for ( int i=index; i<values.size(); i++ ) { for ( int i=index; i<values.size(); i++ ) {
identifiers.put( new Integer(i+1), identifiers.get( new Integer(i) ) ); identifiers.put( i+1, identifiers.get( i ) );
} }
identifiers.remove( new Integer(index) ); identifiers.remove( index );
} }
public Object remove(int index) { public Object remove(int index) {

View File

@ -290,7 +290,7 @@ public class PersistentList extends AbstractPersistentCollection implements List
if (index<0) { if (index<0) {
throw new ArrayIndexOutOfBoundsException("negative index"); throw new ArrayIndexOutOfBoundsException("negative index");
} }
Object result = readElementByIndex( new Integer(index) ); Object result = readElementByIndex( index );
return result==UNKNOWN ? list.get(index) : result; return result==UNKNOWN ? list.get(index) : result;
} }
@ -301,7 +301,7 @@ public class PersistentList extends AbstractPersistentCollection implements List
if (index<0) { if (index<0) {
throw new ArrayIndexOutOfBoundsException("negative index"); throw new ArrayIndexOutOfBoundsException("negative index");
} }
Object old = isPutQueueEnabled() ? readElementByIndex( new Integer(index) ) : UNKNOWN; Object old = isPutQueueEnabled() ? readElementByIndex( index ) : UNKNOWN;
if ( old==UNKNOWN ) { if ( old==UNKNOWN ) {
write(); write();
return list.set(index, value); return list.set(index, value);
@ -336,7 +336,7 @@ public class PersistentList extends AbstractPersistentCollection implements List
throw new ArrayIndexOutOfBoundsException("negative index"); throw new ArrayIndexOutOfBoundsException("negative index");
} }
Object old = isPutQueueEnabled() ? Object old = isPutQueueEnabled() ?
readElementByIndex( new Integer(index) ) : UNKNOWN; readElementByIndex( index ) : UNKNOWN;
if ( old==UNKNOWN ) { if ( old==UNKNOWN ) {
write(); write();
return list.remove(index); return list.remove(index);
@ -442,7 +442,7 @@ public class PersistentList extends AbstractPersistentCollection implements List
int end; int end;
if ( sn.size() > list.size() ) { if ( sn.size() > list.size() ) {
for ( int i=list.size(); i<sn.size(); i++ ) { for ( int i=list.size(); i<sn.size(); i++ ) {
deletes.add( indexIsFormula ? sn.get(i) : new Integer(i) ); deletes.add( indexIsFormula ? sn.get(i) : i );
} }
end = list.size(); end = list.size();
} }
@ -451,7 +451,7 @@ public class PersistentList extends AbstractPersistentCollection implements List
} }
for ( int i=0; i<end; i++ ) { for ( int i=0; i<end; i++ ) {
if ( list.get(i)==null && sn.get(i)!=null ) { if ( list.get(i)==null && sn.get(i)!=null ) {
deletes.add( indexIsFormula ? sn.get(i) : new Integer(i) ); deletes.add( indexIsFormula ? sn.get(i) : i );
} }
} }
return deletes.iterator(); return deletes.iterator();
@ -469,7 +469,7 @@ public class PersistentList extends AbstractPersistentCollection implements List
} }
public Object getIndex(Object entry, int i, CollectionPersister persister) { public Object getIndex(Object entry, int i, CollectionPersister persister) {
return new Integer(i); return i;
} }
public Object getElement(Object entry) { public Object getElement(Object entry) {

View File

@ -147,7 +147,7 @@ public class BlobProxy implements InvocationHandler {
return Boolean.valueOf( proxy == args[0] ); return Boolean.valueOf( proxy == args[0] );
} }
if ( "hashCode".equals( methodName ) && argCount == 0 ) { if ( "hashCode".equals( methodName ) && argCount == 0 ) {
return new Integer( this.hashCode() ); return this.hashCode();
} }
throw new UnsupportedOperationException( "Blob may not be manipulated from creating session" ); throw new UnsupportedOperationException( "Blob may not be manipulated from creating session" );

View File

@ -162,7 +162,7 @@ public class ClobProxy implements InvocationHandler {
return Boolean.valueOf( proxy == args[0] ); return Boolean.valueOf( proxy == args[0] );
} }
if ( "hashCode".equals( methodName ) && argCount == 0 ) { if ( "hashCode".equals( methodName ) && argCount == 0 ) {
return new Integer( this.hashCode() ); return this.hashCode();
} }
throw new UnsupportedOperationException( "Clob may not be manipulated from creating session" ); throw new UnsupportedOperationException( "Clob may not be manipulated from creating session" );

View File

@ -104,7 +104,7 @@ public class ParameterParser {
String param = sqlString.substring( indx + 1, chopLocation ); String param = sqlString.substring( indx + 1, chopLocation );
// make sure this "name" is an integral // make sure this "name" is an integral
try { try {
new Integer( param ); Integer.valueOf( param );
} }
catch( NumberFormatException e ) { catch( NumberFormatException e ) {
throw new QueryException( "JPA-style positional param was not an integral ordinal" ); throw new QueryException( "JPA-style positional param was not an integral ordinal" );

View File

@ -265,7 +265,7 @@ public class QueryPlanCache implements Serializable {
final String key = (String) entry.getKey(); final String key = (String) entry.getKey();
final Integer valueCount; final Integer valueCount;
if ( Collection.class.isInstance( entry.getValue() ) ) { if ( Collection.class.isInstance( entry.getValue() ) ) {
valueCount = new Integer( ( (Collection) entry.getValue() ).size() ); valueCount = ( (Collection) entry.getValue() ).size();
} }
else { else {
valueCount = 1; valueCount = 1;

View File

@ -42,7 +42,7 @@ public class BooleanLiteralNode extends LiteralNode implements ExpectedTypeAware
} }
public Boolean getValue() { public Boolean getValue() {
return getType() == TRUE ? Boolean.TRUE : Boolean.FALSE; return getType() == TRUE ;
} }
@Override @Override

View File

@ -133,7 +133,7 @@ public class ASTPrinter {
* or just the integer as a string if none exists. * or just the integer as a string if none exists.
*/ */
public String getTokenTypeName(int type) { public String getTokenTypeName(int type) {
final Integer typeInteger = new Integer( type ); final Integer typeInteger = type;
String value = null; String value = null;
if ( tokenTypeNameCache != null ) { if ( tokenTypeNameCache != null ) {
value = ( String ) tokenTypeNameCache.get( typeInteger ); value = ( String ) tokenTypeNameCache.get( typeInteger );

View File

@ -448,11 +448,11 @@ public final class ASTUtil {
rtn = ( Integer ) value; rtn = ( Integer ) value;
} }
else if ( value instanceof Short ) { else if ( value instanceof Short ) {
rtn = new Integer( ( ( Short ) value ).intValue() ); rtn = ( ( Short ) value ).intValue();
} }
else if ( value instanceof Long ) { else if ( value instanceof Long ) {
if ( ( ( Long ) value ).longValue() <= Integer.MAX_VALUE ) { if ( ( ( Long ) value ).longValue() <= Integer.MAX_VALUE ) {
rtn = new Integer( ( ( Long ) value ).intValue() ); rtn = ( ( Long ) value ).intValue();
} }
} }
} }

View File

@ -114,13 +114,13 @@ public final class IdentifierGeneratorHelper {
Class clazz = type.getReturnedClass(); Class clazz = type.getReturnedClass();
if ( clazz == Long.class ) { if ( clazz == Long.class ) {
return new Long( rs.getLong( 1 ) ); return rs.getLong( 1 );
} }
else if ( clazz == Integer.class ) { else if ( clazz == Integer.class ) {
return new Integer( rs.getInt( 1 ) ); return rs.getInt( 1 );
} }
else if ( clazz == Short.class ) { else if ( clazz == Short.class ) {
return new Short( rs.getShort( 1 ) ); return rs.getShort( 1 );
} }
else if ( clazz == String.class ) { else if ( clazz == String.class ) {
return rs.getString( 1 ); return rs.getString( 1 );
@ -153,13 +153,13 @@ public final class IdentifierGeneratorHelper {
@Deprecated @Deprecated
public static Number createNumber(long value, Class clazz) throws IdentifierGenerationException { public static Number createNumber(long value, Class clazz) throws IdentifierGenerationException {
if ( clazz == Long.class ) { if ( clazz == Long.class ) {
return new Long( value ); return value;
} }
else if ( clazz == Integer.class ) { else if ( clazz == Integer.class ) {
return new Integer( ( int ) value ); return ( int ) value;
} }
else if ( clazz == Short.class ) { else if ( clazz == Short.class ) {
return new Short( ( short ) value ); return ( short ) value;
} }
else { else {
throw new IdentifierGenerationException( "unrecognized id type : " + clazz.getName() ); throw new IdentifierGenerationException( "unrecognized id type : " + clazz.getName() );
@ -345,13 +345,13 @@ public final class IdentifierGeneratorHelper {
// TODO : should we check for truncation? // TODO : should we check for truncation?
checkInitialized(); checkInitialized();
if ( exactType == Long.class ) { if ( exactType == Long.class ) {
return new Long( value ); return value;
} }
else if ( exactType == Integer.class ) { else if ( exactType == Integer.class ) {
return new Integer( ( int ) value ); return ( int ) value;
} }
else { else {
return new Short( ( short ) value ); return ( short ) value;
} }
} }

View File

@ -511,39 +511,39 @@ public abstract class AbstractQueryImpl implements Query {
} }
public Query setBoolean(int position, boolean val) { public Query setBoolean(int position, boolean val) {
Boolean valueToUse = val ? Boolean.TRUE : Boolean.FALSE; Boolean valueToUse = val;
Type typeToUse = determineType( position, valueToUse, StandardBasicTypes.BOOLEAN ); Type typeToUse = determineType( position, valueToUse, StandardBasicTypes.BOOLEAN );
setParameter( position, valueToUse, typeToUse ); setParameter( position, valueToUse, typeToUse );
return this; return this;
} }
public Query setByte(int position, byte val) { public Query setByte(int position, byte val) {
setParameter(position, new Byte(val), StandardBasicTypes.BYTE); setParameter(position, val, StandardBasicTypes.BYTE);
return this; return this;
} }
public Query setShort(int position, short val) { public Query setShort(int position, short val) {
setParameter(position, new Short(val), StandardBasicTypes.SHORT); setParameter(position, val, StandardBasicTypes.SHORT);
return this; return this;
} }
public Query setInteger(int position, int val) { public Query setInteger(int position, int val) {
setParameter(position, new Integer(val), StandardBasicTypes.INTEGER); setParameter(position, val, StandardBasicTypes.INTEGER);
return this; return this;
} }
public Query setLong(int position, long val) { public Query setLong(int position, long val) {
setParameter(position, new Long(val), StandardBasicTypes.LONG); setParameter(position, val, StandardBasicTypes.LONG);
return this; return this;
} }
public Query setFloat(int position, float val) { public Query setFloat(int position, float val) {
setParameter(position, new Float(val), StandardBasicTypes.FLOAT); setParameter(position, val, StandardBasicTypes.FLOAT);
return this; return this;
} }
public Query setDouble(int position, double val) { public Query setDouble(int position, double val) {
setParameter(position, new Double(val), StandardBasicTypes.DOUBLE); setParameter(position, val, StandardBasicTypes.DOUBLE);
return this; return this;
} }
@ -615,19 +615,19 @@ public abstract class AbstractQueryImpl implements Query {
} }
public Query setBoolean(String name, boolean val) { public Query setBoolean(String name, boolean val) {
Boolean valueToUse = val ? Boolean.TRUE : Boolean.FALSE; Boolean valueToUse = val;
Type typeToUse = determineType( name, valueToUse, StandardBasicTypes.BOOLEAN ); Type typeToUse = determineType( name, valueToUse, StandardBasicTypes.BOOLEAN );
setParameter( name, valueToUse, typeToUse ); setParameter( name, valueToUse, typeToUse );
return this; return this;
} }
public Query setByte(String name, byte val) { public Query setByte(String name, byte val) {
setParameter(name, new Byte(val), StandardBasicTypes.BYTE); setParameter(name, val, StandardBasicTypes.BYTE);
return this; return this;
} }
public Query setCharacter(String name, char val) { public Query setCharacter(String name, char val) {
setParameter(name, new Character(val), StandardBasicTypes.CHARACTER); setParameter(name, val, StandardBasicTypes.CHARACTER);
return this; return this;
} }
@ -637,7 +637,7 @@ public abstract class AbstractQueryImpl implements Query {
} }
public Query setDouble(String name, double val) { public Query setDouble(String name, double val) {
setParameter(name, new Double(val), StandardBasicTypes.DOUBLE); setParameter(name, val, StandardBasicTypes.DOUBLE);
return this; return this;
} }
@ -647,12 +647,12 @@ public abstract class AbstractQueryImpl implements Query {
} }
public Query setFloat(String name, float val) { public Query setFloat(String name, float val) {
setParameter(name, new Float(val), StandardBasicTypes.FLOAT); setParameter(name, val, StandardBasicTypes.FLOAT);
return this; return this;
} }
public Query setInteger(String name, int val) { public Query setInteger(String name, int val) {
setParameter(name, new Integer(val), StandardBasicTypes.INTEGER); setParameter(name, val, StandardBasicTypes.INTEGER);
return this; return this;
} }
@ -672,7 +672,7 @@ public abstract class AbstractQueryImpl implements Query {
} }
public Query setLong(String name, long val) { public Query setLong(String name, long val) {
setParameter(name, new Long(val), StandardBasicTypes.LONG); setParameter(name, val, StandardBasicTypes.LONG);
return this; return this;
} }
@ -682,7 +682,7 @@ public abstract class AbstractQueryImpl implements Query {
} }
public Query setShort(String name, short val) { public Query setShort(String name, short val) {
setParameter(name, new Short(val), StandardBasicTypes.SHORT); setParameter(name, val, StandardBasicTypes.SHORT);
return this; return this;
} }

View File

@ -104,7 +104,7 @@ public class FetchingScrollableResultsImpl extends AbstractScrollableResults {
if ( afterLast ) { if ( afterLast ) {
if ( maxPosition == null ) { if ( maxPosition == null ) {
// we just hit the last position // we just hit the last position
maxPosition = new Integer( currentPosition ); maxPosition = currentPosition;
} }
} }

View File

@ -771,7 +771,7 @@ public abstract class AbstractCollectionPersister
protected Object decrementIndexByBase(Object index) { protected Object decrementIndexByBase(Object index) {
if ( baseIndex != 0 ) { if ( baseIndex != 0 ) {
index = new Integer( ( (Integer) index ).intValue() - baseIndex ); index = (Integer)index - baseIndex;
} }
return index; return index;
} }
@ -824,7 +824,7 @@ public abstract class AbstractCollectionPersister
protected Object incrementIndexByBase(Object index) { protected Object incrementIndexByBase(Object index) {
if ( baseIndex != 0 ) { if ( baseIndex != 0 ) {
index = new Integer( ( (Integer) index ).intValue() + baseIndex ); index = (Integer)index + baseIndex;
} }
return index; return index;
} }

View File

@ -88,7 +88,7 @@ public abstract class BasicLazyInitializer extends AbstractLazyInitializer {
} }
else if ( params==1 ) { else if ( params==1 ) {
if ( !overridesEquals && "equals".equals(methodName) ) { if ( !overridesEquals && "equals".equals(methodName) ) {
return args[0]==proxy ? Boolean.TRUE : Boolean.FALSE; return args[0]==proxy;
} }
else if ( method.equals(setIdentifierMethod) ) { else if ( method.equals(setIdentifierMethod) ) {
initialize(); initialize();

View File

@ -44,7 +44,7 @@ public class ByteType
public static final ByteType INSTANCE = new ByteType(); public static final ByteType INSTANCE = new ByteType();
private static final Byte ZERO = new Byte( (byte) 0 ); private static final Byte ZERO = Byte.valueOf( (byte)0 );
public ByteType() { public ByteType() {
super( TinyIntTypeDescriptor.INSTANCE, ByteTypeDescriptor.INSTANCE ); super( TinyIntTypeDescriptor.INSTANCE, ByteTypeDescriptor.INSTANCE );

View File

@ -68,12 +68,12 @@ public class LongType
} }
public Long stringToObject(String xml) throws Exception { public Long stringToObject(String xml) throws Exception {
return new Long(xml); return Long.valueOf( xml );
} }
@SuppressWarnings({ "UnnecessaryBoxing", "UnnecessaryUnboxing" }) @SuppressWarnings({ "UnnecessaryBoxing", "UnnecessaryUnboxing" })
public Long next(Long current, SessionImplementor session) { public Long next(Long current, SessionImplementor session) {
return Long.valueOf( current.longValue() + 1 ); return current + 1l;
} }
public Long seed(SessionImplementor session) { public Long seed(SessionImplementor session) {

View File

@ -72,7 +72,7 @@ public class ShortType
} }
public Short stringToObject(String xml) throws Exception { public Short stringToObject(String xml) throws Exception {
return new Short(xml); return Short.valueOf( xml );
} }
@SuppressWarnings({ "UnnecessaryBoxing", "UnnecessaryUnboxing" }) @SuppressWarnings({ "UnnecessaryBoxing", "UnnecessaryUnboxing" })

View File

@ -206,7 +206,7 @@ public abstract class AbstractQueryImpl<X> implements TypedQuery<X> {
else if ( SPEC_HINT_TIMEOUT.equals( hintName ) ) { else if ( SPEC_HINT_TIMEOUT.equals( hintName ) ) {
// convert milliseconds to seconds // convert milliseconds to seconds
int timeout = (int)Math.round(ConfigurationHelper.getInteger( value ).doubleValue() / 1000.0 ); int timeout = (int)Math.round(ConfigurationHelper.getInteger( value ).doubleValue() / 1000.0 );
applyTimeout( new Integer(timeout) ); applyTimeout( timeout );
} }
else if ( HINT_COMMENT.equals( hintName ) ) { else if ( HINT_COMMENT.equals( hintName ) ) {
applyComment( (String) value ); applyComment( (String) value );

View File

@ -660,7 +660,7 @@ public class Ejb3Configuration implements Serializable, Referenceable {
} }
if ( ! overridenDatasource && ( info.getJtaDataSource() != null || info.getNonJtaDataSource() != null ) ) { if ( ! overridenDatasource && ( info.getJtaDataSource() != null || info.getNonJtaDataSource() != null ) ) {
isJTA = info.getJtaDataSource() != null ? Boolean.TRUE : Boolean.FALSE; isJTA = info.getJtaDataSource() != null;
this.setDataSource( this.setDataSource(
isJTA ? info.getJtaDataSource() : info.getNonJtaDataSource() isJTA ? info.getJtaDataSource() : info.getNonJtaDataSource()
); );