HHH-8159 - Apply fixups indicated by analysis tools
This commit is contained in:
parent
42fd32a81a
commit
48331ed8cf
|
@ -24,10 +24,7 @@
|
|||
package org.hibernate.engine;
|
||||
|
||||
/**
|
||||
* Describes the strategy for fetching an association
|
||||
* <p/>
|
||||
* todo not really a fan of the name. not sure of a better one though.
|
||||
* I'd almost rather see this be called the style, but then what to call FetchStyle? HowToFetch?
|
||||
* Describes the strategy for fetching an association, which includes both when and how.
|
||||
*
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
|
@ -35,6 +32,12 @@ public class FetchStrategy {
|
|||
private final FetchTiming timing;
|
||||
private final FetchStyle style;
|
||||
|
||||
/**
|
||||
* Constructs a FetchStrategy.
|
||||
*
|
||||
* @param timing The fetch timing (the when)
|
||||
* @param style The fetch style (the how).
|
||||
*/
|
||||
public FetchStrategy(FetchTiming timing, FetchStyle style) {
|
||||
this.timing = timing;
|
||||
this.style = style;
|
||||
|
|
|
@ -57,6 +57,11 @@ public class NaturalIdXrefDelegate {
|
|||
private final StatefulPersistenceContext persistenceContext;
|
||||
private final Map<EntityPersister, NaturalIdResolutionCache> naturalIdResolutionCacheMap = new ConcurrentHashMap<EntityPersister, NaturalIdResolutionCache>();
|
||||
|
||||
/**
|
||||
* Constructs a NaturalIdXrefDelegate
|
||||
*
|
||||
* @param persistenceContext The persistence context that owns this delegate
|
||||
*/
|
||||
public NaturalIdXrefDelegate(StatefulPersistenceContext persistenceContext) {
|
||||
this.persistenceContext = persistenceContext;
|
||||
}
|
||||
|
@ -105,7 +110,7 @@ public class NaturalIdXrefDelegate {
|
|||
persister = locatePersisterForKey( persister );
|
||||
validateNaturalId( persister, naturalIdValues );
|
||||
|
||||
NaturalIdResolutionCache entityNaturalIdResolutionCache = naturalIdResolutionCacheMap.get( persister );
|
||||
final NaturalIdResolutionCache entityNaturalIdResolutionCache = naturalIdResolutionCacheMap.get( persister );
|
||||
Object[] sessionCachedNaturalIdValues = null;
|
||||
if ( entityNaturalIdResolutionCache != null ) {
|
||||
final CachedNaturalId cachedNaturalId = entityNaturalIdResolutionCache.pkToNaturalIdMap
|
||||
|
@ -142,7 +147,7 @@ public class NaturalIdXrefDelegate {
|
|||
* @return {@code true} if the given naturalIdValues match the current cached values; {@code false} otherwise.
|
||||
*/
|
||||
public boolean sameAsCached(EntityPersister persister, Serializable pk, Object[] naturalIdValues) {
|
||||
NaturalIdResolutionCache entityNaturalIdResolutionCache = naturalIdResolutionCacheMap.get( persister );
|
||||
final NaturalIdResolutionCache entityNaturalIdResolutionCache = naturalIdResolutionCacheMap.get( persister );
|
||||
return entityNaturalIdResolutionCache != null
|
||||
&& entityNaturalIdResolutionCache.sameAsCached( pk, naturalIdValues );
|
||||
}
|
||||
|
@ -302,7 +307,7 @@ public class NaturalIdXrefDelegate {
|
|||
|
||||
Collection<Serializable> pks = null;
|
||||
|
||||
NaturalIdResolutionCache entityNaturalIdResolutionCache = naturalIdResolutionCacheMap.get( persister );
|
||||
final NaturalIdResolutionCache entityNaturalIdResolutionCache = naturalIdResolutionCacheMap.get( persister );
|
||||
if ( entityNaturalIdResolutionCache != null ) {
|
||||
pks = entityNaturalIdResolutionCache.pkToNaturalIdMap.keySet();
|
||||
}
|
||||
|
@ -369,7 +374,7 @@ public class NaturalIdXrefDelegate {
|
|||
for ( int naturalIdPropertyIndex : naturalIdPropertyIndexes ) {
|
||||
final Type type = persister.getPropertyType( persister.getPropertyNames()[ naturalIdPropertyIndex ] );
|
||||
naturalIdTypes[i] = type;
|
||||
int elementHashCode = values[i] == null ? 0 :type.getHashCode( values[i], persister.getFactory() );
|
||||
final int elementHashCode = values[i] == null ? 0 :type.getHashCode( values[i], persister.getFactory() );
|
||||
hashCodeCalculation = prime * hashCodeCalculation + elementHashCode;
|
||||
i++;
|
||||
}
|
||||
|
@ -491,6 +496,9 @@ public class NaturalIdXrefDelegate {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear the resolution cache
|
||||
*/
|
||||
public void clear() {
|
||||
naturalIdResolutionCacheMap.clear();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue