HHH-18552 clean up inappropriate usages of TransientObjectException
and minor cleanups in StatefulPersistenceContext Signed-off-by: Gavin King <gavin@hibernate.org>
This commit is contained in:
parent
7422c18a94
commit
f45e3db4b0
|
@ -373,10 +373,9 @@ public final class ForeignKeys {
|
||||||
|
|
||||||
private static void throwIfTransient(String entityName, Object object, SharedSessionContractImplementor session) {
|
private static void throwIfTransient(String entityName, Object object, SharedSessionContractImplementor session) {
|
||||||
if ( isTransient( entityName, object, Boolean.FALSE, session ) ) {
|
if ( isTransient( entityName, object, Boolean.FALSE, session ) ) {
|
||||||
throw new TransientObjectException(
|
throw new TransientObjectException( "Entity references an unsaved transient instance of '"
|
||||||
"object references an unsaved transient instance - save the transient instance before flushing: " +
|
+ (entityName == null ? session.guessEntityName(object) : entityName)
|
||||||
(entityName == null ? session.guessEntityName(object) : entityName)
|
+ "' (make the transient instance persistent before flushing)" );
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,6 @@ import org.hibernate.LockMode;
|
||||||
import org.hibernate.MappingException;
|
import org.hibernate.MappingException;
|
||||||
import org.hibernate.NonUniqueObjectException;
|
import org.hibernate.NonUniqueObjectException;
|
||||||
import org.hibernate.PersistentObjectException;
|
import org.hibernate.PersistentObjectException;
|
||||||
import org.hibernate.TransientObjectException;
|
|
||||||
import org.hibernate.bytecode.enhance.spi.interceptor.BytecodeLazyAttributeInterceptor;
|
import org.hibernate.bytecode.enhance.spi.interceptor.BytecodeLazyAttributeInterceptor;
|
||||||
import org.hibernate.bytecode.enhance.spi.interceptor.EnhancementAsProxyLazinessInterceptor;
|
import org.hibernate.bytecode.enhance.spi.interceptor.EnhancementAsProxyLazinessInterceptor;
|
||||||
import org.hibernate.collection.spi.PersistentCollection;
|
import org.hibernate.collection.spi.PersistentCollection;
|
||||||
|
@ -79,6 +78,7 @@ import static org.hibernate.engine.internal.ManagedTypeHelper.asHibernateProxy;
|
||||||
import static org.hibernate.engine.internal.ManagedTypeHelper.asManagedEntity;
|
import static org.hibernate.engine.internal.ManagedTypeHelper.asManagedEntity;
|
||||||
import static org.hibernate.engine.internal.ManagedTypeHelper.asPersistentAttributeInterceptable;
|
import static org.hibernate.engine.internal.ManagedTypeHelper.asPersistentAttributeInterceptable;
|
||||||
import static org.hibernate.engine.internal.ManagedTypeHelper.isPersistentAttributeInterceptable;
|
import static org.hibernate.engine.internal.ManagedTypeHelper.isPersistentAttributeInterceptable;
|
||||||
|
import static org.hibernate.proxy.HibernateProxy.extractLazyInitializer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A <em>stateful</em> implementation of the {@link PersistenceContext} contract, meaning that we maintain this
|
* A <em>stateful</em> implementation of the {@link PersistenceContext} contract, meaning that we maintain this
|
||||||
|
@ -217,7 +217,7 @@ public class StatefulPersistenceContext implements PersistenceContext {
|
||||||
//
|
//
|
||||||
@Override
|
@Override
|
||||||
public PersistentCollection<?> useUnownedCollection(CollectionKey key) {
|
public PersistentCollection<?> useUnownedCollection(CollectionKey key) {
|
||||||
return ( unownedCollections == null ) ? null : unownedCollections.remove( key );
|
return unownedCollections == null ? null : unownedCollections.remove( key );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -234,7 +234,7 @@ public class StatefulPersistenceContext implements PersistenceContext {
|
||||||
//Strictly avoid lambdas in this case
|
//Strictly avoid lambdas in this case
|
||||||
for ( EntityHolderImpl value : entitiesByKey.values() ) {
|
for ( EntityHolderImpl value : entitiesByKey.values() ) {
|
||||||
if ( value != null && value.proxy != null ) {
|
if ( value != null && value.proxy != null ) {
|
||||||
HibernateProxy.extractLazyInitializer( value.proxy ).unsetSession();
|
extractLazyInitializer( value.proxy ).unsetSession();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -337,9 +337,8 @@ public class StatefulPersistenceContext implements PersistenceContext {
|
||||||
if ( cachedValue != null ) {
|
if ( cachedValue != null ) {
|
||||||
return cachedValue;
|
return cachedValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// check to see if the natural id is mutable/immutable
|
// check to see if the natural id is mutable/immutable
|
||||||
if ( persister.getEntityMetamodel().hasImmutableNaturalId() ) {
|
else if ( persister.getEntityMetamodel().hasImmutableNaturalId() ) {
|
||||||
// an immutable natural-id is not retrieved during a normal database-snapshot operation...
|
// an immutable natural-id is not retrieved during a normal database-snapshot operation...
|
||||||
final Object naturalIdFromDb = persister.getNaturalIdentifierSnapshot( id, session );
|
final Object naturalIdFromDb = persister.getNaturalIdentifierSnapshot( id, session );
|
||||||
naturalIdResolutions.cacheResolutionFromLoad( id, naturalIdFromDb, persister );
|
naturalIdResolutions.cacheResolutionFromLoad( id, naturalIdFromDb, persister );
|
||||||
|
@ -353,13 +352,14 @@ public class StatefulPersistenceContext implements PersistenceContext {
|
||||||
if ( entitySnapshot == NO_ROW || entitySnapshot == null ) {
|
if ( entitySnapshot == NO_ROW || entitySnapshot == null ) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
final Object[] naturalIdSnapshotSubSet = new Object[ props.length ];
|
final Object[] naturalIdSnapshotSubSet = new Object[ props.length ];
|
||||||
for ( int i = 0; i < props.length; i++ ) {
|
for ( int i = 0; i < props.length; i++ ) {
|
||||||
naturalIdSnapshotSubSet[i] = entitySnapshot[ props[i] ];
|
naturalIdSnapshotSubSet[i] = entitySnapshot[ props[i] ];
|
||||||
|
}
|
||||||
|
naturalIdResolutions.cacheResolutionFromLoad( id, naturalIdSnapshotSubSet, persister );
|
||||||
|
return naturalIdSnapshotSubSet;
|
||||||
}
|
}
|
||||||
naturalIdResolutions.cacheResolutionFromLoad( id, naturalIdSnapshotSubSet, persister );
|
|
||||||
return naturalIdSnapshotSubSet;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -429,9 +429,8 @@ public class StatefulPersistenceContext implements PersistenceContext {
|
||||||
public void postLoad(JdbcValuesSourceProcessingState processingState, Consumer<EntityHolder> holderConsumer) {
|
public void postLoad(JdbcValuesSourceProcessingState processingState, Consumer<EntityHolder> holderConsumer) {
|
||||||
final Callback callback = processingState.getExecutionContext().getCallback();
|
final Callback callback = processingState.getExecutionContext().getCallback();
|
||||||
if ( processingState.getLoadingEntityHolders() != null ) {
|
if ( processingState.getLoadingEntityHolders() != null ) {
|
||||||
final EventListenerGroup<PostLoadEventListener> listenerGroup = getSession().getFactory()
|
final EventListenerGroup<PostLoadEventListener> listenerGroup =
|
||||||
.getFastSessionServices()
|
getSession().getFactory().getFastSessionServices().eventListenerGroup_POST_LOAD;
|
||||||
.eventListenerGroup_POST_LOAD;
|
|
||||||
final PostLoadEvent postLoadEvent = processingState.getPostLoadEvent();
|
final PostLoadEvent postLoadEvent = processingState.getPostLoadEvent();
|
||||||
for ( final EntityHolder holder : processingState.getLoadingEntityHolders() ) {
|
for ( final EntityHolder holder : processingState.getLoadingEntityHolders() ) {
|
||||||
processLoadedEntityHolder( holder, listenerGroup, postLoadEvent, callback, holderConsumer );
|
processLoadedEntityHolder( holder, listenerGroup, postLoadEvent, callback, holderConsumer );
|
||||||
|
@ -460,26 +459,27 @@ public class StatefulPersistenceContext implements PersistenceContext {
|
||||||
// in which case we added an entry with a null proxy and entity.
|
// in which case we added an entry with a null proxy and entity.
|
||||||
// Remove that empty entry on post load to avoid unwanted side effects
|
// Remove that empty entry on post load to avoid unwanted side effects
|
||||||
entitiesByKey.remove( holder.getEntityKey() );
|
entitiesByKey.remove( holder.getEntityKey() );
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
if ( postLoadEvent != null ) {
|
else {
|
||||||
postLoadEvent.reset();
|
if ( postLoadEvent != null ) {
|
||||||
postLoadEvent.setEntity( holder.getEntity() )
|
postLoadEvent.reset();
|
||||||
.setId( holder.getEntityKey().getIdentifier() )
|
postLoadEvent.setEntity( holder.getEntity() )
|
||||||
.setPersister( holder.getDescriptor() );
|
.setId( holder.getEntityKey().getIdentifier() )
|
||||||
listenerGroup.fireEventOnEachListener(
|
.setPersister( holder.getDescriptor() );
|
||||||
postLoadEvent,
|
listenerGroup.fireEventOnEachListener(
|
||||||
PostLoadEventListener::onPostLoad
|
postLoadEvent,
|
||||||
);
|
PostLoadEventListener::onPostLoad
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if ( callback != null ) {
|
||||||
|
callback.invokeAfterLoadActions(
|
||||||
|
holder.getEntity(),
|
||||||
|
holder.getDescriptor(),
|
||||||
|
getSession()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
( (EntityHolderImpl) holder ).entityInitializer = null;
|
||||||
}
|
}
|
||||||
if ( callback != null ) {
|
|
||||||
callback.invokeAfterLoadActions(
|
|
||||||
holder.getEntity(),
|
|
||||||
holder.getDescriptor(),
|
|
||||||
getSession()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
( (EntityHolderImpl) holder ).entityInitializer = null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -498,7 +498,8 @@ public class StatefulPersistenceContext implements PersistenceContext {
|
||||||
holder = oldHolder;
|
holder = oldHolder;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
entityHolderMap.put( key, holder = EntityHolderImpl.forEntity( key, key.getPersister(), entity ) );
|
holder = EntityHolderImpl.forEntity( key, key.getPersister(), entity );
|
||||||
|
entityHolderMap.put( key, holder );
|
||||||
}
|
}
|
||||||
holder.state = EntityHolderState.INITIALIZED;
|
holder.state = EntityHolderState.INITIALIZED;
|
||||||
final BatchFetchQueue fetchQueue = this.batchFetchQueue;
|
final BatchFetchQueue fetchQueue = this.batchFetchQueue;
|
||||||
|
@ -614,8 +615,8 @@ public class StatefulPersistenceContext implements PersistenceContext {
|
||||||
final boolean existsInDatabase,
|
final boolean existsInDatabase,
|
||||||
final EntityPersister persister,
|
final EntityPersister persister,
|
||||||
final boolean disableVersionIncrement) {
|
final boolean disableVersionIncrement) {
|
||||||
EntityHolder entityHolder = addEntityHolder( entityKey, entity );
|
final EntityHolder entityHolder = addEntityHolder( entityKey, entity );
|
||||||
EntityEntry entityEntry = addEntry(
|
final EntityEntry entityEntry = addEntry(
|
||||||
entity,
|
entity,
|
||||||
status,
|
status,
|
||||||
loadedState,
|
loadedState,
|
||||||
|
@ -661,7 +662,7 @@ public class StatefulPersistenceContext implements PersistenceContext {
|
||||||
removes the virtual call, and allows the methods to be inlined. In this critical code path, it has a very
|
removes the virtual call, and allows the methods to be inlined. In this critical code path, it has a very
|
||||||
large impact on performance to make virtual method calls.
|
large impact on performance to make virtual method calls.
|
||||||
*/
|
*/
|
||||||
if (persister.getEntityEntryFactory() instanceof MutableEntityEntryFactory) {
|
if ( persister.getEntityEntryFactory() instanceof MutableEntityEntryFactory ) {
|
||||||
//noinspection RedundantCast
|
//noinspection RedundantCast
|
||||||
e = ( (MutableEntityEntryFactory) persister.getEntityEntryFactory() ).createEntityEntry(
|
e = ( (MutableEntityEntryFactory) persister.getEntityEntryFactory() ).createEntityEntry(
|
||||||
status,
|
status,
|
||||||
|
@ -731,7 +732,7 @@ public class StatefulPersistenceContext implements PersistenceContext {
|
||||||
if ( ! Hibernate.isInitialized( value ) ) {
|
if ( ! Hibernate.isInitialized( value ) ) {
|
||||||
|
|
||||||
// could be a proxy....
|
// could be a proxy....
|
||||||
final LazyInitializer lazyInitializer = HibernateProxy.extractLazyInitializer( value );
|
final LazyInitializer lazyInitializer = extractLazyInitializer( value );
|
||||||
if ( lazyInitializer != null ) {
|
if ( lazyInitializer != null ) {
|
||||||
reassociateProxy( lazyInitializer, asHibernateProxy( value ) );
|
reassociateProxy( lazyInitializer, asHibernateProxy( value ) );
|
||||||
return true;
|
return true;
|
||||||
|
@ -740,7 +741,8 @@ public class StatefulPersistenceContext implements PersistenceContext {
|
||||||
// or an uninitialized enhanced entity ("bytecode proxy")...
|
// or an uninitialized enhanced entity ("bytecode proxy")...
|
||||||
if ( isPersistentAttributeInterceptable( value ) ) {
|
if ( isPersistentAttributeInterceptable( value ) ) {
|
||||||
final PersistentAttributeInterceptable bytecodeProxy = asPersistentAttributeInterceptable( value );
|
final PersistentAttributeInterceptable bytecodeProxy = asPersistentAttributeInterceptable( value );
|
||||||
final BytecodeLazyAttributeInterceptor interceptor = (BytecodeLazyAttributeInterceptor) bytecodeProxy.$$_hibernate_getInterceptor();
|
final BytecodeLazyAttributeInterceptor interceptor =
|
||||||
|
(BytecodeLazyAttributeInterceptor) bytecodeProxy.$$_hibernate_getInterceptor();
|
||||||
if ( interceptor != null ) {
|
if ( interceptor != null ) {
|
||||||
interceptor.setSession( getSession() );
|
interceptor.setSession( getSession() );
|
||||||
}
|
}
|
||||||
|
@ -754,7 +756,7 @@ public class StatefulPersistenceContext implements PersistenceContext {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void reassociateProxy(Object value, Object id) throws MappingException {
|
public void reassociateProxy(Object value, Object id) throws MappingException {
|
||||||
final LazyInitializer lazyInitializer = HibernateProxy.extractLazyInitializer( value );
|
final LazyInitializer lazyInitializer = extractLazyInitializer( value );
|
||||||
if ( lazyInitializer != null ) {
|
if ( lazyInitializer != null ) {
|
||||||
LOG.debugf( "Setting proxy identifier: %s", id );
|
LOG.debugf( "Setting proxy identifier: %s", id );
|
||||||
lazyInitializer.setIdentifier( id );
|
lazyInitializer.setIdentifier( id );
|
||||||
|
@ -792,7 +794,7 @@ public class StatefulPersistenceContext implements PersistenceContext {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object unproxy(Object maybeProxy) throws HibernateException {
|
public Object unproxy(Object maybeProxy) throws HibernateException {
|
||||||
final LazyInitializer lazyInitializer = HibernateProxy.extractLazyInitializer( maybeProxy );
|
final LazyInitializer lazyInitializer = extractLazyInitializer( maybeProxy );
|
||||||
if ( lazyInitializer != null ) {
|
if ( lazyInitializer != null ) {
|
||||||
if ( lazyInitializer.isUninitialized() ) {
|
if ( lazyInitializer.isUninitialized() ) {
|
||||||
throw new PersistentObjectException(
|
throw new PersistentObjectException(
|
||||||
|
@ -809,7 +811,7 @@ public class StatefulPersistenceContext implements PersistenceContext {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object unproxyAndReassociate(final Object maybeProxy) throws HibernateException {
|
public Object unproxyAndReassociate(final Object maybeProxy) throws HibernateException {
|
||||||
final LazyInitializer lazyInitializer = HibernateProxy.extractLazyInitializer( maybeProxy );
|
final LazyInitializer lazyInitializer = extractLazyInitializer( maybeProxy );
|
||||||
if ( lazyInitializer != null ) {
|
if ( lazyInitializer != null ) {
|
||||||
reassociateProxy( lazyInitializer, asHibernateProxy( maybeProxy ) );
|
reassociateProxy( lazyInitializer, asHibernateProxy( maybeProxy ) );
|
||||||
//initialize + unwrap the object and return it
|
//initialize + unwrap the object and return it
|
||||||
|
@ -858,7 +860,7 @@ public class StatefulPersistenceContext implements PersistenceContext {
|
||||||
|
|
||||||
// Similarly, if the original HibernateProxy is initialized, there
|
// Similarly, if the original HibernateProxy is initialized, there
|
||||||
// is again no point in creating a proxy. Just return the impl
|
// is again no point in creating a proxy. Just return the impl
|
||||||
final LazyInitializer lazyInitializer = HibernateProxy.extractLazyInitializer( proxy );
|
final LazyInitializer lazyInitializer = extractLazyInitializer( proxy );
|
||||||
if ( !lazyInitializer.isUninitialized() ) {
|
if ( !lazyInitializer.isUninitialized() ) {
|
||||||
final Object impl = lazyInitializer.getImplementation();
|
final Object impl = lazyInitializer.getImplementation();
|
||||||
// can we return it?
|
// can we return it?
|
||||||
|
@ -871,16 +873,13 @@ public class StatefulPersistenceContext implements PersistenceContext {
|
||||||
|
|
||||||
// Otherwise, create the narrowed proxy
|
// Otherwise, create the narrowed proxy
|
||||||
final HibernateProxy narrowedProxy = asHibernateProxy( persister.createProxy( key.getIdentifier(), session ) );
|
final HibernateProxy narrowedProxy = asHibernateProxy( persister.createProxy( key.getIdentifier(), session ) );
|
||||||
|
|
||||||
// set the read-only/modifiable mode in the new proxy to what it was in the original proxy
|
// set the read-only/modifiable mode in the new proxy to what it was in the original proxy
|
||||||
final boolean readOnlyOrig = lazyInitializer.isReadOnly();
|
narrowedProxy.getHibernateLazyInitializer().setReadOnly( lazyInitializer.isReadOnly() );
|
||||||
narrowedProxy.getHibernateLazyInitializer().setReadOnly( readOnlyOrig );
|
|
||||||
|
|
||||||
return narrowedProxy;
|
return narrowedProxy;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if ( object != null ) {
|
if ( object != null ) {
|
||||||
HibernateProxy.extractLazyInitializer( proxy ).setImplementation( object );
|
extractLazyInitializer( proxy ).setImplementation( object );
|
||||||
}
|
}
|
||||||
return proxy;
|
return proxy;
|
||||||
}
|
}
|
||||||
|
@ -1531,7 +1530,7 @@ public class StatefulPersistenceContext implements PersistenceContext {
|
||||||
if ( mergeMap != null ) {
|
if ( mergeMap != null ) {
|
||||||
for ( Object o : mergeMap.entrySet() ) {
|
for ( Object o : mergeMap.entrySet() ) {
|
||||||
final Entry<?,?> mergeMapEntry = (Entry<?,?>) o;
|
final Entry<?,?> mergeMapEntry = (Entry<?,?>) o;
|
||||||
final LazyInitializer lazyInitializer = HibernateProxy.extractLazyInitializer( mergeMapEntry.getKey() );
|
final LazyInitializer lazyInitializer = extractLazyInitializer( mergeMapEntry.getKey() );
|
||||||
if ( lazyInitializer != null ) {
|
if ( lazyInitializer != null ) {
|
||||||
if ( persister.isSubclassEntityName( lazyInitializer.getEntityName() ) ) {
|
if ( persister.isSubclassEntityName( lazyInitializer.getEntityName() ) ) {
|
||||||
HibernateProxy proxy = asHibernateProxy( mergeMapEntry.getKey() );
|
HibernateProxy proxy = asHibernateProxy( mergeMapEntry.getKey() );
|
||||||
|
@ -1693,17 +1692,17 @@ public class StatefulPersistenceContext implements PersistenceContext {
|
||||||
@Override
|
@Override
|
||||||
public boolean isReadOnly(Object entityOrProxy) {
|
public boolean isReadOnly(Object entityOrProxy) {
|
||||||
if ( entityOrProxy == null ) {
|
if ( entityOrProxy == null ) {
|
||||||
throw new AssertionFailure( "object must be non-null." );
|
throw new IllegalArgumentException( "Null entity instance" );
|
||||||
}
|
}
|
||||||
boolean isReadOnly;
|
boolean isReadOnly;
|
||||||
final LazyInitializer lazyInitializer = HibernateProxy.extractLazyInitializer( entityOrProxy );
|
final LazyInitializer lazyInitializer = extractLazyInitializer( entityOrProxy );
|
||||||
if ( lazyInitializer != null ) {
|
if ( lazyInitializer != null ) {
|
||||||
isReadOnly = lazyInitializer.isReadOnly();
|
isReadOnly = lazyInitializer.isReadOnly();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
final EntityEntry ee = getEntry( entityOrProxy );
|
final EntityEntry ee = getEntry( entityOrProxy );
|
||||||
if ( ee == null ) {
|
if ( ee == null ) {
|
||||||
throw new TransientObjectException( "Instance was not associated with this persistence context" );
|
throw new IllegalArgumentException( "Instance is not associated with this persistence context" );
|
||||||
}
|
}
|
||||||
isReadOnly = ee.isReadOnly();
|
isReadOnly = ee.isReadOnly();
|
||||||
}
|
}
|
||||||
|
@ -1713,12 +1712,12 @@ public class StatefulPersistenceContext implements PersistenceContext {
|
||||||
@Override
|
@Override
|
||||||
public void setReadOnly(Object object, boolean readOnly) {
|
public void setReadOnly(Object object, boolean readOnly) {
|
||||||
if ( object == null ) {
|
if ( object == null ) {
|
||||||
throw new AssertionFailure( "object must be non-null." );
|
throw new IllegalArgumentException( "Null entity instance" );
|
||||||
}
|
}
|
||||||
if ( isReadOnly( object ) == readOnly ) {
|
if ( isReadOnly( object ) == readOnly ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final LazyInitializer lazyInitializer = HibernateProxy.extractLazyInitializer( object );
|
final LazyInitializer lazyInitializer = extractLazyInitializer( object );
|
||||||
if ( lazyInitializer != null ) {
|
if ( lazyInitializer != null ) {
|
||||||
setProxyReadOnly( lazyInitializer, readOnly );
|
setProxyReadOnly( lazyInitializer, readOnly );
|
||||||
if ( ! lazyInitializer.isUninitialized() ) {
|
if ( ! lazyInitializer.isUninitialized() ) {
|
||||||
|
@ -1733,7 +1732,7 @@ public class StatefulPersistenceContext implements PersistenceContext {
|
||||||
// PersistenceContext.proxyFor( entity ) returns entity if there is no proxy for that entity
|
// PersistenceContext.proxyFor( entity ) returns entity if there is no proxy for that entity
|
||||||
// so need to check the return value to be sure it is really a proxy
|
// so need to check the return value to be sure it is really a proxy
|
||||||
final Object maybeProxy = getSession().getPersistenceContextInternal().proxyFor( object );
|
final Object maybeProxy = getSession().getPersistenceContextInternal().proxyFor( object );
|
||||||
final LazyInitializer lazyInitializer1 = HibernateProxy.extractLazyInitializer( maybeProxy );
|
final LazyInitializer lazyInitializer1 = extractLazyInitializer( maybeProxy );
|
||||||
if ( lazyInitializer1 != null ) {
|
if ( lazyInitializer1 != null ) {
|
||||||
setProxyReadOnly( lazyInitializer1, readOnly );
|
setProxyReadOnly( lazyInitializer1, readOnly );
|
||||||
}
|
}
|
||||||
|
@ -1751,7 +1750,7 @@ public class StatefulPersistenceContext implements PersistenceContext {
|
||||||
private void setEntityReadOnly(Object entity, boolean readOnly) {
|
private void setEntityReadOnly(Object entity, boolean readOnly) {
|
||||||
final EntityEntry entry = getEntry( entity );
|
final EntityEntry entry = getEntry( entity );
|
||||||
if ( entry == null ) {
|
if ( entry == null ) {
|
||||||
throw new TransientObjectException( "Instance was not associated with this persistence context" );
|
throw new IllegalArgumentException( "Instance was not associated with this persistence context" );
|
||||||
}
|
}
|
||||||
entry.setReadOnly( readOnly, entity );
|
entry.setReadOnly( readOnly, entity );
|
||||||
hasNonReadOnlyEntities = hasNonReadOnlyEntities || ! readOnly;
|
hasNonReadOnlyEntities = hasNonReadOnlyEntities || ! readOnly;
|
||||||
|
@ -1963,7 +1962,7 @@ public class StatefulPersistenceContext implements PersistenceContext {
|
||||||
final EntityHolderImpl holder = EntityHolderImpl.forEntity( ek, persister, entity );
|
final EntityHolderImpl holder = EntityHolderImpl.forEntity( ek, persister, entity );
|
||||||
holder.state = state;
|
holder.state = state;
|
||||||
if ( proxy != null ) {
|
if ( proxy != null ) {
|
||||||
final LazyInitializer lazyInitializer = HibernateProxy.extractLazyInitializer( proxy );
|
final LazyInitializer lazyInitializer = extractLazyInitializer( proxy );
|
||||||
if ( lazyInitializer != null ) {
|
if ( lazyInitializer != null ) {
|
||||||
lazyInitializer.setSession( session );
|
lazyInitializer.setSession( session );
|
||||||
holder.proxy = proxy;
|
holder.proxy = proxy;
|
||||||
|
|
|
@ -502,8 +502,8 @@ public class ActionQueue {
|
||||||
final String path = transientEntities.getNonNullableTransientPropertyPaths(transientEntity).iterator().next();
|
final String path = transientEntities.getNonNullableTransientPropertyPaths(transientEntity).iterator().next();
|
||||||
//TODO: should be TransientPropertyValueException
|
//TODO: should be TransientPropertyValueException
|
||||||
throw new TransientObjectException( "Persistent instance of '" + insertAction.getEntityName()
|
throw new TransientObjectException( "Persistent instance of '" + insertAction.getEntityName()
|
||||||
+ "' with id '" + insertAction.getId()
|
+ "' with id [" + insertAction.getId()
|
||||||
+ "' references an unsaved transient instance via attribute '" + path
|
+ "] references an unsaved transient instance via attribute '" + path
|
||||||
+ "' (save the transient instance before flushing)" );
|
+ "' (save the transient instance before flushing)" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -339,7 +339,7 @@ public class CascadingActions {
|
||||||
boolean isCascadeDeleteEnabled)
|
boolean isCascadeDeleteEnabled)
|
||||||
throws HibernateException {
|
throws HibernateException {
|
||||||
if ( child != null && isChildTransient( session, child, entityName ) ) {
|
if ( child != null && isChildTransient( session, child, entityName ) ) {
|
||||||
throw new TransientObjectException( "persistent instance references an unsaved transient instance of '"
|
throw new TransientObjectException( "Persistent instance references an unsaved transient instance of '"
|
||||||
+ entityName + "' (save the transient instance before flushing)" );
|
+ entityName + "' (save the transient instance before flushing)" );
|
||||||
//TODO: should be TransientPropertyValueException
|
//TODO: should be TransientPropertyValueException
|
||||||
// throw new TransientPropertyValueException(
|
// throw new TransientPropertyValueException(
|
||||||
|
|
|
@ -179,7 +179,8 @@ public class DefaultDeleteEventListener implements DeleteEventListener, Callback
|
||||||
|
|
||||||
final Object id = persister.getIdentifier( entity, source );
|
final Object id = persister.getIdentifier( entity, source );
|
||||||
if ( id == null ) {
|
if ( id == null ) {
|
||||||
throw new TransientObjectException("the detached instance passed to delete() had a null identifier");
|
throw new TransientObjectException( "Cannot delete instance of entity '" + persister.getEntityName()
|
||||||
|
+ "' because it has a null identifier" );
|
||||||
}
|
}
|
||||||
|
|
||||||
final PersistenceContext persistenceContext = source.getPersistenceContextInternal();
|
final PersistenceContext persistenceContext = source.getPersistenceContextInternal();
|
||||||
|
|
|
@ -71,8 +71,8 @@ public class DefaultLockEventListener extends AbstractLockUpgradeEventListener i
|
||||||
final EntityPersister persister = source.getEntityPersister( event.getEntityName(), entity );
|
final EntityPersister persister = source.getEntityPersister( event.getEntityName(), entity );
|
||||||
final Object id = persister.getIdentifier( entity, source );
|
final Object id = persister.getIdentifier( entity, source );
|
||||||
if ( !ForeignKeys.isNotTransient( event.getEntityName(), entity, Boolean.FALSE, source ) ) {
|
if ( !ForeignKeys.isNotTransient( event.getEntityName(), entity, Boolean.FALSE, source ) ) {
|
||||||
throw new TransientObjectException( "cannot lock an unsaved transient instance: "
|
throw new TransientObjectException( "Cannot lock unsaved transient instance of entity '"
|
||||||
+ persister.getEntityName() );
|
+ persister.getEntityName() + "'" );
|
||||||
}
|
}
|
||||||
entry = reassociate( event, entity, id, persister );
|
entry = reassociate( event, entity, id, persister );
|
||||||
cascadeOnLock( event, persister, entity );
|
cascadeOnLock( event, persister, entity );
|
||||||
|
|
|
@ -20,7 +20,6 @@ import org.hibernate.engine.internal.CascadePoint;
|
||||||
import org.hibernate.engine.spi.ActionQueue;
|
import org.hibernate.engine.spi.ActionQueue;
|
||||||
import org.hibernate.engine.spi.CascadingActions;
|
import org.hibernate.engine.spi.CascadingActions;
|
||||||
import org.hibernate.engine.spi.EntityEntry;
|
import org.hibernate.engine.spi.EntityEntry;
|
||||||
import org.hibernate.engine.spi.EntityKey;
|
|
||||||
import org.hibernate.engine.spi.PersistenceContext;
|
import org.hibernate.engine.spi.PersistenceContext;
|
||||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||||
import org.hibernate.event.spi.EventSource;
|
import org.hibernate.event.spi.EventSource;
|
||||||
|
@ -132,7 +131,8 @@ public class DefaultRefreshEventListener implements RefreshEventListener {
|
||||||
persister = source.getEntityPersister( event.getEntityName(), object );
|
persister = source.getEntityPersister( event.getEntityName(), object );
|
||||||
id = persister.getIdentifier( object, event.getSession() );
|
id = persister.getIdentifier( object, event.getSession() );
|
||||||
if ( id == null ) {
|
if ( id == null ) {
|
||||||
throw new TransientObjectException( "transient instance passed to refresh");
|
throw new TransientObjectException( "Cannot refresh instance of entity '" + persister.getEntityName()
|
||||||
|
+ "' because it has a null identifier" );
|
||||||
}
|
}
|
||||||
if ( LOG.isTraceEnabled() ) {
|
if ( LOG.isTraceEnabled() ) {
|
||||||
LOG.tracev(
|
LOG.tracev(
|
||||||
|
|
|
@ -77,7 +77,8 @@ public class DefaultReplicateEventListener
|
||||||
// except null (that is, even ids which look like they're unsaved)
|
// except null (that is, even ids which look like they're unsaved)
|
||||||
final Object id = persister.getIdentifier( entity, source );
|
final Object id = persister.getIdentifier( entity, source );
|
||||||
if ( id == null ) {
|
if ( id == null ) {
|
||||||
throw new TransientObjectException( "instance with null id passed to replicate()" );
|
throw new TransientObjectException( "Cannot replicate instance of entity '" + persister.getEntityName()
|
||||||
|
+ "' because it has a null identifier" );
|
||||||
}
|
}
|
||||||
|
|
||||||
final Object oldVersion = replicationMode == ReplicationMode.EXCEPTION
|
final Object oldVersion = replicationMode == ReplicationMode.EXCEPTION
|
||||||
|
|
|
@ -572,7 +572,7 @@ public class SessionImpl
|
||||||
|
|
||||||
final EntityEntry e = persistenceContext.getEntry( object );
|
final EntityEntry e = persistenceContext.getEntry( object );
|
||||||
if ( e == null ) {
|
if ( e == null ) {
|
||||||
throw new TransientObjectException( "Given object not associated with the session" );
|
throw new IllegalArgumentException( "Given entity is not associated with the persistence context" );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( e.getStatus().isDeletedOrGone() ) {
|
if ( e.getStatus().isDeletedOrGone() ) {
|
||||||
|
@ -1419,14 +1419,14 @@ public class SessionImpl
|
||||||
final LazyInitializer lazyInitializer = extractLazyInitializer( object );
|
final LazyInitializer lazyInitializer = extractLazyInitializer( object );
|
||||||
if ( lazyInitializer != null ) {
|
if ( lazyInitializer != null ) {
|
||||||
if ( lazyInitializer.getSession() != this ) {
|
if ( lazyInitializer.getSession() != this ) {
|
||||||
throw new TransientObjectException( "The proxy was not associated with this session" );
|
throw new IllegalArgumentException( "Given proxy is not associated with the persistence context" );
|
||||||
}
|
}
|
||||||
return lazyInitializer.getInternalIdentifier();
|
return lazyInitializer.getInternalIdentifier();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
final EntityEntry entry = persistenceContext.getEntry( object );
|
final EntityEntry entry = persistenceContext.getEntry( object );
|
||||||
if ( entry == null ) {
|
if ( entry == null ) {
|
||||||
throw new TransientObjectException( "The instance was not associated with this session" );
|
throw new IllegalArgumentException( "Given entity is not associated with the persistence context" );
|
||||||
}
|
}
|
||||||
return entry.getId();
|
return entry.getId();
|
||||||
}
|
}
|
||||||
|
@ -1682,14 +1682,14 @@ public class SessionImpl
|
||||||
final LazyInitializer lazyInitializer = extractLazyInitializer( object );
|
final LazyInitializer lazyInitializer = extractLazyInitializer( object );
|
||||||
if ( lazyInitializer != null ) {
|
if ( lazyInitializer != null ) {
|
||||||
if ( !persistenceContext.containsProxy( object ) ) {
|
if ( !persistenceContext.containsProxy( object ) ) {
|
||||||
throw new TransientObjectException( "proxy was not associated with the session" );
|
throw new IllegalArgumentException( "Given proxy is not associated with the persistence context" );
|
||||||
}
|
}
|
||||||
object = lazyInitializer.getImplementation();
|
object = lazyInitializer.getImplementation();
|
||||||
}
|
}
|
||||||
|
|
||||||
final EntityEntry entry = persistenceContext.getEntry( object );
|
final EntityEntry entry = persistenceContext.getEntry( object );
|
||||||
if ( entry == null ) {
|
if ( entry == null ) {
|
||||||
throwTransientObjectException( object );
|
throw new IllegalArgumentException( "Given entity is not associated with the persistence context" );
|
||||||
}
|
}
|
||||||
return entry.getPersister().getEntityName();
|
return entry.getPersister().getEntityName();
|
||||||
}
|
}
|
||||||
|
@ -1707,13 +1707,6 @@ public class SessionImpl
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void throwTransientObjectException(Object object) throws HibernateException {
|
|
||||||
throw new TransientObjectException(
|
|
||||||
"object references an unsaved transient instance - save the transient instance before flushing: " +
|
|
||||||
guessEntityName( object )
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String guessEntityName(Object object) throws HibernateException {
|
public String guessEntityName(Object object) throws HibernateException {
|
||||||
checkOpenOrWaitingForAutoClose();
|
checkOpenOrWaitingForAutoClose();
|
||||||
|
|
|
@ -101,10 +101,9 @@ public interface EntityIdentifierMapping extends ValuedModelPart {
|
||||||
// deeper checks...
|
// deeper checks...
|
||||||
final String entityName = findContainingEntityMapping().getEntityName();
|
final String entityName = findContainingEntityMapping().getEntityName();
|
||||||
if ( ForeignKeys.isTransient( entityName, entity, Boolean.FALSE, session ) ) {
|
if ( ForeignKeys.isTransient( entityName, entity, Boolean.FALSE, session ) ) {
|
||||||
throw new TransientObjectException(
|
throw new TransientObjectException( "object references an unsaved transient instance of '"
|
||||||
"object references an unsaved transient instance - save the transient instance before flushing: " +
|
+ (entityName == null ? session.guessEntityName( entity ) : entityName)
|
||||||
(entityName == null ? session.guessEntityName( entity ) : entityName)
|
+ "' save the transient instance before flushing" );
|
||||||
);
|
|
||||||
}
|
}
|
||||||
id = getIdentifier( entity );
|
id = getIdentifier( entity );
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,6 @@ import org.hibernate.FlushMode;
|
||||||
import org.hibernate.HibernateException;
|
import org.hibernate.HibernateException;
|
||||||
import org.hibernate.LazyInitializationException;
|
import org.hibernate.LazyInitializationException;
|
||||||
import org.hibernate.SessionException;
|
import org.hibernate.SessionException;
|
||||||
import org.hibernate.TransientObjectException;
|
|
||||||
import org.hibernate.boot.spi.SessionFactoryOptions;
|
import org.hibernate.boot.spi.SessionFactoryOptions;
|
||||||
import org.hibernate.engine.spi.EntityKey;
|
import org.hibernate.engine.spi.EntityKey;
|
||||||
import org.hibernate.engine.spi.PersistenceContext;
|
import org.hibernate.engine.spi.PersistenceContext;
|
||||||
|
@ -372,7 +371,7 @@ public abstract class AbstractLazyInitializer implements LazyInitializer {
|
||||||
|
|
||||||
private void errorIfReadOnlySettingNotAvailable() {
|
private void errorIfReadOnlySettingNotAvailable() {
|
||||||
if ( session == null ) {
|
if ( session == null ) {
|
||||||
throw new TransientObjectException(
|
throw new IllegalStateException(
|
||||||
"Proxy for [" + entityName + "#" + id + "] is not associated with a session"
|
"Proxy for [" + entityName + "#" + id + "] is not associated with a session"
|
||||||
+ " (the read-only/modifiable setting is only accessible when the proxy is associated with an open session)"
|
+ " (the read-only/modifiable setting is only accessible when the proxy is associated with an open session)"
|
||||||
);
|
);
|
||||||
|
|
|
@ -77,7 +77,7 @@ public class LazyOneToOneRemoveFlushAccessTest {
|
||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
if ( shouldThrow ) {
|
if ( shouldThrow ) {
|
||||||
assertThat( e.getCause() ).isInstanceOf( TransientObjectException.class )
|
assertThat( e.getCause() ).isInstanceOf( TransientObjectException.class )
|
||||||
.hasMessageContaining( "persistent instance references an unsaved transient instance" );
|
.hasMessageContaining( "references an unsaved transient instance" );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
fail( "Test should work with transient strictness disabled, instead threw", e );
|
fail( "Test should work with transient strictness disabled, instead threw", e );
|
||||||
|
|
|
@ -1285,7 +1285,7 @@ public class ReadOnlyProxyTest extends AbstractReadOnlyTest {
|
||||||
s.setReadOnly( dpLoaded, true );
|
s.setReadOnly( dpLoaded, true );
|
||||||
checkReadOnly( s, dpLoaded, true );
|
checkReadOnly( s, dpLoaded, true );
|
||||||
assertFalse( Hibernate.isInitialized( dpLoaded ) );
|
assertFalse( Hibernate.isInitialized( dpLoaded ) );
|
||||||
DataPoint dpMerged = (DataPoint) s.merge( dp );
|
DataPoint dpMerged = s.merge( dp );
|
||||||
assertSame( dpLoaded, dpMerged );
|
assertSame( dpLoaded, dpMerged );
|
||||||
assertTrue( Hibernate.isInitialized( dpLoaded ) );
|
assertTrue( Hibernate.isInitialized( dpLoaded ) );
|
||||||
assertEquals( "changed", dpLoaded.getDescription() );
|
assertEquals( "changed", dpLoaded.getDescription() );
|
||||||
|
@ -1336,7 +1336,7 @@ public class ReadOnlyProxyTest extends AbstractReadOnlyTest {
|
||||||
checkReadOnly( s, dpLoaded, false );
|
checkReadOnly( s, dpLoaded, false );
|
||||||
s.setReadOnly( dpLoaded, true );
|
s.setReadOnly( dpLoaded, true );
|
||||||
checkReadOnly( s, dpLoaded, true );
|
checkReadOnly( s, dpLoaded, true );
|
||||||
DataPoint dpMerged = (DataPoint) s.merge( dp );
|
DataPoint dpMerged = s.merge( dp );
|
||||||
assertSame( dpLoaded, dpMerged );
|
assertSame( dpLoaded, dpMerged );
|
||||||
assertEquals( "changed", dpLoaded.getDescription() );
|
assertEquals( "changed", dpLoaded.getDescription() );
|
||||||
checkReadOnly( s, dpLoaded, true );
|
checkReadOnly( s, dpLoaded, true );
|
||||||
|
@ -1385,7 +1385,7 @@ public class ReadOnlyProxyTest extends AbstractReadOnlyTest {
|
||||||
s.setReadOnly( dpLoaded, true );
|
s.setReadOnly( dpLoaded, true );
|
||||||
checkReadOnly( s, dpLoaded, true );
|
checkReadOnly( s, dpLoaded, true );
|
||||||
assertFalse( Hibernate.isInitialized( dpLoaded ) );
|
assertFalse( Hibernate.isInitialized( dpLoaded ) );
|
||||||
DataPoint dpMerged = (DataPoint) s.merge( dpEntity );
|
DataPoint dpMerged = s.merge( dpEntity );
|
||||||
assertSame( dpLoaded, dpMerged );
|
assertSame( dpLoaded, dpMerged );
|
||||||
assertTrue( Hibernate.isInitialized( dpLoaded ) );
|
assertTrue( Hibernate.isInitialized( dpLoaded ) );
|
||||||
assertEquals( "changed", dpLoaded.getDescription() );
|
assertEquals( "changed", dpLoaded.getDescription() );
|
||||||
|
@ -1437,7 +1437,7 @@ public class ReadOnlyProxyTest extends AbstractReadOnlyTest {
|
||||||
checkReadOnly( s, dpLoaded, false );
|
checkReadOnly( s, dpLoaded, false );
|
||||||
s.setReadOnly( dpLoaded, true );
|
s.setReadOnly( dpLoaded, true );
|
||||||
checkReadOnly( s, dpLoaded, true );
|
checkReadOnly( s, dpLoaded, true );
|
||||||
DataPoint dpMerged = (DataPoint) s.merge( dpEntity );
|
DataPoint dpMerged = s.merge( dpEntity );
|
||||||
assertSame( dpLoaded, dpMerged );
|
assertSame( dpLoaded, dpMerged );
|
||||||
assertEquals( "changed", dpLoaded.getDescription() );
|
assertEquals( "changed", dpLoaded.getDescription() );
|
||||||
checkReadOnly( s, dpLoaded, true );
|
checkReadOnly( s, dpLoaded, true );
|
||||||
|
@ -1484,7 +1484,7 @@ public class ReadOnlyProxyTest extends AbstractReadOnlyTest {
|
||||||
assertFalse( s.isReadOnly( dpEntity ) );
|
assertFalse( s.isReadOnly( dpEntity ) );
|
||||||
s.setReadOnly( dpEntity, true );
|
s.setReadOnly( dpEntity, true );
|
||||||
assertTrue( s.isReadOnly( dpEntity ) );
|
assertTrue( s.isReadOnly( dpEntity ) );
|
||||||
DataPoint dpMerged = (DataPoint) s.merge( dp );
|
DataPoint dpMerged = s.merge( dp );
|
||||||
assertSame( dpEntity, dpMerged );
|
assertSame( dpEntity, dpMerged );
|
||||||
assertEquals( "changed", dpEntity.getDescription() );
|
assertEquals( "changed", dpEntity.getDescription() );
|
||||||
assertTrue( s.isReadOnly( dpEntity ) );
|
assertTrue( s.isReadOnly( dpEntity ) );
|
||||||
|
@ -1695,7 +1695,7 @@ public class ReadOnlyProxyTest extends AbstractReadOnlyTest {
|
||||||
( (HibernateProxy) dp ).getHibernateLazyInitializer().isReadOnly();
|
( (HibernateProxy) dp ).getHibernateLazyInitializer().isReadOnly();
|
||||||
fail( "should have failed because session was detached" );
|
fail( "should have failed because session was detached" );
|
||||||
}
|
}
|
||||||
catch (TransientObjectException ex) {
|
catch (IllegalStateException ex) {
|
||||||
// expected
|
// expected
|
||||||
assertFalse( ( (HibernateProxy) dp ).getHibernateLazyInitializer().isReadOnlySettingAvailable() );
|
assertFalse( ( (HibernateProxy) dp ).getHibernateLazyInitializer().isReadOnlySettingAvailable() );
|
||||||
}
|
}
|
||||||
|
@ -1729,7 +1729,7 @@ public class ReadOnlyProxyTest extends AbstractReadOnlyTest {
|
||||||
s.isReadOnly( dp );
|
s.isReadOnly( dp );
|
||||||
fail( "should have failed because proxy was detached" );
|
fail( "should have failed because proxy was detached" );
|
||||||
}
|
}
|
||||||
catch (TransientObjectException ex) {
|
catch (IllegalStateException ex) {
|
||||||
// expected
|
// expected
|
||||||
assertFalse( ( (HibernateProxy) dp ).getHibernateLazyInitializer().isReadOnlySettingAvailable() );
|
assertFalse( ( (HibernateProxy) dp ).getHibernateLazyInitializer().isReadOnlySettingAvailable() );
|
||||||
}
|
}
|
||||||
|
@ -1759,7 +1759,7 @@ public class ReadOnlyProxyTest extends AbstractReadOnlyTest {
|
||||||
( (HibernateProxy) dp ).getHibernateLazyInitializer().isReadOnly();
|
( (HibernateProxy) dp ).getHibernateLazyInitializer().isReadOnly();
|
||||||
fail( "should have failed because proxy was detached" );
|
fail( "should have failed because proxy was detached" );
|
||||||
}
|
}
|
||||||
catch (TransientObjectException ex) {
|
catch (IllegalStateException ex) {
|
||||||
// expected
|
// expected
|
||||||
assertFalse( ( (HibernateProxy) dp ).getHibernateLazyInitializer().isReadOnlySettingAvailable() );
|
assertFalse( ( (HibernateProxy) dp ).getHibernateLazyInitializer().isReadOnlySettingAvailable() );
|
||||||
}
|
}
|
||||||
|
@ -1823,7 +1823,7 @@ public class ReadOnlyProxyTest extends AbstractReadOnlyTest {
|
||||||
( (HibernateProxy) dp ).getHibernateLazyInitializer().setReadOnly( true );
|
( (HibernateProxy) dp ).getHibernateLazyInitializer().setReadOnly( true );
|
||||||
fail( "should have failed because session was detached" );
|
fail( "should have failed because session was detached" );
|
||||||
}
|
}
|
||||||
catch (TransientObjectException ex) {
|
catch (IllegalStateException ex) {
|
||||||
// expected
|
// expected
|
||||||
assertFalse( ( (HibernateProxy) dp ).getHibernateLazyInitializer().isReadOnlySettingAvailable() );
|
assertFalse( ( (HibernateProxy) dp ).getHibernateLazyInitializer().isReadOnlySettingAvailable() );
|
||||||
}
|
}
|
||||||
|
@ -1892,7 +1892,7 @@ public class ReadOnlyProxyTest extends AbstractReadOnlyTest {
|
||||||
s.setReadOnly( dp, true );
|
s.setReadOnly( dp, true );
|
||||||
fail( "should have failed because proxy was detached" );
|
fail( "should have failed because proxy was detached" );
|
||||||
}
|
}
|
||||||
catch (TransientObjectException ex) {
|
catch (IllegalStateException ex) {
|
||||||
// expected
|
// expected
|
||||||
assertFalse( ( (HibernateProxy) dp ).getHibernateLazyInitializer().isReadOnlySettingAvailable() );
|
assertFalse( ( (HibernateProxy) dp ).getHibernateLazyInitializer().isReadOnlySettingAvailable() );
|
||||||
}
|
}
|
||||||
|
@ -1922,7 +1922,7 @@ public class ReadOnlyProxyTest extends AbstractReadOnlyTest {
|
||||||
( (HibernateProxy) dp ).getHibernateLazyInitializer().setReadOnly( true );
|
( (HibernateProxy) dp ).getHibernateLazyInitializer().setReadOnly( true );
|
||||||
fail( "should have failed because proxy was detached" );
|
fail( "should have failed because proxy was detached" );
|
||||||
}
|
}
|
||||||
catch (TransientObjectException ex) {
|
catch (IllegalStateException ex) {
|
||||||
// expected
|
// expected
|
||||||
assertFalse( ( (HibernateProxy) dp ).getHibernateLazyInitializer().isReadOnlySettingAvailable() );
|
assertFalse( ( (HibernateProxy) dp ).getHibernateLazyInitializer().isReadOnlySettingAvailable() );
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue