HHH-15791 Avoid excessive Session casts to EventSource
This commit is contained in:
parent
6c2bff76c9
commit
329ccaa7a1
|
@ -42,6 +42,7 @@ import org.hibernate.engine.jdbc.env.spi.IdentifierHelperBuilder;
|
||||||
import org.hibernate.engine.jdbc.env.spi.NameQualifierSupport;
|
import org.hibernate.engine.jdbc.env.spi.NameQualifierSupport;
|
||||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
||||||
|
import org.hibernate.event.spi.EventSource;
|
||||||
import org.hibernate.exception.spi.TemplatedViolatedConstraintNameExtractor;
|
import org.hibernate.exception.spi.TemplatedViolatedConstraintNameExtractor;
|
||||||
import org.hibernate.exception.spi.ViolatedConstraintNameExtractor;
|
import org.hibernate.exception.spi.ViolatedConstraintNameExtractor;
|
||||||
import org.hibernate.internal.CoreMessageLogger;
|
import org.hibernate.internal.CoreMessageLogger;
|
||||||
|
@ -704,7 +705,7 @@ public class HSQLLegacyDialect extends Dialect {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void lock(Object id, Object version, Object object, int timeout, SharedSessionContractImplementor session)
|
public void lock(Object id, Object version, Object object, int timeout, EventSource session)
|
||||||
throws StaleObjectStateException, JDBCException {
|
throws StaleObjectStateException, JDBCException {
|
||||||
if ( getLockMode().greaterThan( LockMode.READ ) ) {
|
if ( getLockMode().greaterThan( LockMode.READ ) ) {
|
||||||
LOG.hsqldbSupportsOnlyReadCommittedIsolation();
|
LOG.hsqldbSupportsOnlyReadCommittedIsolation();
|
||||||
|
|
|
@ -19,6 +19,7 @@ import org.hibernate.engine.spi.EntityKey;
|
||||||
import org.hibernate.engine.spi.PersistenceContext;
|
import org.hibernate.engine.spi.PersistenceContext;
|
||||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
||||||
import org.hibernate.engine.spi.Status;
|
import org.hibernate.engine.spi.Status;
|
||||||
|
import org.hibernate.event.spi.EventSource;
|
||||||
import org.hibernate.metamodel.mapping.NaturalIdMapping;
|
import org.hibernate.metamodel.mapping.NaturalIdMapping;
|
||||||
import org.hibernate.metamodel.mapping.PluralAttributeMapping;
|
import org.hibernate.metamodel.mapping.PluralAttributeMapping;
|
||||||
import org.hibernate.persister.collection.CollectionPersister;
|
import org.hibernate.persister.collection.CollectionPersister;
|
||||||
|
@ -52,7 +53,7 @@ public abstract class AbstractEntityInsertAction extends EntityAction {
|
||||||
Object instance,
|
Object instance,
|
||||||
boolean isVersionIncrementDisabled,
|
boolean isVersionIncrementDisabled,
|
||||||
EntityPersister persister,
|
EntityPersister persister,
|
||||||
SharedSessionContractImplementor session) {
|
EventSource session) {
|
||||||
super( session, id, instance, persister );
|
super( session, id, instance, persister );
|
||||||
this.state = state;
|
this.state = state;
|
||||||
this.isVersionIncrementDisabled = isVersionIncrementDisabled;
|
this.isVersionIncrementDisabled = isVersionIncrementDisabled;
|
||||||
|
@ -177,7 +178,7 @@ public abstract class AbstractEntityInsertAction extends EntityAction {
|
||||||
protected abstract EntityKey getEntityKey();
|
protected abstract EntityKey getEntityKey();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void afterDeserialize(SharedSessionContractImplementor session) {
|
public void afterDeserialize(EventSource session) {
|
||||||
super.afterDeserialize( session );
|
super.afterDeserialize( session );
|
||||||
// IMPL NOTE: non-flushed changes code calls this method with session == null...
|
// IMPL NOTE: non-flushed changes code calls this method with session == null...
|
||||||
// guard against NullPointerException
|
// guard against NullPointerException
|
||||||
|
|
|
@ -164,7 +164,7 @@ public class BulkOperationCleanupAction implements Executable, Serializable {
|
||||||
public static void schedule(SharedSessionContractImplementor session, EntityPersister... affectedQueryables) {
|
public static void schedule(SharedSessionContractImplementor session, EntityPersister... affectedQueryables) {
|
||||||
final BulkOperationCleanupAction action = new BulkOperationCleanupAction( session, affectedQueryables );
|
final BulkOperationCleanupAction action = new BulkOperationCleanupAction( session, affectedQueryables );
|
||||||
if ( session.isEventSource() ) {
|
if ( session.isEventSource() ) {
|
||||||
( (EventSource) session ).getActionQueue().addAction( action );
|
session.asEventSource().getActionQueue().addAction( action );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
action.getAfterTransactionCompletionProcess().doAfterTransactionCompletion( true, session );
|
action.getAfterTransactionCompletionProcess().doAfterTransactionCompletion( true, session );
|
||||||
|
@ -174,7 +174,7 @@ public class BulkOperationCleanupAction implements Executable, Serializable {
|
||||||
public static void schedule(SharedSessionContractImplementor session, Set<String> affectedQueryables) {
|
public static void schedule(SharedSessionContractImplementor session, Set<String> affectedQueryables) {
|
||||||
final BulkOperationCleanupAction action = new BulkOperationCleanupAction( session, affectedQueryables );
|
final BulkOperationCleanupAction action = new BulkOperationCleanupAction( session, affectedQueryables );
|
||||||
if ( session.isEventSource() ) {
|
if ( session.isEventSource() ) {
|
||||||
( (EventSource) session ).getActionQueue().addAction( action );
|
session.asEventSource().getActionQueue().addAction( action );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
action.getAfterTransactionCompletionProcess().doAfterTransactionCompletion( true, session );
|
action.getAfterTransactionCompletionProcess().doAfterTransactionCompletion( true, session );
|
||||||
|
@ -302,7 +302,7 @@ public class BulkOperationCleanupAction implements Executable, Serializable {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void afterDeserialize(SharedSessionContractImplementor session) {
|
public void afterDeserialize(EventSource session) {
|
||||||
// nop
|
// nop
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,7 @@ import org.hibernate.pretty.MessageHelper;
|
||||||
public abstract class CollectionAction implements Executable, Serializable, Comparable<CollectionAction> {
|
public abstract class CollectionAction implements Executable, Serializable, Comparable<CollectionAction> {
|
||||||
|
|
||||||
private transient CollectionPersister persister;
|
private transient CollectionPersister persister;
|
||||||
private transient SharedSessionContractImplementor session;
|
private transient EventSource session;
|
||||||
private final PersistentCollection<?> collection;
|
private final PersistentCollection<?> collection;
|
||||||
|
|
||||||
private final Object key;
|
private final Object key;
|
||||||
|
@ -40,7 +40,7 @@ public abstract class CollectionAction implements Executable, Serializable, Comp
|
||||||
final CollectionPersister persister,
|
final CollectionPersister persister,
|
||||||
final PersistentCollection<?> collection,
|
final PersistentCollection<?> collection,
|
||||||
final Object key,
|
final Object key,
|
||||||
final SharedSessionContractImplementor session) {
|
final EventSource session) {
|
||||||
this.persister = persister;
|
this.persister = persister;
|
||||||
this.session = session;
|
this.session = session;
|
||||||
this.key = key;
|
this.key = key;
|
||||||
|
@ -57,7 +57,7 @@ public abstract class CollectionAction implements Executable, Serializable, Comp
|
||||||
*
|
*
|
||||||
* @param session The session being deserialized
|
* @param session The session being deserialized
|
||||||
*/
|
*/
|
||||||
public void afterDeserialize(SharedSessionContractImplementor session) {
|
public void afterDeserialize(EventSource session) {
|
||||||
if ( this.session != null || this.persister != null ) {
|
if ( this.session != null || this.persister != null ) {
|
||||||
throw new IllegalStateException( "already attached to a session." );
|
throw new IllegalStateException( "already attached to a session." );
|
||||||
}
|
}
|
||||||
|
@ -122,7 +122,7 @@ public abstract class CollectionAction implements Executable, Serializable, Comp
|
||||||
return finalKey;
|
return finalKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected final SharedSessionContractImplementor getSession() {
|
protected final EventSource getSession() {
|
||||||
return session;
|
return session;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -185,7 +185,7 @@ public abstract class CollectionAction implements Executable, Serializable, Comp
|
||||||
}
|
}
|
||||||
|
|
||||||
protected EventSource eventSource() {
|
protected EventSource eventSource() {
|
||||||
return (EventSource) getSession();
|
return getSession();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -9,6 +9,7 @@ package org.hibernate.action.internal;
|
||||||
import org.hibernate.HibernateException;
|
import org.hibernate.HibernateException;
|
||||||
import org.hibernate.collection.spi.PersistentCollection;
|
import org.hibernate.collection.spi.PersistentCollection;
|
||||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
||||||
|
import org.hibernate.event.spi.EventSource;
|
||||||
import org.hibernate.event.spi.PostCollectionRecreateEvent;
|
import org.hibernate.event.spi.PostCollectionRecreateEvent;
|
||||||
import org.hibernate.event.spi.PostCollectionRecreateEventListener;
|
import org.hibernate.event.spi.PostCollectionRecreateEventListener;
|
||||||
import org.hibernate.event.spi.PreCollectionRecreateEvent;
|
import org.hibernate.event.spi.PreCollectionRecreateEvent;
|
||||||
|
@ -32,7 +33,7 @@ public final class CollectionRecreateAction extends CollectionAction {
|
||||||
final PersistentCollection<?> collection,
|
final PersistentCollection<?> collection,
|
||||||
final CollectionPersister persister,
|
final CollectionPersister persister,
|
||||||
final Object id,
|
final Object id,
|
||||||
final SharedSessionContractImplementor session) {
|
final EventSource session) {
|
||||||
super( persister, collection, id, session );
|
super( persister, collection, id, session );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,7 @@ import org.hibernate.AssertionFailure;
|
||||||
import org.hibernate.HibernateException;
|
import org.hibernate.HibernateException;
|
||||||
import org.hibernate.collection.spi.PersistentCollection;
|
import org.hibernate.collection.spi.PersistentCollection;
|
||||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
||||||
|
import org.hibernate.event.spi.EventSource;
|
||||||
import org.hibernate.event.spi.PostCollectionRemoveEvent;
|
import org.hibernate.event.spi.PostCollectionRemoveEvent;
|
||||||
import org.hibernate.event.spi.PostCollectionRemoveEventListener;
|
import org.hibernate.event.spi.PostCollectionRemoveEventListener;
|
||||||
import org.hibernate.event.spi.PreCollectionRemoveEvent;
|
import org.hibernate.event.spi.PreCollectionRemoveEvent;
|
||||||
|
@ -43,7 +44,7 @@ public final class CollectionRemoveAction extends CollectionAction {
|
||||||
final CollectionPersister persister,
|
final CollectionPersister persister,
|
||||||
final Object id,
|
final Object id,
|
||||||
final boolean emptySnapshot,
|
final boolean emptySnapshot,
|
||||||
final SharedSessionContractImplementor session) {
|
final EventSource session) {
|
||||||
super( persister, collection, id, session );
|
super( persister, collection, id, session );
|
||||||
if ( collection == null ) {
|
if ( collection == null ) {
|
||||||
throw new AssertionFailure("collection == null");
|
throw new AssertionFailure("collection == null");
|
||||||
|
@ -73,7 +74,7 @@ public final class CollectionRemoveAction extends CollectionAction {
|
||||||
final CollectionPersister persister,
|
final CollectionPersister persister,
|
||||||
final Object id,
|
final Object id,
|
||||||
final boolean emptySnapshot,
|
final boolean emptySnapshot,
|
||||||
final SharedSessionContractImplementor session) {
|
final EventSource session) {
|
||||||
super( persister, null, id, session );
|
super( persister, null, id, session );
|
||||||
if ( affectedOwner == null ) {
|
if ( affectedOwner == null ) {
|
||||||
throw new AssertionFailure("affectedOwner == null");
|
throw new AssertionFailure("affectedOwner == null");
|
||||||
|
@ -93,7 +94,7 @@ public final class CollectionRemoveAction extends CollectionAction {
|
||||||
public CollectionRemoveAction(
|
public CollectionRemoveAction(
|
||||||
final CollectionPersister persister,
|
final CollectionPersister persister,
|
||||||
final Object id,
|
final Object id,
|
||||||
final SharedSessionContractImplementor session) {
|
final EventSource session) {
|
||||||
super( persister, null, id, session );
|
super( persister, null, id, session );
|
||||||
emptySnapshot = false;
|
emptySnapshot = false;
|
||||||
affectedOwner = null;
|
affectedOwner = null;
|
||||||
|
|
|
@ -10,6 +10,7 @@ import org.hibernate.AssertionFailure;
|
||||||
import org.hibernate.HibernateException;
|
import org.hibernate.HibernateException;
|
||||||
import org.hibernate.collection.spi.PersistentCollection;
|
import org.hibernate.collection.spi.PersistentCollection;
|
||||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
||||||
|
import org.hibernate.event.spi.EventSource;
|
||||||
import org.hibernate.event.spi.PostCollectionUpdateEvent;
|
import org.hibernate.event.spi.PostCollectionUpdateEvent;
|
||||||
import org.hibernate.event.spi.PostCollectionUpdateEventListener;
|
import org.hibernate.event.spi.PostCollectionUpdateEventListener;
|
||||||
import org.hibernate.event.spi.PreCollectionUpdateEvent;
|
import org.hibernate.event.spi.PreCollectionUpdateEvent;
|
||||||
|
@ -38,7 +39,7 @@ public final class CollectionUpdateAction extends CollectionAction {
|
||||||
final CollectionPersister persister,
|
final CollectionPersister persister,
|
||||||
final Object id,
|
final Object id,
|
||||||
final boolean emptySnapshot,
|
final boolean emptySnapshot,
|
||||||
final SharedSessionContractImplementor session) {
|
final EventSource session) {
|
||||||
super( persister, collection, id, session );
|
super( persister, collection, id, session );
|
||||||
this.emptySnapshot = emptySnapshot;
|
this.emptySnapshot = emptySnapshot;
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,7 +33,7 @@ public abstract class EntityAction
|
||||||
private final Object id;
|
private final Object id;
|
||||||
|
|
||||||
private transient Object instance;
|
private transient Object instance;
|
||||||
private transient SharedSessionContractImplementor session;
|
private transient EventSource session;
|
||||||
private transient EntityPersister persister;
|
private transient EntityPersister persister;
|
||||||
|
|
||||||
private transient boolean veto;
|
private transient boolean veto;
|
||||||
|
@ -47,7 +47,7 @@ public abstract class EntityAction
|
||||||
* @param persister The entity persister
|
* @param persister The entity persister
|
||||||
*/
|
*/
|
||||||
protected EntityAction(
|
protected EntityAction(
|
||||||
SharedSessionContractImplementor session,
|
EventSource session,
|
||||||
Object id,
|
Object id,
|
||||||
Object instance,
|
Object instance,
|
||||||
EntityPersister persister) {
|
EntityPersister persister) {
|
||||||
|
@ -123,7 +123,7 @@ public abstract class EntityAction
|
||||||
*
|
*
|
||||||
* @return The session from which this action originated.
|
* @return The session from which this action originated.
|
||||||
*/
|
*/
|
||||||
public final SharedSessionContractImplementor getSession() {
|
public final EventSource getSession() {
|
||||||
return session;
|
return session;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -167,7 +167,7 @@ public abstract class EntityAction
|
||||||
* @param session The session being deserialized
|
* @param session The session being deserialized
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void afterDeserialize(SharedSessionContractImplementor session) {
|
public void afterDeserialize(EventSource session) {
|
||||||
if ( this.session != null || this.persister != null ) {
|
if ( this.session != null || this.persister != null ) {
|
||||||
throw new IllegalStateException( "already attached to a session." );
|
throw new IllegalStateException( "already attached to a session." );
|
||||||
}
|
}
|
||||||
|
@ -181,7 +181,7 @@ public abstract class EntityAction
|
||||||
}
|
}
|
||||||
|
|
||||||
protected EventSource eventSource() {
|
protected EventSource eventSource() {
|
||||||
return (EventSource) getSession();
|
return getSession();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -16,6 +16,7 @@ import org.hibernate.engine.spi.PersistenceContext;
|
||||||
import org.hibernate.engine.spi.SessionImplementor;
|
import org.hibernate.engine.spi.SessionImplementor;
|
||||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
||||||
import org.hibernate.event.service.spi.EventListenerGroup;
|
import org.hibernate.event.service.spi.EventListenerGroup;
|
||||||
|
import org.hibernate.event.spi.EventSource;
|
||||||
import org.hibernate.event.spi.PostCommitDeleteEventListener;
|
import org.hibernate.event.spi.PostCommitDeleteEventListener;
|
||||||
import org.hibernate.event.spi.PostDeleteEvent;
|
import org.hibernate.event.spi.PostDeleteEvent;
|
||||||
import org.hibernate.event.spi.PostDeleteEventListener;
|
import org.hibernate.event.spi.PostDeleteEventListener;
|
||||||
|
@ -55,7 +56,7 @@ public class EntityDeleteAction extends EntityAction {
|
||||||
final Object instance,
|
final Object instance,
|
||||||
final EntityPersister persister,
|
final EntityPersister persister,
|
||||||
final boolean isCascadeDeleteEnabled,
|
final boolean isCascadeDeleteEnabled,
|
||||||
final SessionImplementor session) {
|
final EventSource session) {
|
||||||
super( session, id, instance, persister );
|
super( session, id, instance, persister );
|
||||||
this.version = version;
|
this.version = version;
|
||||||
this.isCascadeDeleteEnabled = isCascadeDeleteEnabled;
|
this.isCascadeDeleteEnabled = isCascadeDeleteEnabled;
|
||||||
|
@ -79,7 +80,7 @@ public class EntityDeleteAction extends EntityAction {
|
||||||
* @param persister The entity persister
|
* @param persister The entity persister
|
||||||
* @param session The session
|
* @param session The session
|
||||||
*/
|
*/
|
||||||
public EntityDeleteAction(final Object id, final EntityPersister persister, final SessionImplementor session) {
|
public EntityDeleteAction(final Object id, final EntityPersister persister, final EventSource session) {
|
||||||
super( session, id, null, persister );
|
super( session, id, null, persister );
|
||||||
version = null;
|
version = null;
|
||||||
isCascadeDeleteEnabled = false;
|
isCascadeDeleteEnabled = false;
|
||||||
|
|
|
@ -12,6 +12,7 @@ import org.hibernate.engine.spi.EntityKey;
|
||||||
import org.hibernate.engine.spi.PersistenceContext;
|
import org.hibernate.engine.spi.PersistenceContext;
|
||||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
||||||
import org.hibernate.event.service.spi.EventListenerGroup;
|
import org.hibernate.event.service.spi.EventListenerGroup;
|
||||||
|
import org.hibernate.event.spi.EventSource;
|
||||||
import org.hibernate.event.spi.PostCommitInsertEventListener;
|
import org.hibernate.event.spi.PostCommitInsertEventListener;
|
||||||
import org.hibernate.event.spi.PostInsertEvent;
|
import org.hibernate.event.spi.PostInsertEvent;
|
||||||
import org.hibernate.event.spi.PostInsertEventListener;
|
import org.hibernate.event.spi.PostInsertEventListener;
|
||||||
|
@ -49,7 +50,7 @@ public class EntityIdentityInsertAction extends AbstractEntityInsertAction {
|
||||||
final Object instance,
|
final Object instance,
|
||||||
final EntityPersister persister,
|
final EntityPersister persister,
|
||||||
final boolean isVersionIncrementDisabled,
|
final boolean isVersionIncrementDisabled,
|
||||||
final SharedSessionContractImplementor session,
|
final EventSource session,
|
||||||
final boolean isDelayed) {
|
final boolean isDelayed) {
|
||||||
super(
|
super(
|
||||||
isDelayed ? generateDelayedPostInsertIdentifier() : null,
|
isDelayed ? generateDelayedPostInsertIdentifier() : null,
|
||||||
|
|
|
@ -18,6 +18,7 @@ import org.hibernate.engine.spi.SessionEventListenerManager;
|
||||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
||||||
import org.hibernate.event.service.spi.EventListenerGroup;
|
import org.hibernate.event.service.spi.EventListenerGroup;
|
||||||
|
import org.hibernate.event.spi.EventSource;
|
||||||
import org.hibernate.event.spi.PostCommitInsertEventListener;
|
import org.hibernate.event.spi.PostCommitInsertEventListener;
|
||||||
import org.hibernate.event.spi.PostInsertEvent;
|
import org.hibernate.event.spi.PostInsertEvent;
|
||||||
import org.hibernate.event.spi.PostInsertEventListener;
|
import org.hibernate.event.spi.PostInsertEventListener;
|
||||||
|
@ -54,7 +55,7 @@ public class EntityInsertAction extends AbstractEntityInsertAction {
|
||||||
final Object version,
|
final Object version,
|
||||||
final EntityPersister persister,
|
final EntityPersister persister,
|
||||||
final boolean isVersionIncrementDisabled,
|
final boolean isVersionIncrementDisabled,
|
||||||
final SharedSessionContractImplementor session) {
|
final EventSource session) {
|
||||||
super( id, state, instance, isVersionIncrementDisabled, persister, session );
|
super( id, state, instance, isVersionIncrementDisabled, persister, session );
|
||||||
this.version = version;
|
this.version = version;
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,7 @@ import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
||||||
import org.hibernate.engine.spi.Status;
|
import org.hibernate.engine.spi.Status;
|
||||||
import org.hibernate.event.service.spi.EventListenerGroup;
|
import org.hibernate.event.service.spi.EventListenerGroup;
|
||||||
|
import org.hibernate.event.spi.EventSource;
|
||||||
import org.hibernate.event.spi.PostCommitUpdateEventListener;
|
import org.hibernate.event.spi.PostCommitUpdateEventListener;
|
||||||
import org.hibernate.event.spi.PostUpdateEvent;
|
import org.hibernate.event.spi.PostUpdateEvent;
|
||||||
import org.hibernate.event.spi.PostUpdateEventListener;
|
import org.hibernate.event.spi.PostUpdateEventListener;
|
||||||
|
@ -76,7 +77,7 @@ public class EntityUpdateAction extends EntityAction {
|
||||||
final Object instance,
|
final Object instance,
|
||||||
final Object rowId,
|
final Object rowId,
|
||||||
final EntityPersister persister,
|
final EntityPersister persister,
|
||||||
final SharedSessionContractImplementor session) {
|
final EventSource session) {
|
||||||
super( session, id, instance, persister );
|
super( session, id, instance, persister );
|
||||||
this.state = state;
|
this.state = state;
|
||||||
this.previousState = previousState;
|
this.previousState = previousState;
|
||||||
|
|
|
@ -6,14 +6,14 @@
|
||||||
*/
|
*/
|
||||||
package org.hibernate.action.internal;
|
package org.hibernate.action.internal;
|
||||||
|
|
||||||
import org.hibernate.engine.spi.SessionImplementor;
|
import org.hibernate.event.spi.EventSource;
|
||||||
import org.hibernate.persister.entity.EntityPersister;
|
import org.hibernate.persister.entity.EntityPersister;
|
||||||
|
|
||||||
public final class OrphanRemovalAction extends EntityDeleteAction {
|
public final class OrphanRemovalAction extends EntityDeleteAction {
|
||||||
|
|
||||||
public OrphanRemovalAction(
|
public OrphanRemovalAction(
|
||||||
Object id, Object[] state, Object version, Object instance,
|
Object id, Object[] state, Object version, Object instance,
|
||||||
EntityPersister persister, boolean isCascadeDeleteEnabled, SessionImplementor session) {
|
EntityPersister persister, boolean isCascadeDeleteEnabled, EventSource session) {
|
||||||
super( id, state, version, instance, persister, isCascadeDeleteEnabled, session );
|
super( id, state, version, instance, persister, isCascadeDeleteEnabled, session );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,6 +11,7 @@ import org.hibernate.collection.spi.AbstractPersistentCollection;
|
||||||
import org.hibernate.collection.spi.PersistentCollection;
|
import org.hibernate.collection.spi.PersistentCollection;
|
||||||
import org.hibernate.engine.spi.CollectionEntry;
|
import org.hibernate.engine.spi.CollectionEntry;
|
||||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
||||||
|
import org.hibernate.event.spi.EventSource;
|
||||||
import org.hibernate.persister.collection.CollectionPersister;
|
import org.hibernate.persister.collection.CollectionPersister;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -35,7 +36,7 @@ public final class QueuedOperationCollectionAction extends CollectionAction {
|
||||||
final PersistentCollection<?> collection,
|
final PersistentCollection<?> collection,
|
||||||
final CollectionPersister persister,
|
final CollectionPersister persister,
|
||||||
final Object id,
|
final Object id,
|
||||||
final SharedSessionContractImplementor session) {
|
final EventSource session) {
|
||||||
super( persister, collection, id, session );
|
super( persister, collection, id, session );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,7 @@ import org.hibernate.engine.spi.EntityEntry;
|
||||||
import org.hibernate.engine.spi.SessionImplementor;
|
import org.hibernate.engine.spi.SessionImplementor;
|
||||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
||||||
import org.hibernate.engine.spi.Status;
|
import org.hibernate.engine.spi.Status;
|
||||||
|
import org.hibernate.event.spi.EventSource;
|
||||||
import org.hibernate.internal.CoreMessageLogger;
|
import org.hibernate.internal.CoreMessageLogger;
|
||||||
import org.hibernate.internal.util.collections.IdentitySet;
|
import org.hibernate.internal.util.collections.IdentitySet;
|
||||||
import org.hibernate.pretty.MessageHelper;
|
import org.hibernate.pretty.MessageHelper;
|
||||||
|
@ -293,7 +294,7 @@ public class UnresolvedEntityInsertActions {
|
||||||
*/
|
*/
|
||||||
public static UnresolvedEntityInsertActions deserialize(
|
public static UnresolvedEntityInsertActions deserialize(
|
||||||
ObjectInputStream ois,
|
ObjectInputStream ois,
|
||||||
SessionImplementor session) throws IOException, ClassNotFoundException {
|
EventSource session) throws IOException, ClassNotFoundException {
|
||||||
|
|
||||||
final UnresolvedEntityInsertActions rtn = new UnresolvedEntityInsertActions();
|
final UnresolvedEntityInsertActions rtn = new UnresolvedEntityInsertActions();
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@ package org.hibernate.action.spi;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
import org.hibernate.HibernateException;
|
import org.hibernate.HibernateException;
|
||||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
import org.hibernate.event.spi.EventSource;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An operation which may be scheduled for later execution. Usually, the operation is a database
|
* An operation which may be scheduled for later execution. Usually, the operation is a database
|
||||||
|
@ -59,7 +59,7 @@ public interface Executable {
|
||||||
/**
|
/**
|
||||||
* Reconnect to session after deserialization
|
* Reconnect to session after deserialization
|
||||||
*
|
*
|
||||||
* @param session The session being deserialized
|
* @param session The session being deserialized; must be an EventSource
|
||||||
*/
|
*/
|
||||||
void afterDeserialize(SharedSessionContractImplementor session);
|
void afterDeserialize(EventSource session);
|
||||||
}
|
}
|
||||||
|
|
|
@ -196,7 +196,7 @@ public class CollectionCacheInvalidator
|
||||||
CollectionPersister persister,
|
CollectionPersister persister,
|
||||||
PersistentCollection<?> collection,
|
PersistentCollection<?> collection,
|
||||||
Object key,
|
Object key,
|
||||||
SharedSessionContractImplementor session) {
|
EventSource session) {
|
||||||
super( persister, collection, key, session );
|
super( persister, collection, key, session );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -208,7 +208,6 @@ public class CollectionCacheInvalidator
|
||||||
beforeExecutions();
|
beforeExecutions();
|
||||||
return getAfterTransactionCompletionProcess();
|
return getAfterTransactionCompletionProcess();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,7 @@ import org.hibernate.dialect.unique.UniqueDelegate;
|
||||||
import org.hibernate.engine.jdbc.dialect.spi.DialectResolutionInfo;
|
import org.hibernate.engine.jdbc.dialect.spi.DialectResolutionInfo;
|
||||||
import org.hibernate.engine.jdbc.env.spi.SchemaNameResolver;
|
import org.hibernate.engine.jdbc.env.spi.SchemaNameResolver;
|
||||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
import org.hibernate.event.spi.EventSource;
|
||||||
import org.hibernate.internal.util.collections.ArrayHelper;
|
import org.hibernate.internal.util.collections.ArrayHelper;
|
||||||
import org.hibernate.mapping.Column;
|
import org.hibernate.mapping.Column;
|
||||||
import org.hibernate.mapping.Constraint;
|
import org.hibernate.mapping.Constraint;
|
||||||
|
@ -877,7 +877,7 @@ public class SpannerDialect extends Dialect {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void lock(
|
public void lock(
|
||||||
Object id, Object version, Object object, int timeout, SharedSessionContractImplementor session)
|
Object id, Object version, Object object, int timeout, EventSource session)
|
||||||
throws StaleObjectStateException, LockingStrategyException {
|
throws StaleObjectStateException, LockingStrategyException {
|
||||||
// Do nothing. Cloud Spanner doesn't have have locking strategies.
|
// Do nothing. Cloud Spanner doesn't have have locking strategies.
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
package org.hibernate.dialect.lock;
|
package org.hibernate.dialect.lock;
|
||||||
|
|
||||||
import org.hibernate.StaleObjectStateException;
|
import org.hibernate.StaleObjectStateException;
|
||||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
import org.hibernate.event.spi.EventSource;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A strategy abstraction for how locks are obtained in the underlying database.
|
* A strategy abstraction for how locks are obtained in the underlying database.
|
||||||
|
@ -37,6 +37,6 @@ public interface LockingStrategy {
|
||||||
* the requested lock.
|
* the requested lock.
|
||||||
* @throws LockingStrategyException Indicates a failure in the lock attempt
|
* @throws LockingStrategyException Indicates a failure in the lock attempt
|
||||||
*/
|
*/
|
||||||
void lock(Object id, Object version, Object object, int timeout, SharedSessionContractImplementor session)
|
void lock(Object id, Object version, Object object, int timeout, EventSource session)
|
||||||
throws StaleObjectStateException, LockingStrategyException;
|
throws StaleObjectStateException, LockingStrategyException;
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,6 @@ import org.hibernate.HibernateException;
|
||||||
import org.hibernate.LockMode;
|
import org.hibernate.LockMode;
|
||||||
import org.hibernate.action.internal.EntityIncrementVersionProcess;
|
import org.hibernate.action.internal.EntityIncrementVersionProcess;
|
||||||
import org.hibernate.engine.spi.EntityEntry;
|
import org.hibernate.engine.spi.EntityEntry;
|
||||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
|
||||||
import org.hibernate.event.spi.EventSource;
|
import org.hibernate.event.spi.EventSource;
|
||||||
import org.hibernate.persister.entity.Lockable;
|
import org.hibernate.persister.entity.Lockable;
|
||||||
|
|
||||||
|
@ -43,13 +42,13 @@ public class OptimisticForceIncrementLockingStrategy implements LockingStrategy
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void lock(Object id, Object version, Object object, int timeout, SharedSessionContractImplementor session) {
|
public void lock(Object id, Object version, Object object, int timeout, EventSource session) {
|
||||||
if ( !lockable.isVersioned() ) {
|
if ( !lockable.isVersioned() ) {
|
||||||
throw new HibernateException( "[" + lockMode + "] not supported for non-versioned entities [" + lockable.getEntityName() + "]" );
|
throw new HibernateException( "[" + lockMode + "] not supported for non-versioned entities [" + lockable.getEntityName() + "]" );
|
||||||
}
|
}
|
||||||
final EntityEntry entry = session.getPersistenceContextInternal().getEntry( object );
|
final EntityEntry entry = session.getPersistenceContextInternal().getEntry( object );
|
||||||
// Register the EntityIncrementVersionProcess action to run just prior to transaction commit.
|
// Register the EntityIncrementVersionProcess action to run just prior to transaction commit.
|
||||||
( (EventSource) session ).getActionQueue().registerProcess( new EntityIncrementVersionProcess( object ) );
|
session.getActionQueue().registerProcess( new EntityIncrementVersionProcess( object ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
protected LockMode getLockMode() {
|
protected LockMode getLockMode() {
|
||||||
|
|
|
@ -9,7 +9,6 @@ package org.hibernate.dialect.lock;
|
||||||
import org.hibernate.HibernateException;
|
import org.hibernate.HibernateException;
|
||||||
import org.hibernate.LockMode;
|
import org.hibernate.LockMode;
|
||||||
import org.hibernate.action.internal.EntityVerifyVersionProcess;
|
import org.hibernate.action.internal.EntityVerifyVersionProcess;
|
||||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
|
||||||
import org.hibernate.event.spi.EventSource;
|
import org.hibernate.event.spi.EventSource;
|
||||||
import org.hibernate.persister.entity.Lockable;
|
import org.hibernate.persister.entity.Lockable;
|
||||||
|
|
||||||
|
@ -41,12 +40,12 @@ public class OptimisticLockingStrategy implements LockingStrategy {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void lock(Object id, Object version, Object object, int timeout, SharedSessionContractImplementor session) {
|
public void lock(Object id, Object version, Object object, int timeout, EventSource session) {
|
||||||
if ( !lockable.isVersioned() ) {
|
if ( !lockable.isVersioned() ) {
|
||||||
throw new OptimisticEntityLockException( object, "[" + lockMode + "] not supported for non-versioned entities [" + lockable.getEntityName() + "]" );
|
throw new OptimisticEntityLockException( object, "[" + lockMode + "] not supported for non-versioned entities [" + lockable.getEntityName() + "]" );
|
||||||
}
|
}
|
||||||
// Register the EntityVerifyVersionProcess action to run just prior to transaction commit.
|
// Register the EntityVerifyVersionProcess action to run just prior to transaction commit.
|
||||||
( (EventSource) session ).getActionQueue().registerProcess( new EntityVerifyVersionProcess( object ) );
|
session.getActionQueue().registerProcess( new EntityVerifyVersionProcess( object ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
protected LockMode getLockMode() {
|
protected LockMode getLockMode() {
|
||||||
|
|
|
@ -9,7 +9,7 @@ package org.hibernate.dialect.lock;
|
||||||
import org.hibernate.HibernateException;
|
import org.hibernate.HibernateException;
|
||||||
import org.hibernate.LockMode;
|
import org.hibernate.LockMode;
|
||||||
import org.hibernate.engine.spi.EntityEntry;
|
import org.hibernate.engine.spi.EntityEntry;
|
||||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
import org.hibernate.event.spi.EventSource;
|
||||||
import org.hibernate.persister.entity.EntityPersister;
|
import org.hibernate.persister.entity.EntityPersister;
|
||||||
import org.hibernate.persister.entity.Lockable;
|
import org.hibernate.persister.entity.Lockable;
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ public class PessimisticForceIncrementLockingStrategy implements LockingStrategy
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void lock(Object id, Object version, Object object, int timeout, SharedSessionContractImplementor session) {
|
public void lock(Object id, Object version, Object object, int timeout, EventSource session) {
|
||||||
if ( !lockable.isVersioned() ) {
|
if ( !lockable.isVersioned() ) {
|
||||||
throw new HibernateException( "[" + lockMode + "] not supported for non-versioned entities [" + lockable.getEntityName() + "]" );
|
throw new HibernateException( "[" + lockMode + "] not supported for non-versioned entities [" + lockable.getEntityName() + "]" );
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,7 @@ import org.hibernate.LockOptions;
|
||||||
import org.hibernate.StaleObjectStateException;
|
import org.hibernate.StaleObjectStateException;
|
||||||
import org.hibernate.engine.jdbc.spi.JdbcCoordinator;
|
import org.hibernate.engine.jdbc.spi.JdbcCoordinator;
|
||||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
import org.hibernate.event.spi.EventSource;
|
||||||
import org.hibernate.persister.entity.Lockable;
|
import org.hibernate.persister.entity.Lockable;
|
||||||
import org.hibernate.pretty.MessageHelper;
|
import org.hibernate.pretty.MessageHelper;
|
||||||
import org.hibernate.sql.SimpleSelect;
|
import org.hibernate.sql.SimpleSelect;
|
||||||
|
@ -53,7 +53,7 @@ public class PessimisticReadSelectLockingStrategy extends AbstractSelectLockingS
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void lock(Object id, Object version, Object object, int timeout, SharedSessionContractImplementor session) {
|
public void lock(Object id, Object version, Object object, int timeout, EventSource session) {
|
||||||
final String sql = determineSql( timeout );
|
final String sql = determineSql( timeout );
|
||||||
final SessionFactoryImplementor factory = session.getFactory();
|
final SessionFactoryImplementor factory = session.getFactory();
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -15,7 +15,7 @@ import org.hibernate.LockMode;
|
||||||
import org.hibernate.StaleObjectStateException;
|
import org.hibernate.StaleObjectStateException;
|
||||||
import org.hibernate.engine.jdbc.spi.JdbcCoordinator;
|
import org.hibernate.engine.jdbc.spi.JdbcCoordinator;
|
||||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
import org.hibernate.event.spi.EventSource;
|
||||||
import org.hibernate.internal.CoreMessageLogger;
|
import org.hibernate.internal.CoreMessageLogger;
|
||||||
import org.hibernate.persister.entity.Lockable;
|
import org.hibernate.persister.entity.Lockable;
|
||||||
import org.hibernate.pretty.MessageHelper;
|
import org.hibernate.pretty.MessageHelper;
|
||||||
|
@ -69,7 +69,7 @@ public class PessimisticReadUpdateLockingStrategy implements LockingStrategy {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void lock(Object id, Object version, Object object, int timeout, SharedSessionContractImplementor session) {
|
public void lock(Object id, Object version, Object object, int timeout, EventSource session) {
|
||||||
if ( !lockable.isVersioned() ) {
|
if ( !lockable.isVersioned() ) {
|
||||||
throw new HibernateException( "write locks via update not supported for non-versioned entities [" + lockable.getEntityName() + "]" );
|
throw new HibernateException( "write locks via update not supported for non-versioned entities [" + lockable.getEntityName() + "]" );
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,7 @@ import org.hibernate.LockOptions;
|
||||||
import org.hibernate.StaleObjectStateException;
|
import org.hibernate.StaleObjectStateException;
|
||||||
import org.hibernate.engine.jdbc.spi.JdbcCoordinator;
|
import org.hibernate.engine.jdbc.spi.JdbcCoordinator;
|
||||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
import org.hibernate.event.spi.EventSource;
|
||||||
import org.hibernate.persister.entity.Lockable;
|
import org.hibernate.persister.entity.Lockable;
|
||||||
import org.hibernate.pretty.MessageHelper;
|
import org.hibernate.pretty.MessageHelper;
|
||||||
import org.hibernate.sql.SimpleSelect;
|
import org.hibernate.sql.SimpleSelect;
|
||||||
|
@ -52,7 +52,7 @@ public class PessimisticWriteSelectLockingStrategy extends AbstractSelectLocking
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void lock(Object id, Object version, Object object, int timeout, SharedSessionContractImplementor session) {
|
public void lock(Object id, Object version, Object object, int timeout, EventSource session) {
|
||||||
final String sql = determineSql( timeout );
|
final String sql = determineSql( timeout );
|
||||||
final SessionFactoryImplementor factory = session.getFactory();
|
final SessionFactoryImplementor factory = session.getFactory();
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -15,7 +15,7 @@ import org.hibernate.LockMode;
|
||||||
import org.hibernate.StaleObjectStateException;
|
import org.hibernate.StaleObjectStateException;
|
||||||
import org.hibernate.engine.jdbc.spi.JdbcCoordinator;
|
import org.hibernate.engine.jdbc.spi.JdbcCoordinator;
|
||||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
import org.hibernate.event.spi.EventSource;
|
||||||
import org.hibernate.internal.CoreMessageLogger;
|
import org.hibernate.internal.CoreMessageLogger;
|
||||||
import org.hibernate.persister.entity.Lockable;
|
import org.hibernate.persister.entity.Lockable;
|
||||||
import org.hibernate.pretty.MessageHelper;
|
import org.hibernate.pretty.MessageHelper;
|
||||||
|
@ -68,7 +68,7 @@ public class PessimisticWriteUpdateLockingStrategy implements LockingStrategy {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void lock(Object id, Object version, Object object, int timeout, SharedSessionContractImplementor session) {
|
public void lock(Object id, Object version, Object object, int timeout, EventSource session) {
|
||||||
if ( !lockable.isVersioned() ) {
|
if ( !lockable.isVersioned() ) {
|
||||||
throw new HibernateException( "write locks via update not supported for non-versioned entities [" + lockable.getEntityName() + "]" );
|
throw new HibernateException( "write locks via update not supported for non-versioned entities [" + lockable.getEntityName() + "]" );
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,7 @@ import org.hibernate.LockOptions;
|
||||||
import org.hibernate.StaleObjectStateException;
|
import org.hibernate.StaleObjectStateException;
|
||||||
import org.hibernate.engine.jdbc.spi.JdbcCoordinator;
|
import org.hibernate.engine.jdbc.spi.JdbcCoordinator;
|
||||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
import org.hibernate.event.spi.EventSource;
|
||||||
import org.hibernate.persister.entity.Lockable;
|
import org.hibernate.persister.entity.Lockable;
|
||||||
import org.hibernate.pretty.MessageHelper;
|
import org.hibernate.pretty.MessageHelper;
|
||||||
import org.hibernate.sql.SimpleSelect;
|
import org.hibernate.sql.SimpleSelect;
|
||||||
|
@ -51,7 +51,7 @@ public class SelectLockingStrategy extends AbstractSelectLockingStrategy {
|
||||||
Object version,
|
Object version,
|
||||||
Object object,
|
Object object,
|
||||||
int timeout,
|
int timeout,
|
||||||
SharedSessionContractImplementor session) throws StaleObjectStateException, JDBCException {
|
EventSource session) throws StaleObjectStateException, JDBCException {
|
||||||
final String sql = determineSql( timeout );
|
final String sql = determineSql( timeout );
|
||||||
final SessionFactoryImplementor factory = session.getFactory();
|
final SessionFactoryImplementor factory = session.getFactory();
|
||||||
final Lockable lockable = getLockable();
|
final Lockable lockable = getLockable();
|
||||||
|
|
|
@ -15,7 +15,7 @@ import org.hibernate.LockMode;
|
||||||
import org.hibernate.StaleObjectStateException;
|
import org.hibernate.StaleObjectStateException;
|
||||||
import org.hibernate.engine.jdbc.spi.JdbcCoordinator;
|
import org.hibernate.engine.jdbc.spi.JdbcCoordinator;
|
||||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
import org.hibernate.event.spi.EventSource;
|
||||||
import org.hibernate.internal.CoreMessageLogger;
|
import org.hibernate.internal.CoreMessageLogger;
|
||||||
import org.hibernate.persister.entity.Lockable;
|
import org.hibernate.persister.entity.Lockable;
|
||||||
import org.hibernate.pretty.MessageHelper;
|
import org.hibernate.pretty.MessageHelper;
|
||||||
|
@ -72,7 +72,7 @@ public class UpdateLockingStrategy implements LockingStrategy {
|
||||||
Object version,
|
Object version,
|
||||||
Object object,
|
Object object,
|
||||||
int timeout,
|
int timeout,
|
||||||
SharedSessionContractImplementor session) throws StaleObjectStateException, JDBCException {
|
EventSource session) throws StaleObjectStateException, JDBCException {
|
||||||
final String lockableEntityName = lockable.getEntityName();
|
final String lockableEntityName = lockable.getEntityName();
|
||||||
if ( !lockable.isVersioned() ) {
|
if ( !lockable.isVersioned() ) {
|
||||||
throw new HibernateException( "write locks via update not supported for non-versioned entities [" + lockableEntityName + "]" );
|
throw new HibernateException( "write locks via update not supported for non-versioned entities [" + lockableEntityName + "]" );
|
||||||
|
|
|
@ -270,23 +270,23 @@ public class NaturalIdResolutionsImpl implements NaturalIdResolutions, Serializa
|
||||||
if ( cacheAccess == null ) {
|
if ( cacheAccess == null ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
final SharedSessionContractImplementor s = session();
|
||||||
final EntityMappingType rootEntityDescriptor = persister.getRootEntityDescriptor();
|
final EntityMappingType rootEntityDescriptor = persister.getRootEntityDescriptor();
|
||||||
final EntityPersister rootEntityPersister = rootEntityDescriptor.getEntityPersister();
|
final EntityPersister rootEntityPersister = rootEntityDescriptor.getEntityPersister();
|
||||||
|
|
||||||
final Object cacheKey = cacheAccess.generateCacheKey( naturalIdValues, rootEntityPersister, session() );
|
final Object cacheKey = cacheAccess.generateCacheKey( naturalIdValues, rootEntityPersister, s );
|
||||||
|
|
||||||
final SessionFactoryImplementor factory = session().getFactory();
|
final SessionFactoryImplementor factory = s.getFactory();
|
||||||
final StatisticsImplementor statistics = factory.getStatistics();
|
final StatisticsImplementor statistics = factory.getStatistics();
|
||||||
|
|
||||||
switch ( source ) {
|
switch ( source ) {
|
||||||
case LOAD: {
|
case LOAD: {
|
||||||
if ( CacheHelper.fromSharedCache( session(), cacheKey, cacheAccess ) != null ) {
|
if ( CacheHelper.fromSharedCache( s, cacheKey, cacheAccess ) != null ) {
|
||||||
// prevent identical re-cachings
|
// prevent identical re-cachings
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final boolean put = cacheAccess.putFromLoad(
|
final boolean put = cacheAccess.putFromLoad(
|
||||||
session(),
|
s,
|
||||||
cacheKey,
|
cacheKey,
|
||||||
id,
|
id,
|
||||||
null
|
null
|
||||||
|
@ -302,7 +302,7 @@ public class NaturalIdResolutionsImpl implements NaturalIdResolutions, Serializa
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case INSERT: {
|
case INSERT: {
|
||||||
final boolean put = cacheAccess.insert( session(), cacheKey, id );
|
final boolean put = cacheAccess.insert( s, cacheKey, id );
|
||||||
if ( put && statistics.isStatisticsEnabled() ) {
|
if ( put && statistics.isStatisticsEnabled() ) {
|
||||||
statistics.naturalIdCachePut(
|
statistics.naturalIdCachePut(
|
||||||
rootEntityDescriptor.getNavigableRole(),
|
rootEntityDescriptor.getNavigableRole(),
|
||||||
|
@ -310,7 +310,7 @@ public class NaturalIdResolutionsImpl implements NaturalIdResolutions, Serializa
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
( (EventSource) session() ).getActionQueue().registerProcess(
|
s.asEventSource().getActionQueue().registerProcess(
|
||||||
(success, session) -> {
|
(success, session) -> {
|
||||||
if ( success ) {
|
if ( success ) {
|
||||||
final boolean put1 = cacheAccess.afterInsert( session, cacheKey, id );
|
final boolean put1 = cacheAccess.afterInsert( session, cacheKey, id );
|
||||||
|
@ -330,16 +330,16 @@ public class NaturalIdResolutionsImpl implements NaturalIdResolutions, Serializa
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case UPDATE: {
|
case UPDATE: {
|
||||||
final Object previousCacheKey = cacheAccess.generateCacheKey( previousNaturalIdValues, rootEntityPersister, session() );
|
final Object previousCacheKey = cacheAccess.generateCacheKey( previousNaturalIdValues, rootEntityPersister, s );
|
||||||
if ( cacheKey.equals( previousCacheKey ) ) {
|
if ( cacheKey.equals( previousCacheKey ) ) {
|
||||||
// prevent identical re-caching, solves HHH-7309
|
// prevent identical re-caching, solves HHH-7309
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final SoftLock removalLock = cacheAccess.lockItem( session(), previousCacheKey, null );
|
final SoftLock removalLock = cacheAccess.lockItem( s, previousCacheKey, null );
|
||||||
cacheAccess.remove( session(), previousCacheKey);
|
cacheAccess.remove( s, previousCacheKey);
|
||||||
|
|
||||||
final SoftLock lock = cacheAccess.lockItem( session(), cacheKey, null );
|
final SoftLock lock = cacheAccess.lockItem( s, cacheKey, null );
|
||||||
final boolean put = cacheAccess.update( session(), cacheKey, id );
|
final boolean put = cacheAccess.update( s, cacheKey, id );
|
||||||
if ( put && statistics.isStatisticsEnabled() ) {
|
if ( put && statistics.isStatisticsEnabled() ) {
|
||||||
statistics.naturalIdCachePut(
|
statistics.naturalIdCachePut(
|
||||||
rootEntityDescriptor.getNavigableRole(),
|
rootEntityDescriptor.getNavigableRole(),
|
||||||
|
@ -347,12 +347,12 @@ public class NaturalIdResolutionsImpl implements NaturalIdResolutions, Serializa
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
( (EventSource) session() ).getActionQueue().registerProcess(
|
s.asEventSource().getActionQueue().registerProcess(
|
||||||
(success, session) -> {
|
(success, session) -> {
|
||||||
cacheAccess.unlockItem( session(), previousCacheKey, removalLock );
|
cacheAccess.unlockItem( s, previousCacheKey, removalLock );
|
||||||
if (success) {
|
if (success) {
|
||||||
final boolean put12 = cacheAccess.afterUpdate(
|
final boolean put12 = cacheAccess.afterUpdate(
|
||||||
session(),
|
s,
|
||||||
cacheKey,
|
cacheKey,
|
||||||
id,
|
id,
|
||||||
lock
|
lock
|
||||||
|
@ -366,7 +366,7 @@ public class NaturalIdResolutionsImpl implements NaturalIdResolutions, Serializa
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
cacheAccess.unlockItem( session(), cacheKey, lock );
|
cacheAccess.unlockItem( s, cacheKey, lock );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
|
@ -43,6 +43,7 @@ import org.hibernate.action.spi.BeforeTransactionCompletionProcess;
|
||||||
import org.hibernate.action.spi.Executable;
|
import org.hibernate.action.spi.Executable;
|
||||||
import org.hibernate.cache.CacheException;
|
import org.hibernate.cache.CacheException;
|
||||||
import org.hibernate.engine.internal.NonNullableTransientDependencies;
|
import org.hibernate.engine.internal.NonNullableTransientDependencies;
|
||||||
|
import org.hibernate.event.spi.EventSource;
|
||||||
import org.hibernate.internal.CoreLogging;
|
import org.hibernate.internal.CoreLogging;
|
||||||
import org.hibernate.internal.CoreMessageLogger;
|
import org.hibernate.internal.CoreMessageLogger;
|
||||||
import org.hibernate.internal.util.StringHelper;
|
import org.hibernate.internal.util.StringHelper;
|
||||||
|
@ -905,7 +906,7 @@ public class ActionQueue {
|
||||||
* @throws IOException indicates a problem reading from the stream
|
* @throws IOException indicates a problem reading from the stream
|
||||||
* @throws ClassNotFoundException Generally means we were unable to locate user classes.
|
* @throws ClassNotFoundException Generally means we were unable to locate user classes.
|
||||||
*/
|
*/
|
||||||
public static ActionQueue deserialize(ObjectInputStream ois, SessionImplementor session)
|
public static ActionQueue deserialize(ObjectInputStream ois, EventSource session)
|
||||||
throws IOException, ClassNotFoundException {
|
throws IOException, ClassNotFoundException {
|
||||||
final boolean traceEnabled = LOG.isTraceEnabled();
|
final boolean traceEnabled = LOG.isTraceEnabled();
|
||||||
if ( traceEnabled ) {
|
if ( traceEnabled ) {
|
||||||
|
|
|
@ -19,6 +19,7 @@ import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.hibernate.action.spi.Executable;
|
import org.hibernate.action.spi.Executable;
|
||||||
|
import org.hibernate.event.spi.EventSource;
|
||||||
import org.hibernate.internal.util.collections.CollectionHelper;
|
import org.hibernate.internal.util.collections.CollectionHelper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -345,7 +346,7 @@ public class ExecutableList<E extends Executable & Comparable<? super E> & Seria
|
||||||
*
|
*
|
||||||
* @param session The session with which to associate the {@code Executable}s
|
* @param session The session with which to associate the {@code Executable}s
|
||||||
*/
|
*/
|
||||||
public void afterDeserialize(SessionImplementor session) {
|
public void afterDeserialize(EventSource session) {
|
||||||
for ( E e : executables ) {
|
for ( E e : executables ) {
|
||||||
e.afterDeserialize( session );
|
e.afterDeserialize( session );
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,6 +40,7 @@ import org.hibernate.engine.jdbc.connections.spi.JdbcConnectionAccess;
|
||||||
import org.hibernate.engine.jdbc.spi.JdbcCoordinator;
|
import org.hibernate.engine.jdbc.spi.JdbcCoordinator;
|
||||||
import org.hibernate.engine.jdbc.spi.JdbcServices;
|
import org.hibernate.engine.jdbc.spi.JdbcServices;
|
||||||
import org.hibernate.event.spi.DeleteContext;
|
import org.hibernate.event.spi.DeleteContext;
|
||||||
|
import org.hibernate.event.spi.EventSource;
|
||||||
import org.hibernate.event.spi.MergeContext;
|
import org.hibernate.event.spi.MergeContext;
|
||||||
import org.hibernate.event.spi.PersistContext;
|
import org.hibernate.event.spi.PersistContext;
|
||||||
import org.hibernate.event.spi.RefreshContext;
|
import org.hibernate.event.spi.RefreshContext;
|
||||||
|
@ -297,6 +298,11 @@ public class SessionDelegatorBaseImpl implements SessionImplementor {
|
||||||
return delegate.isEventSource();
|
return delegate.isEventSource();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public EventSource asEventSource() {
|
||||||
|
return delegate.asEventSource();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void afterScrollOperation() {
|
public void afterScrollOperation() {
|
||||||
delegate.afterScrollOperation();
|
delegate.afterScrollOperation();
|
||||||
|
|
|
@ -15,6 +15,7 @@ import org.hibernate.CacheMode;
|
||||||
import org.hibernate.FlushMode;
|
import org.hibernate.FlushMode;
|
||||||
import org.hibernate.HibernateException;
|
import org.hibernate.HibernateException;
|
||||||
import org.hibernate.Interceptor;
|
import org.hibernate.Interceptor;
|
||||||
|
import org.hibernate.event.spi.EventSource;
|
||||||
import org.hibernate.query.Query;
|
import org.hibernate.query.Query;
|
||||||
import org.hibernate.SharedSessionContract;
|
import org.hibernate.SharedSessionContract;
|
||||||
import org.hibernate.Transaction;
|
import org.hibernate.Transaction;
|
||||||
|
@ -355,6 +356,8 @@ public interface SharedSessionContractImplementor
|
||||||
|
|
||||||
boolean isEventSource();
|
boolean isEventSource();
|
||||||
|
|
||||||
|
EventSource asEventSource();
|
||||||
|
|
||||||
void afterScrollOperation();
|
void afterScrollOperation();
|
||||||
|
|
||||||
boolean shouldAutoClose();
|
boolean shouldAutoClose();
|
||||||
|
|
|
@ -9,11 +9,8 @@ package org.hibernate.event.internal;
|
||||||
import org.hibernate.LockOptions;
|
import org.hibernate.LockOptions;
|
||||||
import org.hibernate.engine.spi.EntityEntry;
|
import org.hibernate.engine.spi.EntityEntry;
|
||||||
import org.hibernate.event.spi.EventSource;
|
import org.hibernate.event.spi.EventSource;
|
||||||
import org.hibernate.internal.CoreLogging;
|
|
||||||
import org.hibernate.loader.ast.internal.LoaderHelper;
|
import org.hibernate.loader.ast.internal.LoaderHelper;
|
||||||
|
|
||||||
import org.jboss.logging.Logger;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A convenience base class for listeners that respond to requests to perform a
|
* A convenience base class for listeners that respond to requests to perform a
|
||||||
* pessimistic lock upgrade on an entity.
|
* pessimistic lock upgrade on an entity.
|
||||||
|
@ -21,7 +18,6 @@ import org.jboss.logging.Logger;
|
||||||
* @author Gavin King
|
* @author Gavin King
|
||||||
*/
|
*/
|
||||||
public abstract class AbstractLockUpgradeEventListener extends AbstractReassociateEventListener {
|
public abstract class AbstractLockUpgradeEventListener extends AbstractReassociateEventListener {
|
||||||
private static final Logger log = CoreLogging.logger( AbstractLockUpgradeEventListener.class );
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Performs a pessimistic lock upgrade on a given entity, if needed.
|
* Performs a pessimistic lock upgrade on a given entity, if needed.
|
||||||
|
|
|
@ -1813,6 +1813,11 @@ public class SessionImpl
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public EventSource asEventSource() {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isDefaultReadOnly() {
|
public boolean isDefaultReadOnly() {
|
||||||
return persistenceContext.isDefaultReadOnly();
|
return persistenceContext.isDefaultReadOnly();
|
||||||
|
|
|
@ -27,6 +27,7 @@ import org.hibernate.engine.spi.PersistenceContext;
|
||||||
import org.hibernate.engine.spi.PersistentAttributeInterceptor;
|
import org.hibernate.engine.spi.PersistentAttributeInterceptor;
|
||||||
import org.hibernate.engine.transaction.internal.jta.JtaStatusHelper;
|
import org.hibernate.engine.transaction.internal.jta.JtaStatusHelper;
|
||||||
import org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform;
|
import org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform;
|
||||||
|
import org.hibernate.event.spi.EventSource;
|
||||||
import org.hibernate.id.IdentifierGeneratorHelper;
|
import org.hibernate.id.IdentifierGeneratorHelper;
|
||||||
import org.hibernate.persister.collection.CollectionPersister;
|
import org.hibernate.persister.collection.CollectionPersister;
|
||||||
import org.hibernate.persister.entity.EntityPersister;
|
import org.hibernate.persister.entity.EntityPersister;
|
||||||
|
@ -587,6 +588,11 @@ public class StatelessSessionImpl extends AbstractSharedSessionContract implemen
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public EventSource asEventSource() {
|
||||||
|
throw new HibernateException( "Illegal Cast to EventSource - guard by invoking isEventSource() first" );
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isDefaultReadOnly() {
|
public boolean isDefaultReadOnly() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -124,7 +124,7 @@ public class IdentifierLoadAccessImpl<T> implements IdentifierLoadAccess<T>, Jav
|
||||||
@SuppressWarnings( "unchecked" )
|
@SuppressWarnings( "unchecked" )
|
||||||
protected T doGetReference(Object id) {
|
protected T doGetReference(Object id) {
|
||||||
final SessionImplementor session = context.getSession();
|
final SessionImplementor session = context.getSession();
|
||||||
final EventSource eventSource = (EventSource) session;
|
final EventSource eventSource = session.asEventSource();
|
||||||
final LoadQueryInfluencers loadQueryInfluencers = session.getLoadQueryInfluencers();
|
final LoadQueryInfluencers loadQueryInfluencers = session.getLoadQueryInfluencers();
|
||||||
|
|
||||||
final JpaCompliance jpaCompliance = session.getFactory().getSessionFactoryOptions().getJpaCompliance();
|
final JpaCompliance jpaCompliance = session.getFactory().getSessionFactoryOptions().getJpaCompliance();
|
||||||
|
@ -169,7 +169,7 @@ public class IdentifierLoadAccessImpl<T> implements IdentifierLoadAccess<T>, Jav
|
||||||
@SuppressWarnings( "unchecked" )
|
@SuppressWarnings( "unchecked" )
|
||||||
protected final T doLoad(Object id) {
|
protected final T doLoad(Object id) {
|
||||||
final SessionImplementor session = context.getSession();
|
final SessionImplementor session = context.getSession();
|
||||||
final EventSource eventSource = (EventSource) session;
|
final EventSource eventSource = session.asEventSource();
|
||||||
final LoadQueryInfluencers loadQueryInfluencers = session.getLoadQueryInfluencers();
|
final LoadQueryInfluencers loadQueryInfluencers = session.getLoadQueryInfluencers();
|
||||||
|
|
||||||
final JpaCompliance jpaCompliance = session.getFactory().getSessionFactoryOptions().getJpaCompliance();
|
final JpaCompliance jpaCompliance = session.getFactory().getSessionFactoryOptions().getJpaCompliance();
|
||||||
|
|
|
@ -14,6 +14,7 @@ import org.hibernate.cache.spi.access.SoftLock;
|
||||||
import org.hibernate.engine.spi.EntityEntry;
|
import org.hibernate.engine.spi.EntityEntry;
|
||||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
||||||
import org.hibernate.engine.spi.Status;
|
import org.hibernate.engine.spi.Status;
|
||||||
|
import org.hibernate.event.spi.EventSource;
|
||||||
import org.hibernate.loader.LoaderLogging;
|
import org.hibernate.loader.LoaderLogging;
|
||||||
import org.hibernate.persister.entity.EntityPersister;
|
import org.hibernate.persister.entity.EntityPersister;
|
||||||
|
|
||||||
|
@ -22,7 +23,7 @@ import org.hibernate.persister.entity.EntityPersister;
|
||||||
*/
|
*/
|
||||||
public class LoaderHelper {
|
public class LoaderHelper {
|
||||||
|
|
||||||
public static void upgradeLock(Object object, EntityEntry entry, LockOptions lockOptions, SharedSessionContractImplementor session) {
|
public static void upgradeLock(Object object, EntityEntry entry, LockOptions lockOptions, EventSource session) {
|
||||||
LockMode requestedLockMode = lockOptions.getLockMode();
|
LockMode requestedLockMode = lockOptions.getLockMode();
|
||||||
if ( requestedLockMode.greaterThan( entry.getLockMode() ) ) {
|
if ( requestedLockMode.greaterThan( entry.getLockMode() ) ) {
|
||||||
// The user requested a "greater" (i.e. more restrictive) form of
|
// The user requested a "greater" (i.e. more restrictive) form of
|
||||||
|
|
|
@ -80,7 +80,7 @@ public class MultiIdLoaderStandard<T> implements MultiIdEntityLoader<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<T> load(Object[] ids, MultiIdLoadOptions loadOptions, SharedSessionContractImplementor session) {
|
public List<T> load(Object[] ids, MultiIdLoadOptions loadOptions, EventSource session) {
|
||||||
assert ids != null;
|
assert ids != null;
|
||||||
|
|
||||||
if ( loadOptions.isOrderReturnEnabled() ) {
|
if ( loadOptions.isOrderReturnEnabled() ) {
|
||||||
|
@ -93,7 +93,7 @@ public class MultiIdLoaderStandard<T> implements MultiIdEntityLoader<T> {
|
||||||
|
|
||||||
private List<T> performOrderedMultiLoad(
|
private List<T> performOrderedMultiLoad(
|
||||||
Object[] ids,
|
Object[] ids,
|
||||||
SharedSessionContractImplementor session,
|
EventSource session,
|
||||||
MultiIdLoadOptions loadOptions) {
|
MultiIdLoadOptions loadOptions) {
|
||||||
if ( log.isTraceEnabled() ) {
|
if ( log.isTraceEnabled() ) {
|
||||||
log.tracef( "#performOrderedMultiLoad(`%s`, ..)", entityDescriptor.getEntityName() );
|
log.tracef( "#performOrderedMultiLoad(`%s`, ..)", entityDescriptor.getEntityName() );
|
||||||
|
@ -141,7 +141,7 @@ public class MultiIdLoaderStandard<T> implements MultiIdEntityLoader<T> {
|
||||||
id,
|
id,
|
||||||
entityDescriptor.getMappedClass().getName(),
|
entityDescriptor.getMappedClass().getName(),
|
||||||
lockOptions,
|
lockOptions,
|
||||||
(EventSource) session,
|
session,
|
||||||
getReadOnlyFromLoadQueryInfluencers(session)
|
getReadOnlyFromLoadQueryInfluencers(session)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -343,7 +343,7 @@ public class MultiIdLoaderStandard<T> implements MultiIdEntityLoader<T> {
|
||||||
|
|
||||||
private List<T> performUnorderedMultiLoad(
|
private List<T> performUnorderedMultiLoad(
|
||||||
Object[] ids,
|
Object[] ids,
|
||||||
SharedSessionContractImplementor session,
|
EventSource session,
|
||||||
MultiIdLoadOptions loadOptions) {
|
MultiIdLoadOptions loadOptions) {
|
||||||
assert !loadOptions.isOrderReturnEnabled();
|
assert !loadOptions.isOrderReturnEnabled();
|
||||||
assert ids != null;
|
assert ids != null;
|
||||||
|
@ -382,7 +382,7 @@ public class MultiIdLoaderStandard<T> implements MultiIdEntityLoader<T> {
|
||||||
id,
|
id,
|
||||||
entityDescriptor.getMappedClass().getName(),
|
entityDescriptor.getMappedClass().getName(),
|
||||||
lockOptions,
|
lockOptions,
|
||||||
(EventSource) session,
|
session,
|
||||||
getReadOnlyFromLoadQueryInfluencers( session )
|
getReadOnlyFromLoadQueryInfluencers( session )
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,7 @@ package org.hibernate.loader.ast.spi;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
||||||
|
import org.hibernate.event.spi.EventSource;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loader subtype for loading multiple entities by multiple identifier values.
|
* Loader subtype for loading multiple entities by multiple identifier values.
|
||||||
|
@ -17,5 +18,5 @@ public interface MultiIdEntityLoader<T> extends MultiLoader<T> {
|
||||||
/**
|
/**
|
||||||
* Load multiple entities by id. The exact result depends on the passed options.
|
* Load multiple entities by id. The exact result depends on the passed options.
|
||||||
*/
|
*/
|
||||||
<K> List<T> load(K[] ids, MultiIdLoadOptions options, SharedSessionContractImplementor session);
|
<K> List<T> load(K[] ids, MultiIdLoadOptions options, EventSource session);
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,7 +70,7 @@ public class CacheEntityLoaderHelper {
|
||||||
EntityKey keyToLoad,
|
EntityKey keyToLoad,
|
||||||
LoadEventListener.LoadType options,
|
LoadEventListener.LoadType options,
|
||||||
LockOptions lockOptions,
|
LockOptions lockOptions,
|
||||||
SharedSessionContractImplementor session) {
|
EventSource session) {
|
||||||
final Object old = session.getEntityUsingInterceptor( keyToLoad );
|
final Object old = session.getEntityUsingInterceptor( keyToLoad );
|
||||||
|
|
||||||
if ( old != null ) {
|
if ( old != null ) {
|
||||||
|
|
|
@ -2073,7 +2073,7 @@ public abstract class AbstractEntityPersister
|
||||||
Object version,
|
Object version,
|
||||||
Object object,
|
Object object,
|
||||||
LockMode lockMode,
|
LockMode lockMode,
|
||||||
SharedSessionContractImplementor session) throws HibernateException {
|
EventSource session) throws HibernateException {
|
||||||
getLocker( lockMode ).lock( id, version, object, LockOptions.WAIT_FOREVER, session );
|
getLocker( lockMode ).lock( id, version, object, LockOptions.WAIT_FOREVER, session );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2083,7 +2083,7 @@ public abstract class AbstractEntityPersister
|
||||||
Object version,
|
Object version,
|
||||||
Object object,
|
Object object,
|
||||||
LockOptions lockOptions,
|
LockOptions lockOptions,
|
||||||
SharedSessionContractImplementor session) throws HibernateException {
|
EventSource session) throws HibernateException {
|
||||||
getLocker( lockOptions.getLockMode() ).lock( id, version, object, lockOptions.getTimeOut(), session );
|
getLocker( lockOptions.getLockMode() ).lock( id, version, object, lockOptions.getTimeOut(), session );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3493,8 +3493,8 @@ public abstract class AbstractEntityPersister
|
||||||
final Object identifier = entityKey.getIdentifier();
|
final Object identifier = entityKey.getIdentifier();
|
||||||
|
|
||||||
Object loaded = null;
|
Object loaded = null;
|
||||||
if ( canReadFromCache && session instanceof EventSource ) {
|
if ( canReadFromCache && session.isEventSource() ) {
|
||||||
LoadEvent loadEvent = new LoadEvent( identifier, entity, (EventSource) session, false );
|
LoadEvent loadEvent = new LoadEvent( identifier, entity, session.asEventSource(), false );
|
||||||
loaded = CacheEntityLoaderHelper.INSTANCE.loadFromSecondLevelCache( loadEvent, this, entityKey );
|
loaded = CacheEntityLoaderHelper.INSTANCE.loadFromSecondLevelCache( loadEvent, this, entityKey );
|
||||||
}
|
}
|
||||||
if ( loaded == null ) {
|
if ( loaded == null ) {
|
||||||
|
@ -3544,7 +3544,7 @@ public abstract class AbstractEntityPersister
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<?> multiLoad(Object[] ids, SharedSessionContractImplementor session, MultiIdLoadOptions loadOptions) {
|
public List<?> multiLoad(Object[] ids, EventSource session, MultiIdLoadOptions loadOptions) {
|
||||||
return multiIdEntityLoader.load( ids, loadOptions, session );
|
return multiIdEntityLoader.load( ids, loadOptions, session );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,6 +26,7 @@ import org.hibernate.engine.spi.EntityEntryFactory;
|
||||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||||
import org.hibernate.engine.spi.SessionImplementor;
|
import org.hibernate.engine.spi.SessionImplementor;
|
||||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
||||||
|
import org.hibernate.event.spi.EventSource;
|
||||||
import org.hibernate.id.IdentifierGenerator;
|
import org.hibernate.id.IdentifierGenerator;
|
||||||
import org.hibernate.internal.FilterAliasGenerator;
|
import org.hibernate.internal.FilterAliasGenerator;
|
||||||
import org.hibernate.internal.TableGroupFilterAliasGenerator;
|
import org.hibernate.internal.TableGroupFilterAliasGenerator;
|
||||||
|
@ -550,17 +551,17 @@ public interface EntityPersister
|
||||||
*
|
*
|
||||||
* @return The loaded, matching entities
|
* @return The loaded, matching entities
|
||||||
*/
|
*/
|
||||||
List<?> multiLoad(Object[] ids, SharedSessionContractImplementor session, MultiIdLoadOptions loadOptions);
|
List<?> multiLoad(Object[] ids, EventSource session, MultiIdLoadOptions loadOptions);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Do a version check (optional operation)
|
* Do a version check (optional operation)
|
||||||
*/
|
*/
|
||||||
void lock(Object id, Object version, Object object, LockMode lockMode, SharedSessionContractImplementor session);
|
void lock(Object id, Object version, Object object, LockMode lockMode, EventSource session);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Do a version check (optional operation)
|
* Do a version check (optional operation)
|
||||||
*/
|
*/
|
||||||
void lock(Object id, Object version, Object object, LockOptions lockOptions, SharedSessionContractImplementor session);
|
void lock(Object id, Object version, Object object, LockOptions lockOptions, EventSource session);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Persist an instance
|
* Persist an instance
|
||||||
|
|
|
@ -589,7 +589,7 @@ public abstract class AbstractEntityInitializer extends AbstractFetchParentAcces
|
||||||
// We have to query the second level cache if reference cache entries are used
|
// We have to query the second level cache if reference cache entries are used
|
||||||
if ( instance == null && entityDescriptor.canUseReferenceCacheEntries() ) {
|
if ( instance == null && entityDescriptor.canUseReferenceCacheEntries() ) {
|
||||||
instance = CacheEntityLoaderHelper.INSTANCE.loadFromSecondLevelCache(
|
instance = CacheEntityLoaderHelper.INSTANCE.loadFromSecondLevelCache(
|
||||||
(EventSource) rowProcessingState.getSession(),
|
rowProcessingState.getSession().asEventSource(),
|
||||||
null,
|
null,
|
||||||
lockMode,
|
lockMode,
|
||||||
entityDescriptor,
|
entityDescriptor,
|
||||||
|
|
|
@ -63,9 +63,10 @@ public class JdbcValuesSourceProcessingStateStandardImpl implements JdbcValuesSo
|
||||||
this.processingOptions = processingOptions;
|
this.processingOptions = processingOptions;
|
||||||
this.loadingEntityEntryConsumer = loadingEntityEntryListener;
|
this.loadingEntityEntryConsumer = loadingEntityEntryListener;
|
||||||
|
|
||||||
if ( executionContext.getSession() instanceof EventSource ) {
|
if ( executionContext.getSession().isEventSource() ) {
|
||||||
preLoadEvent = new PreLoadEvent( (EventSource) executionContext.getSession() );
|
final EventSource eventSource = executionContext.getSession().asEventSource();
|
||||||
postLoadEvent = new PostLoadEvent( (EventSource) executionContext.getSession() );
|
preLoadEvent = new PreLoadEvent( eventSource );
|
||||||
|
postLoadEvent = new PostLoadEvent( eventSource );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
preLoadEvent = null;
|
preLoadEvent = null;
|
||||||
|
|
|
@ -35,6 +35,7 @@ import org.hibernate.engine.spi.EntityEntryFactory;
|
||||||
import org.hibernate.engine.spi.LoadQueryInfluencers;
|
import org.hibernate.engine.spi.LoadQueryInfluencers;
|
||||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
||||||
|
import org.hibernate.event.spi.EventSource;
|
||||||
import org.hibernate.id.IdentifierGenerator;
|
import org.hibernate.id.IdentifierGenerator;
|
||||||
import org.hibernate.internal.FilterAliasGenerator;
|
import org.hibernate.internal.FilterAliasGenerator;
|
||||||
import org.hibernate.loader.ast.spi.MultiIdLoadOptions;
|
import org.hibernate.loader.ast.spi.MultiIdLoadOptions;
|
||||||
|
@ -357,16 +358,16 @@ public class GoofyPersisterClassProvider implements PersisterClassResolver {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<?> multiLoad(Object[] ids, SharedSessionContractImplementor session, MultiIdLoadOptions loadOptions) {
|
public List<?> multiLoad(Object[] ids, EventSource session, MultiIdLoadOptions loadOptions) {
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void lock(Object id, Object version, Object object, LockMode lockMode, SharedSessionContractImplementor session) {
|
public void lock(Object id, Object version, Object object, LockMode lockMode, EventSource session) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void lock(Object id, Object version, Object object, LockOptions lockOptions, SharedSessionContractImplementor session) {
|
public void lock(Object id, Object version, Object object, LockOptions lockOptions, EventSource session) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -21,6 +21,7 @@ import org.hibernate.action.spi.BeforeTransactionCompletionProcess;
|
||||||
import org.hibernate.action.spi.Executable;
|
import org.hibernate.action.spi.Executable;
|
||||||
import org.hibernate.engine.spi.ExecutableList;
|
import org.hibernate.engine.spi.ExecutableList;
|
||||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
||||||
|
import org.hibernate.event.spi.EventSource;
|
||||||
|
|
||||||
import org.hibernate.testing.orm.junit.BaseUnitTest;
|
import org.hibernate.testing.orm.junit.BaseUnitTest;
|
||||||
import org.junit.jupiter.api.AfterEach;
|
import org.junit.jupiter.api.AfterEach;
|
||||||
|
@ -97,7 +98,7 @@ public class NonSortedExecutableListTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void afterDeserialize(SharedSessionContractImplementor session) {
|
public void afterDeserialize(EventSource session) {
|
||||||
this.afterDeserializeCalled = true;
|
this.afterDeserializeCalled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,7 @@ import org.hibernate.action.spi.BeforeTransactionCompletionProcess;
|
||||||
import org.hibernate.action.spi.Executable;
|
import org.hibernate.action.spi.Executable;
|
||||||
import org.hibernate.engine.spi.ExecutableList;
|
import org.hibernate.engine.spi.ExecutableList;
|
||||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
||||||
|
import org.hibernate.event.spi.EventSource;
|
||||||
|
|
||||||
import org.hibernate.testing.orm.junit.BaseUnitTest;
|
import org.hibernate.testing.orm.junit.BaseUnitTest;
|
||||||
import org.junit.jupiter.api.AfterEach;
|
import org.junit.jupiter.api.AfterEach;
|
||||||
|
@ -95,7 +96,7 @@ public class SortedExecutableListTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void afterDeserialize(SharedSessionContractImplementor session) {
|
public void afterDeserialize(EventSource session) {
|
||||||
this.afterDeserializeCalled = true;
|
this.afterDeserializeCalled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,6 +31,7 @@ import org.hibernate.engine.spi.EntityEntryFactory;
|
||||||
import org.hibernate.engine.spi.LoadQueryInfluencers;
|
import org.hibernate.engine.spi.LoadQueryInfluencers;
|
||||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
||||||
|
import org.hibernate.event.spi.EventSource;
|
||||||
import org.hibernate.id.IdentifierGenerator;
|
import org.hibernate.id.IdentifierGenerator;
|
||||||
import org.hibernate.internal.FilterAliasGenerator;
|
import org.hibernate.internal.FilterAliasGenerator;
|
||||||
import org.hibernate.jpa.boot.spi.Bootstrap;
|
import org.hibernate.jpa.boot.spi.Bootstrap;
|
||||||
|
@ -397,16 +398,16 @@ public class PersisterClassProviderTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List multiLoad(Object[] ids, SharedSessionContractImplementor session, MultiIdLoadOptions loadOptions) {
|
public List multiLoad(Object[] ids, EventSource session, MultiIdLoadOptions loadOptions) {
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void lock(Object id, Object version, Object object, LockMode lockMode, SharedSessionContractImplementor session) {
|
public void lock(Object id, Object version, Object object, LockMode lockMode, EventSource session) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void lock(Object id, Object version, Object object, LockOptions lockOptions, SharedSessionContractImplementor session) {
|
public void lock(Object id, Object version, Object object, LockOptions lockOptions, EventSource session) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -33,6 +33,7 @@ import org.hibernate.engine.spi.EntityEntryFactory;
|
||||||
import org.hibernate.engine.spi.LoadQueryInfluencers;
|
import org.hibernate.engine.spi.LoadQueryInfluencers;
|
||||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
||||||
|
import org.hibernate.event.spi.EventSource;
|
||||||
import org.hibernate.id.IdentifierGenerator;
|
import org.hibernate.id.IdentifierGenerator;
|
||||||
import org.hibernate.id.UUIDHexGenerator;
|
import org.hibernate.id.UUIDHexGenerator;
|
||||||
import org.hibernate.internal.FilterAliasGenerator;
|
import org.hibernate.internal.FilterAliasGenerator;
|
||||||
|
@ -398,7 +399,7 @@ public class CustomPersister implements EntityPersister {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<?> multiLoad(Object[] ids, SharedSessionContractImplementor session, MultiIdLoadOptions loadOptions) {
|
public List<?> multiLoad(Object[] ids, EventSource session, MultiIdLoadOptions loadOptions) {
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -448,28 +449,29 @@ public class CustomPersister implements EntityPersister {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see EntityPersister#lock(Object, Object, Object, LockMode, SharedSessionContractImplementor)
|
* @see EntityPersister#lock(Object, Object, Object, LockMode, EventSource)
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void lock(
|
public void lock(
|
||||||
Object id,
|
Object id,
|
||||||
Object version,
|
Object version,
|
||||||
Object object,
|
Object object,
|
||||||
LockOptions lockOptions,
|
LockOptions lockOptions,
|
||||||
SharedSessionContractImplementor session
|
EventSource session
|
||||||
) throws HibernateException {
|
) throws HibernateException {
|
||||||
|
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see EntityPersister#lock(Object, Object, Object, LockMode, SharedSessionContractImplementor)
|
* @see EntityPersister#lock(Object, Object, Object, LockMode, EventSource)
|
||||||
*/
|
*/
|
||||||
public void lock(
|
public void lock(
|
||||||
Object id,
|
Object id,
|
||||||
Object version,
|
Object version,
|
||||||
Object object,
|
Object object,
|
||||||
LockMode lockMode,
|
LockMode lockMode,
|
||||||
SharedSessionContractImplementor session
|
EventSource session
|
||||||
) throws HibernateException {
|
) throws HibernateException {
|
||||||
|
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
|
|
Loading…
Reference in New Issue