misc cleanups
Signed-off-by: Gavin King <gavin@hibernate.org>
This commit is contained in:
parent
09fa8ef76a
commit
f7db3f0005
|
@ -772,10 +772,9 @@ public class StatefulPersistenceContext implements PersistenceContext {
|
|||
*/
|
||||
private void reassociateProxy(LazyInitializer li, HibernateProxy proxy) {
|
||||
if ( li.getSession() != this.getSession() ) {
|
||||
final EntityPersister persister = session.getFactory()
|
||||
.getRuntimeMetamodels()
|
||||
.getMappingMetamodel()
|
||||
.getEntityDescriptor( li.getEntityName() );
|
||||
final EntityPersister persister =
|
||||
session.getFactory().getMappingMetamodel()
|
||||
.getEntityDescriptor( li.getEntityName() );
|
||||
final EntityKey key = session.generateEntityKey( li.getInternalIdentifier(), persister );
|
||||
// any earlier proxy takes precedence
|
||||
final Map<EntityKey, EntityHolderImpl> entityHolderMap = getOrInitializeEntitiesByKey();
|
||||
|
|
|
@ -57,6 +57,7 @@ import static org.hibernate.engine.internal.ManagedTypeHelper.isHibernateProxy;
|
|||
import static org.hibernate.engine.internal.ManagedTypeHelper.isPersistentAttributeInterceptable;
|
||||
import static org.hibernate.engine.internal.ManagedTypeHelper.isSelfDirtinessTracker;
|
||||
import static org.hibernate.event.internal.EntityState.getEntityState;
|
||||
import static org.hibernate.proxy.HibernateProxy.extractLazyInitializer;
|
||||
|
||||
/**
|
||||
* Defines the default copy event listener used by hibernate for copying entities
|
||||
|
@ -111,7 +112,7 @@ public class DefaultMergeEventListener
|
|||
// NOTE : `original` is the value being merged
|
||||
if ( original != null ) {
|
||||
final EventSource source = event.getSession();
|
||||
final LazyInitializer lazyInitializer = HibernateProxy.extractLazyInitializer( original );
|
||||
final LazyInitializer lazyInitializer = extractLazyInitializer( original );
|
||||
if ( lazyInitializer != null ) {
|
||||
if ( lazyInitializer.isUninitialized() ) {
|
||||
LOG.trace( "Ignoring uninitialized proxy" );
|
||||
|
@ -122,9 +123,11 @@ public class DefaultMergeEventListener
|
|||
}
|
||||
}
|
||||
else if ( isPersistentAttributeInterceptable( original ) ) {
|
||||
final PersistentAttributeInterceptor interceptor = asPersistentAttributeInterceptable( original ).$$_hibernate_getInterceptor();
|
||||
final PersistentAttributeInterceptor interceptor =
|
||||
asPersistentAttributeInterceptable( original ).$$_hibernate_getInterceptor();
|
||||
if ( interceptor instanceof EnhancementAsProxyLazinessInterceptor ) {
|
||||
final EnhancementAsProxyLazinessInterceptor proxyInterceptor = (EnhancementAsProxyLazinessInterceptor) interceptor;
|
||||
final EnhancementAsProxyLazinessInterceptor proxyInterceptor =
|
||||
(EnhancementAsProxyLazinessInterceptor) interceptor;
|
||||
LOG.trace( "Ignoring uninitialized enhanced-proxy" );
|
||||
event.setResult( source.load( proxyInterceptor.getEntityName(), proxyInterceptor.getIdentifier() ) );
|
||||
}
|
||||
|
|
|
@ -864,8 +864,8 @@ public class SessionImpl
|
|||
|
||||
@Override
|
||||
public void removeOrphanBeforeUpdates(String entityName, Object child) {
|
||||
// TODO: The removeOrphan concept is a temporary "hack" for HHH-6484. This should be removed once action/task
|
||||
// ordering is improved.
|
||||
// TODO: The removeOrphan concept is a temporary "hack" for HHH-6484.
|
||||
// This should be removed once action/task ordering is improved.
|
||||
final boolean traceEnabled = log.isTraceEnabled();
|
||||
if ( traceEnabled ) {
|
||||
logRemoveOrphanBeforeUpdates( "begin", entityName, child );
|
||||
|
|
|
@ -52,17 +52,16 @@ public class LoaderHelper {
|
|||
final LockMode requestedLockMode = lockOptions.getLockMode();
|
||||
if ( requestedLockMode.greaterThan( entry.getLockMode() ) ) {
|
||||
// Request is for a more restrictive lock than the lock already held
|
||||
final EntityPersister persister = entry.getPersister();
|
||||
|
||||
if ( entry.getStatus().isDeletedOrGone()) {
|
||||
throw new ObjectDeletedException(
|
||||
"attempted to lock a deleted instance",
|
||||
entry.getId(),
|
||||
entry.getPersister().getEntityName()
|
||||
persister.getEntityName()
|
||||
);
|
||||
}
|
||||
|
||||
final EntityPersister persister = entry.getPersister();
|
||||
|
||||
if ( LoaderLogging.LOADER_LOGGER.isTraceEnabled() ) {
|
||||
LoaderLogging.LOADER_LOGGER.tracef(
|
||||
"Locking `%s( %s )` in `%s` lock-mode",
|
||||
|
@ -77,7 +76,7 @@ public class LoaderHelper {
|
|||
Object ck = null;
|
||||
try {
|
||||
if ( cachingEnabled ) {
|
||||
EntityDataAccess cache = persister.getCacheAccessStrategy();
|
||||
final EntityDataAccess cache = persister.getCacheAccessStrategy();
|
||||
ck = cache.generateCacheKey( entry.getId(), persister, session.getFactory(), session.getTenantIdentifier() );
|
||||
lock = cache.lockItem( session, ck, entry.getVersion() );
|
||||
}
|
||||
|
@ -99,9 +98,8 @@ public class LoaderHelper {
|
|||
|
||||
if ( persister.isVersioned() && requestedLockMode == LockMode.PESSIMISTIC_FORCE_INCREMENT ) {
|
||||
// todo : should we check the current isolation mode explicitly?
|
||||
Object nextVersion = persister.forceVersionIncrement(
|
||||
entry.getId(), entry.getVersion(), false, session
|
||||
);
|
||||
final Object nextVersion =
|
||||
persister.forceVersionIncrement( entry.getId(), entry.getVersion(), false, session );
|
||||
entry.forceLocked( object, nextVersion );
|
||||
}
|
||||
else {
|
||||
|
|
Loading…
Reference in New Issue