HHH-9840 Checkstyle fixes

This commit is contained in:
Radim Vansa 2015-06-30 12:42:26 +02:00 committed by Sanne Grinovero
parent cffe71aeba
commit e5f4b616d4
12 changed files with 36 additions and 32 deletions

View File

@ -21,6 +21,8 @@ import org.hibernate.type.Type;
* *
* @author Gavin King * @author Gavin King
* @author Steve Ebersole * @author Steve Ebersole
*
* @deprecated In optimized implementations, wrapping the id is not necessary.
*/ */
@Deprecated @Deprecated
final class OldCacheKeyImplementation implements Serializable { final class OldCacheKeyImplementation implements Serializable {
@ -55,7 +57,7 @@ final class OldCacheKeyImplementation implements Serializable {
} }
private int calculateHashCode(Type type, SessionFactoryImplementor factory) { private int calculateHashCode(Type type, SessionFactoryImplementor factory) {
int result = type.getHashCode(id, factory ); int result = type.getHashCode( id, factory );
result = 31 * result + (tenantId != null ? tenantId.hashCode() : 0); result = 31 * result + (tenantId != null ? tenantId.hashCode() : 0);
return result; return result;
} }
@ -78,7 +80,7 @@ final class OldCacheKeyImplementation implements Serializable {
} }
final OldCacheKeyImplementation that = (OldCacheKeyImplementation) other; final OldCacheKeyImplementation that = (OldCacheKeyImplementation) other;
return EqualsHelper.equals( entityOrRoleName, that.entityOrRoleName ) return EqualsHelper.equals( entityOrRoleName, that.entityOrRoleName )
&& type.isEqual(id, that.id) && type.isEqual( id, that.id)
&& EqualsHelper.equals( tenantId, that.tenantId ); && EqualsHelper.equals( tenantId, that.tenantId );
} }

View File

@ -27,6 +27,8 @@ import org.hibernate.type.Type;
* *
* @author Eric Dalquist * @author Eric Dalquist
* @author Steve Ebersole * @author Steve Ebersole
*
* @deprecated Cache implementation should provide optimized key.
*/ */
@Deprecated @Deprecated
public class OldNaturalIdCacheKey implements Serializable { public class OldNaturalIdCacheKey implements Serializable {

View File

@ -30,7 +30,7 @@ import org.hibernate.persister.entity.EntityPersister;
public interface EntityRegionAccessStrategy extends RegionAccessStrategy { public interface EntityRegionAccessStrategy extends RegionAccessStrategy {
/** /**
* To create instances of EntityCacheKey for this region, Hibernate will invoke this method * To create instances of keys for this region, Hibernate will invoke this method
* exclusively so that generated implementations can generate optimised keys. * exclusively so that generated implementations can generate optimised keys.
* @param id the primary identifier of the entity * @param id the primary identifier of the entity
* @param persister the persister for the type for which a key is being generated * @param persister the persister for the type for which a key is being generated

View File

@ -292,9 +292,7 @@ public class CollectionLoadContext {
if ( debugEnabled ) { if ( debugEnabled ) {
LOG.debug( "Refusing to add to cache due to enabled filters" ); LOG.debug( "Refusing to add to cache due to enabled filters" );
} }
// todo : add the notion of enabled filters to the CacheKey to differentiate filtered collections from non-filtered; // todo : add the notion of enabled filters to the cache key to differentiate filtered collections from non-filtered;
// but CacheKey is currently used for both collections and entities; would ideally need to define two seperate ones;
// currently this works in conjuction with the check on
// DefaultInitializeCollectionEventHandler.initializeCollectionFromCache() (which makes sure to not read from // DefaultInitializeCollectionEventHandler.initializeCollectionFromCache() (which makes sure to not read from
// cache with enabled filters). // cache with enabled filters).
// EARLY EXIT!!!!! // EARLY EXIT!!!!!

View File

@ -63,34 +63,36 @@ public class ConcurrentSecondLevelCacheStatisticsImpl extends CategorizedStatist
public Map getEntries() { public Map getEntries() {
Map map = new HashMap(); Map map = new HashMap();
for (Object o : region.toMap().entrySet()) { for ( Object o : region.toMap().entrySet() ) {
Map.Entry me = (Map.Entry) o; Map.Entry me = (Map.Entry) o;
Object id; Object id;
if (entityRegionAccessStrategy != null) { if ( entityRegionAccessStrategy != null ) {
id = entityRegionAccessStrategy.getCacheKeyId(me.getKey()); id = entityRegionAccessStrategy.getCacheKeyId( me.getKey() );
} else if (collectionRegionAccessStrategy != null) { }
id = collectionRegionAccessStrategy.getCacheKeyId(me.getKey()); else if ( collectionRegionAccessStrategy != null ) {
} else { id = collectionRegionAccessStrategy.getCacheKeyId( me.getKey() );
}
else {
id = me.getKey(); id = me.getKey();
} }
map.put(id, me.getValue()); map.put( id, me.getValue() );
} }
return map; return map;
} }
public String toString() { public String toString() {
StringBuilder buf = new StringBuilder() StringBuilder buf = new StringBuilder()
.append("SecondLevelCacheStatistics") .append( "SecondLevelCacheStatistics" )
.append("[hitCount=").append(this.hitCount) .append( "[hitCount=").append( this.hitCount )
.append(",missCount=").append(this.missCount) .append( ",missCount=").append( this.missCount )
.append(",putCount=").append(this.putCount); .append( ",putCount=").append( this.putCount );
//not sure if this would ever be null but wanted to be careful //not sure if this would ever be null but wanted to be careful
if (region != null) { if ( region != null ) {
buf.append(",elementCountInMemory=").append(this.getElementCountInMemory()) buf.append( ",elementCountInMemory=" ).append( this.getElementCountInMemory() )
.append(",elementCountOnDisk=").append(this.getElementCountOnDisk()) .append( ",elementCountOnDisk=" ).append( this.getElementCountOnDisk() )
.append(",sizeInMemory=").append(this.getSizeInMemory()); .append( ",sizeInMemory=" ).append( this.getSizeInMemory() );
} }
buf.append(']'); buf.append( ']' );
return buf.toString(); return buf.toString();
} }

View File

@ -90,6 +90,6 @@ public class NonStrictReadWriteEhcacheCollectionRegionAccessStrategy
@Override @Override
public Object getCacheKeyId(Object cacheKey) { public Object getCacheKeyId(Object cacheKey) {
return DefaultCacheKeysFactory.getCollectionId(cacheKey); return DefaultCacheKeysFactory.getCollectionId( cacheKey );
} }
} }

View File

@ -129,6 +129,6 @@ public class NonStrictReadWriteEhcacheEntityRegionAccessStrategy
@Override @Override
public Object getCacheKeyId(Object cacheKey) { public Object getCacheKeyId(Object cacheKey) {
return DefaultCacheKeysFactory.getEntityId(cacheKey); return DefaultCacheKeysFactory.getEntityId( cacheKey );
} }
} }

View File

@ -127,6 +127,6 @@ public class NonStrictReadWriteEhcacheNaturalIdRegionAccessStrategy
@Override @Override
public Object[] getNaturalIdValues(Object cacheKey) { public Object[] getNaturalIdValues(Object cacheKey) {
return DefaultCacheKeysFactory.getNaturalIdValues(cacheKey); return DefaultCacheKeysFactory.getNaturalIdValues( cacheKey );
} }
} }

View File

@ -66,6 +66,6 @@ class BaseNaturalIdRegionAccessStrategy extends BaseRegionAccessStrategy impleme
@Override @Override
public Object[] getNaturalIdValues(Object cacheKey) { public Object[] getNaturalIdValues(Object cacheKey) {
return DefaultCacheKeysFactory.getNaturalIdValues(cacheKey); return DefaultCacheKeysFactory.getNaturalIdValues( cacheKey );
} }
} }

View File

@ -53,6 +53,6 @@ class ReadWriteCollectionRegionAccessStrategy extends AbstractReadWriteAccessStr
@Override @Override
public Object getCacheKeyId(Object cacheKey) { public Object getCacheKeyId(Object cacheKey) {
return DefaultCacheKeysFactory.getCollectionId(cacheKey); return DefaultCacheKeysFactory.getCollectionId( cacheKey );
} }
} }

View File

@ -114,6 +114,6 @@ class ReadWriteEntityRegionAccessStrategy extends AbstractReadWriteAccessStrateg
@Override @Override
public Object getCacheKeyId(Object cacheKey) { public Object getCacheKeyId(Object cacheKey) {
return DefaultCacheKeysFactory.getEntityId(cacheKey); return DefaultCacheKeysFactory.getEntityId( cacheKey );
} }
} }

View File

@ -112,6 +112,6 @@ class ReadWriteNaturalIdRegionAccessStrategy extends AbstractReadWriteAccessStra
@Override @Override
public Object[] getNaturalIdValues(Object cacheKey) { public Object[] getNaturalIdValues(Object cacheKey) {
return DefaultCacheKeysFactory.getNaturalIdValues(cacheKey); return DefaultCacheKeysFactory.getNaturalIdValues( cacheKey );
} }
} }