very minor cleanups to engine package
This commit is contained in:
parent
ee1d27719c
commit
f6287cedc2
|
@ -112,13 +112,13 @@ public class EffectiveEntityGraph implements AppliedGraph, Serializable {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
RootGraphImplementor fetchHint = (RootGraphImplementor) properties.get( GraphSemantic.FETCH.getJpaHintName() );
|
RootGraphImplementor<?> fetchHint = (RootGraphImplementor<?>) properties.get( GraphSemantic.FETCH.getJpaHintName() );
|
||||||
RootGraphImplementor loadHint = (RootGraphImplementor) properties.get( GraphSemantic.LOAD.getJpaHintName() );
|
RootGraphImplementor<?> loadHint = (RootGraphImplementor<?>) properties.get( GraphSemantic.LOAD.getJpaHintName() );
|
||||||
if (fetchHint == null) {
|
if (fetchHint == null) {
|
||||||
fetchHint = (RootGraphImplementor) properties.get( GraphSemantic.FETCH.getJakartaHintName() );
|
fetchHint = (RootGraphImplementor<?>) properties.get( GraphSemantic.FETCH.getJakartaHintName() );
|
||||||
}
|
}
|
||||||
if (loadHint == null) {
|
if (loadHint == null) {
|
||||||
loadHint = (RootGraphImplementor) properties.get( GraphSemantic.LOAD.getJakartaHintName() );
|
loadHint = (RootGraphImplementor<?>) properties.get( GraphSemantic.LOAD.getJakartaHintName() );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( fetchHint == null && loadHint == null ) {
|
if ( fetchHint == null && loadHint == null ) {
|
||||||
|
|
|
@ -18,7 +18,7 @@ import org.hibernate.type.Type;
|
||||||
* Used to uniquely key an entity instance in relation to a particular session
|
* Used to uniquely key an entity instance in relation to a particular session
|
||||||
* by some unique property reference, as opposed to identifier.
|
* by some unique property reference, as opposed to identifier.
|
||||||
* <p/>
|
* <p/>
|
||||||
* Uniqueing information consists of the entity-name, the referenced
|
* Uniqueing information consists of the entity name, the referenced
|
||||||
* property name, and the referenced property value.
|
* property name, and the referenced property value.
|
||||||
*
|
*
|
||||||
* @author Gavin King
|
* @author Gavin King
|
||||||
|
|
|
@ -26,9 +26,9 @@ public interface ExceptionConverter {
|
||||||
RuntimeException convertCommitException(RuntimeException e);
|
RuntimeException convertCommitException(RuntimeException e);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts a Hibernate-specific exception into a JPA-specified exception; note that the JPA specification makes use
|
* Converts a Hibernate-specific exception into a JPA-specified exception;
|
||||||
* of exceptions outside its exception hierarchy, though they are all runtime exceptions.
|
* note that the JPA specification makes use of exceptions outside its
|
||||||
* <p/>
|
* exception hierarchy, though they are all runtime exceptions.
|
||||||
*
|
*
|
||||||
* @param e The Hibernate exception.
|
* @param e The Hibernate exception.
|
||||||
* @param lockOptions The lock options in effect at the time of exception (can be null)
|
* @param lockOptions The lock options in effect at the time of exception (can be null)
|
||||||
|
@ -38,9 +38,9 @@ public interface ExceptionConverter {
|
||||||
RuntimeException convert(HibernateException e, LockOptions lockOptions);
|
RuntimeException convert(HibernateException e, LockOptions lockOptions);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts a Hibernate-specific exception into a JPA-specified exception; note that the JPA specification makes use
|
* Converts a Hibernate-specific exception into a JPA-specified exception;
|
||||||
* of exceptions outside its exception hierarchy, though they are all runtime exceptions.
|
* note that the JPA specification makes use of exceptions outside its
|
||||||
* <p/>
|
* exception hierarchy, though they are all runtime exceptions.
|
||||||
*
|
*
|
||||||
* @param e The Hibernate exception.
|
* @param e The Hibernate exception.
|
||||||
*
|
*
|
||||||
|
|
|
@ -7,8 +7,8 @@
|
||||||
package org.hibernate.engine.spi;
|
package org.hibernate.engine.spi;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* For persistence operations (INSERT, UPDATE, DELETE) what style of determining
|
* For persistence operations (INSERT, UPDATE, DELETE) what style of
|
||||||
* results (success/failure) is to be used.
|
* determining results (success/failure) is to be used.
|
||||||
*
|
*
|
||||||
* @author Steve Ebersole
|
* @author Steve Ebersole
|
||||||
*/
|
*/
|
||||||
|
@ -22,7 +22,7 @@ public enum ExecuteUpdateResultCheckStyle {
|
||||||
NONE( "none" ),
|
NONE( "none" ),
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Perform row-count checking. Row counts are the int values returned by both
|
* Perform row count checking. Row counts are the int values returned by both
|
||||||
* {@link java.sql.PreparedStatement#executeUpdate()} and
|
* {@link java.sql.PreparedStatement#executeUpdate()} and
|
||||||
* {@link java.sql.Statement#executeBatch()}. These values are checked
|
* {@link java.sql.Statement#executeBatch()}. These values are checked
|
||||||
* against some expected count.
|
* against some expected count.
|
||||||
|
@ -39,7 +39,7 @@ public enum ExecuteUpdateResultCheckStyle {
|
||||||
|
|
||||||
private final String name;
|
private final String name;
|
||||||
|
|
||||||
private ExecuteUpdateResultCheckStyle(String name) {
|
ExecuteUpdateResultCheckStyle(String name) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,8 +11,9 @@ import org.hibernate.bytecode.enhance.spi.interceptor.LazyAttributeLoadingInterc
|
||||||
import org.hibernate.engine.spi.SelfDirtinessTracker;
|
import org.hibernate.engine.spi.SelfDirtinessTracker;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A self dirtiness tracker that declares additional methods that are intended for internal communication. This
|
* A self dirtiness tracker that declares additional methods that are intended for
|
||||||
* interface can be implemented optionally instead of the plain {@link SelfDirtinessTracker}.
|
* internal communication. This interface can be implemented optionally instead of
|
||||||
|
* the plain {@link SelfDirtinessTracker}.
|
||||||
*/
|
*/
|
||||||
public interface ExtendedSelfDirtinessTracker extends SelfDirtinessTracker {
|
public interface ExtendedSelfDirtinessTracker extends SelfDirtinessTracker {
|
||||||
|
|
||||||
|
|
|
@ -16,8 +16,9 @@ import org.hibernate.metamodel.mapping.JdbcMapping;
|
||||||
/**
|
/**
|
||||||
* Represents the definition of a {@link org.hibernate.Filter filter}.
|
* Represents the definition of a {@link org.hibernate.Filter filter}.
|
||||||
* This information includes the {@linkplain #filterName name} of the
|
* This information includes the {@linkplain #filterName name} of the
|
||||||
* filter, along with the {@linkplain #parameterTypes name and type}
|
* filter, along with the {@linkplain #getParameterJdbcMapping(String)
|
||||||
* of every parameter of the filter. A filter may optionally have a
|
* names} and {@linkplain #getParameterJdbcMapping(String) types} of
|
||||||
|
* every parameter of the filter. A filter may optionally have a
|
||||||
* {@linkplain #defaultFilterCondition default condition}.
|
* {@linkplain #defaultFilterCondition default condition}.
|
||||||
*
|
*
|
||||||
* @see org.hibernate.annotations.FilterDef
|
* @see org.hibernate.annotations.FilterDef
|
||||||
|
|
|
@ -30,7 +30,7 @@ public class IdentifierValue implements UnsavedValueStrategy {
|
||||||
*/
|
*/
|
||||||
public static final IdentifierValue ANY = new IdentifierValue() {
|
public static final IdentifierValue ANY = new IdentifierValue() {
|
||||||
@Override
|
@Override
|
||||||
public final Boolean isUnsaved(Object id) {
|
public Boolean isUnsaved(Object id) {
|
||||||
LOG.trace( "ID unsaved-value strategy ANY" );
|
LOG.trace( "ID unsaved-value strategy ANY" );
|
||||||
return Boolean.TRUE;
|
return Boolean.TRUE;
|
||||||
}
|
}
|
||||||
|
@ -51,7 +51,7 @@ public class IdentifierValue implements UnsavedValueStrategy {
|
||||||
*/
|
*/
|
||||||
public static final IdentifierValue NONE = new IdentifierValue() {
|
public static final IdentifierValue NONE = new IdentifierValue() {
|
||||||
@Override
|
@Override
|
||||||
public final Boolean isUnsaved(Object id) {
|
public Boolean isUnsaved(Object id) {
|
||||||
LOG.trace( "ID unsaved-value strategy NONE" );
|
LOG.trace( "ID unsaved-value strategy NONE" );
|
||||||
return Boolean.FALSE;
|
return Boolean.FALSE;
|
||||||
}
|
}
|
||||||
|
@ -73,7 +73,7 @@ public class IdentifierValue implements UnsavedValueStrategy {
|
||||||
*/
|
*/
|
||||||
public static final IdentifierValue NULL = new IdentifierValue() {
|
public static final IdentifierValue NULL = new IdentifierValue() {
|
||||||
@Override
|
@Override
|
||||||
public final Boolean isUnsaved(Object id) {
|
public Boolean isUnsaved(Object id) {
|
||||||
LOG.trace( "ID unsaved-value strategy NULL" );
|
LOG.trace( "ID unsaved-value strategy NULL" );
|
||||||
return id == null;
|
return id == null;
|
||||||
}
|
}
|
||||||
|
@ -94,7 +94,7 @@ public class IdentifierValue implements UnsavedValueStrategy {
|
||||||
*/
|
*/
|
||||||
public static final IdentifierValue UNDEFINED = new IdentifierValue() {
|
public static final IdentifierValue UNDEFINED = new IdentifierValue() {
|
||||||
@Override
|
@Override
|
||||||
public final Boolean isUnsaved(Object id) {
|
public Boolean isUnsaved(Object id) {
|
||||||
LOG.trace( "ID unsaved-value strategy UNDEFINED" );
|
LOG.trace( "ID unsaved-value strategy UNDEFINED" );
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -741,7 +741,6 @@ public interface PersistenceContext {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Registers an {@link EntityKey} as nullifiable on this {@link PersistenceContext}.
|
* Registers an {@link EntityKey} as nullifiable on this {@link PersistenceContext}.
|
||||||
* @param key
|
|
||||||
*/
|
*/
|
||||||
void registerNullifiableEntityKey(EntityKey key);
|
void registerNullifiableEntityKey(EntityKey key);
|
||||||
|
|
||||||
|
@ -772,8 +771,7 @@ public interface PersistenceContext {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds a collection in the collections-by-key map.
|
* Adds a collection in the collections-by-key map.
|
||||||
* @param collectionKey
|
*
|
||||||
* @param persistentCollection
|
|
||||||
* @return the previous collection, it the key was already mapped.
|
* @return the previous collection, it the key was already mapped.
|
||||||
*/
|
*/
|
||||||
PersistentCollection<?> addCollectionByKey(CollectionKey collectionKey, PersistentCollection<?> persistentCollection);
|
PersistentCollection<?> addCollectionByKey(CollectionKey collectionKey, PersistentCollection<?> persistentCollection);
|
||||||
|
|
|
@ -14,7 +14,7 @@ import org.hibernate.bytecode.enhance.spi.CollectionTracker;
|
||||||
* <p/>
|
* <p/>
|
||||||
* Entity classes are free to implement this contract themselves. This contract is
|
* Entity classes are free to implement this contract themselves. This contract is
|
||||||
* also introduced into the entity when using bytecode enhancement and requesting
|
* also introduced into the entity when using bytecode enhancement and requesting
|
||||||
* that entities track there own dirtiness.
|
* that entities track their own dirtiness.
|
||||||
*
|
*
|
||||||
* @author <a href="mailto:stale.pedersen@jboss.org">Ståle W. Pedersen</a>
|
* @author <a href="mailto:stale.pedersen@jboss.org">Ståle W. Pedersen</a>
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -9,8 +9,8 @@ package org.hibernate.engine.spi;
|
||||||
import org.hibernate.SessionBuilder;
|
import org.hibernate.SessionBuilder;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Defines the internal contract between the {@code SessionBuilder} and other parts of
|
* Defines the internal contract between the {@link SessionBuilder} and
|
||||||
* Hibernate..
|
* other parts of Hibernate.
|
||||||
*
|
*
|
||||||
* @see SessionBuilder
|
* @see SessionBuilder
|
||||||
*
|
*
|
||||||
|
|
|
@ -60,7 +60,6 @@ import jakarta.persistence.SynchronizationType;
|
||||||
*
|
*
|
||||||
* @author Steve Ebersole
|
* @author Steve Ebersole
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings({"deprecation", "unused"})
|
|
||||||
public class SessionFactoryDelegatingImpl implements SessionFactoryImplementor, SessionFactory {
|
public class SessionFactoryDelegatingImpl implements SessionFactoryImplementor, SessionFactory {
|
||||||
private final SessionFactoryImplementor delegate;
|
private final SessionFactoryImplementor delegate;
|
||||||
|
|
||||||
|
@ -107,17 +106,17 @@ public class SessionFactoryDelegatingImpl implements SessionFactoryImplementor,
|
||||||
return delegate.openStatelessSession( connection );
|
return delegate.openStatelessSession( connection );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override @Deprecated
|
||||||
public ClassMetadata getClassMetadata(@SuppressWarnings("rawtypes") Class entityClass) {
|
public ClassMetadata getClassMetadata(@SuppressWarnings("rawtypes") Class entityClass) {
|
||||||
return delegate.getClassMetadata( entityClass );
|
return delegate.getClassMetadata( entityClass );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override @Deprecated
|
||||||
public ClassMetadata getClassMetadata(String entityName) {
|
public ClassMetadata getClassMetadata(String entityName) {
|
||||||
return delegate.getClassMetadata( entityName );
|
return delegate.getClassMetadata( entityName );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override @Deprecated
|
||||||
public CollectionMetadata getCollectionMetadata(String roleName) {
|
public CollectionMetadata getCollectionMetadata(String roleName) {
|
||||||
return delegate.getCollectionMetadata( roleName );
|
return delegate.getCollectionMetadata( roleName );
|
||||||
}
|
}
|
||||||
|
@ -367,7 +366,7 @@ public class SessionFactoryDelegatingImpl implements SessionFactoryImplementor,
|
||||||
return delegate.getCriteriaBuilder();
|
return delegate.getCriteriaBuilder();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override @SuppressWarnings("deprecation")
|
||||||
public MetamodelImplementor getMetamodel() {
|
public MetamodelImplementor getMetamodel() {
|
||||||
return delegate.getMetamodel();
|
return delegate.getMetamodel();
|
||||||
}
|
}
|
||||||
|
|
|
@ -128,14 +128,10 @@ public interface SessionFactoryImplementor
|
||||||
|
|
||||||
void addObserver(SessionFactoryObserver observer);
|
void addObserver(SessionFactoryObserver observer);
|
||||||
|
|
||||||
/**
|
//todo make a Service ?
|
||||||
* @todo make a Service ?
|
|
||||||
*/
|
|
||||||
CustomEntityDirtinessStrategy getCustomEntityDirtinessStrategy();
|
CustomEntityDirtinessStrategy getCustomEntityDirtinessStrategy();
|
||||||
|
|
||||||
/**
|
//todo make a Service ?
|
||||||
* @todo make a Service ?
|
|
||||||
*/
|
|
||||||
CurrentTenantIdentifierResolver getCurrentTenantIdentifierResolver();
|
CurrentTenantIdentifierResolver getCurrentTenantIdentifierResolver();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -66,11 +66,6 @@ public final class TypedValue implements Serializable {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initTransients() {
|
private void initTransients() {
|
||||||
this.hashcode = new ValueHolder<>( new ValueHolder.DeferredInitializer<Integer>() {
|
this.hashcode = new ValueHolder<>( () -> value == null ? 0 : type.getHashCode( value ) );
|
||||||
@Override
|
|
||||||
public Integer initialize() {
|
|
||||||
return value == null ? 0 : type.getHashCode( value );
|
|
||||||
}
|
|
||||||
} );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,7 @@ public class VersionValue implements UnsavedValueStrategy {
|
||||||
*/
|
*/
|
||||||
public static final VersionValue NULL = new VersionValue() {
|
public static final VersionValue NULL = new VersionValue() {
|
||||||
@Override
|
@Override
|
||||||
public final Boolean isUnsaved(Object version) {
|
public Boolean isUnsaved(Object version) {
|
||||||
LOG.trace( "Version unsaved-value strategy NULL" );
|
LOG.trace( "Version unsaved-value strategy NULL" );
|
||||||
return version == null;
|
return version == null;
|
||||||
}
|
}
|
||||||
|
@ -52,7 +52,7 @@ public class VersionValue implements UnsavedValueStrategy {
|
||||||
*/
|
*/
|
||||||
public static final VersionValue UNDEFINED = new VersionValue() {
|
public static final VersionValue UNDEFINED = new VersionValue() {
|
||||||
@Override
|
@Override
|
||||||
public final Boolean isUnsaved(Object version) {
|
public Boolean isUnsaved(Object version) {
|
||||||
LOG.trace( "Version unsaved-value strategy UNDEFINED" );
|
LOG.trace( "Version unsaved-value strategy UNDEFINED" );
|
||||||
return version == null ? Boolean.TRUE : null;
|
return version == null ? Boolean.TRUE : null;
|
||||||
}
|
}
|
||||||
|
@ -75,7 +75,7 @@ public class VersionValue implements UnsavedValueStrategy {
|
||||||
public static final VersionValue NEGATIVE = new VersionValue() {
|
public static final VersionValue NEGATIVE = new VersionValue() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final Boolean isUnsaved(Object version) throws MappingException {
|
public Boolean isUnsaved(Object version) throws MappingException {
|
||||||
LOG.trace( "Version unsaved-value strategy NEGATIVE" );
|
LOG.trace( "Version unsaved-value strategy NEGATIVE" );
|
||||||
if ( version == null ) {
|
if ( version == null ) {
|
||||||
return Boolean.TRUE;
|
return Boolean.TRUE;
|
||||||
|
|
|
@ -16,78 +16,73 @@ import org.hibernate.event.spi.EntityCopyObserver;
|
||||||
import org.hibernate.event.spi.EventSource;
|
import org.hibernate.event.spi.EventSource;
|
||||||
import org.hibernate.pretty.MessageHelper;
|
import org.hibernate.pretty.MessageHelper;
|
||||||
|
|
||||||
import org.jboss.logging.Logger;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* MergeContext is a Map implementation that is intended to be used by a merge
|
* MergeContext is a Map implementation that is intended to be used by a merge
|
||||||
* event listener to keep track of each entity being merged and their corresponding
|
* event listener to keep track of each entity being merged and their corresponding
|
||||||
* managed result. Entities to be merged may to be added to the MergeContext before
|
* managed result. Entities to be merged may to be added to the MergeContext before
|
||||||
* the merge operation has cascaded to that entity.
|
* the merge operation has cascaded to that entity.
|
||||||
*
|
* <p>
|
||||||
* "Merge entity" and "mergeEntity" method parameter refer to an entity that is (or will be)
|
* "Merge entity" and "mergeEntity" method parameter refer to an entity that is
|
||||||
* merged via {@link EventSource#merge(Object mergeEntity)}.
|
* (or will be) merged via {@link EventSource#merge(Object mergeEntity)}.
|
||||||
*
|
* <p>
|
||||||
* "Managed entity" and "managedEntity" method parameter refer to the managed entity that is
|
* "Managed entity" and "managedEntity" method parameter refer to the managed entity
|
||||||
* the result of merging an entity.
|
* that is the result of merging an entity.
|
||||||
*
|
* <p>
|
||||||
* A merge entity can be transient, detached, or managed. If it is managed, then it must be
|
* A merge entity can be transient, detached, or managed. If it is managed, then it
|
||||||
* the same as its associated entity result.
|
* must be the same as its associated entity result.
|
||||||
*
|
* <p>
|
||||||
* If {@link #put(Object mergeEntity, Object managedEntity)} is called, and this
|
* If {@link #put(Object mergeEntity, Object managedEntity)} is called, and this
|
||||||
* MergeContext already contains an entry with a different entity as the key, but
|
* MergeContext already contains an entry with a different entity as the key, but
|
||||||
* with the same (managedEntity) value, this means that multiple entity representations
|
* with the same (managedEntity) value, this means that multiple entity
|
||||||
* for the same persistent entity are being merged. If this happens,
|
* representations for the same persistent entity are being merged. If this happens,
|
||||||
* {@link EntityCopyObserver#entityCopyDetected(
|
* {@link EntityCopyObserver#entityCopyDetected(
|
||||||
* Object managedEntity, Object mergeEntity1, Object mergeEntity2, EventSource)}
|
* Object managedEntity, Object mergeEntity1, Object mergeEntity2, EventSource)}
|
||||||
* will be called. It is up to that method to determine the property course of
|
* will be called. It is up to that method to determine the property course of
|
||||||
* action for this situation.
|
* action for this situation.
|
||||||
*
|
* <p>
|
||||||
* There are several restrictions.
|
* There are several restrictions.
|
||||||
* <ul>
|
* <ul>
|
||||||
* <li>Methods that return collections (e.g., {@link #keySet()},
|
* <li>Methods that return collections (e.g., {@link #keySet()}, {@link #values()},
|
||||||
* {@link #values()}, {@link #entrySet()}) return an
|
* {@link #entrySet()}) return an unmodifiable view of the collection;
|
||||||
* unmodifiable view of the collection;</li>
|
|
||||||
* <li>If {@link #put(Object mergeEntity, Object) managedEntity} or
|
* <li>If {@link #put(Object mergeEntity, Object) managedEntity} or
|
||||||
* {@link #put(Object mergeEntity, Object managedEntity, boolean isOperatedOn)}
|
* {@link #put(Object mergeEntity, Object managedEntity, boolean isOperatedOn)}
|
||||||
* is executed and this MergeMap already contains a cross-reference for
|
* is executed and this {@link MergeContext} already contains a cross-reference
|
||||||
* <code>mergeEntity</code>, then <code>managedEntity</code> must be the
|
* for {@code mergeEntity}, then {@code managedEntity} must be the same as
|
||||||
* same as what is already associated with <code>mergeEntity</code> in this
|
* what is already associated with {@code mergeEntity} in this
|
||||||
* MergeContext.
|
* {@link MergeContext}.
|
||||||
* </li>
|
* <li>If {@link #putAll(Map map)} is executed, the previous restriction applies
|
||||||
* <li>If {@link #putAll(Map map)} is executed, the previous restriction
|
* to each entry in the {@link Map};
|
||||||
* applies to each entry in the Map;</li>
|
* <li>The {@link #remove(Object)} operation is not supported; the only way to
|
||||||
* <li>The {@link #remove(Object)} operation is not supported;
|
* remove data from a {@link MergeContext} is by calling {@link #clear()};
|
||||||
* The only way to remove data from a MergeContext is by calling
|
* <li>the {@link Map} returned by {@link #invertMap()} will only contain the
|
||||||
* {@link #clear()};</li>
|
* managed-to-merge entity cross-reference to its "newest" (most recently
|
||||||
* <li>the Map returned by {@link #invertMap()} will only contain the
|
* added) merge entity.
|
||||||
* managed-to-merge entity cross-reference to its "newest"
|
|
||||||
* (most recently added) merge entity.</li>
|
|
||||||
* </ul>
|
* </ul>
|
||||||
* <p>
|
|
||||||
* The following method is intended to be used by a merge event listener (and other
|
* The following method is intended to be used by a merge event listener (and other
|
||||||
* classes) in the same package to add a merge entity and its corresponding
|
* classes) in the same package to add a merge entity and its corresponding
|
||||||
* managed entity to a MergeContext and indicate if the merge operation is
|
* managed entity to a MergeContext and indicate if the merge operation is
|
||||||
* being performed on the merge entity yet.<p/>
|
* being performed on the merge entity yet.
|
||||||
|
* <p>
|
||||||
* {@link MergeContext#put(Object mergeEntity, Object managedEntity, boolean isOperatedOn)}
|
* {@link MergeContext#put(Object mergeEntity, Object managedEntity, boolean isOperatedOn)}
|
||||||
* <p/>
|
* <p>
|
||||||
* The following method is intended to be used by a merge event listener (and other
|
* The following method is intended to be used by a merge event listener (and other
|
||||||
* classes) in the same package to indicate whether the merge operation is being
|
* classes) in the same package to indicate whether the merge operation is being
|
||||||
* performed on a merge entity already in the MergeContext:
|
* performed on a merge entity already in the {@link MergeContext}:
|
||||||
|
* <p>
|
||||||
* {@link MergeContext#setOperatedOn(Object mergeEntity, boolean isOperatedOn)}
|
* {@link MergeContext#setOperatedOn(Object mergeEntity, boolean isOperatedOn)}
|
||||||
*
|
*
|
||||||
* @author Gail Badner
|
* @author Gail Badner
|
||||||
*/
|
*/
|
||||||
public class MergeContext implements Map {
|
public class MergeContext implements Map {
|
||||||
private static final Logger LOG = Logger.getLogger( MergeContext.class );
|
|
||||||
|
|
||||||
private final EventSource session;
|
private final EventSource session;
|
||||||
private final EntityCopyObserver entityCopyObserver;
|
private final EntityCopyObserver entityCopyObserver;
|
||||||
|
|
||||||
private Map<Object,Object> mergeToManagedEntityXref = new IdentityHashMap<>(10);
|
private final Map<Object,Object> mergeToManagedEntityXref = new IdentityHashMap<>(10);
|
||||||
// key is an entity to be merged;
|
// key is an entity to be merged;
|
||||||
// value is the associated managed entity (result) in the persistence context.
|
// value is the associated managed entity (result) in the persistence context.
|
||||||
|
|
||||||
private Map<Object,Object> managedToMergeEntityXref = new IdentityHashMap<Object,Object>( 10 );
|
private final Map<Object,Object> managedToMergeEntityXref = new IdentityHashMap<>( 10 );
|
||||||
// maintains the inverse of the mergeToManagedEntityXref for performance reasons.
|
// maintains the inverse of the mergeToManagedEntityXref for performance reasons.
|
||||||
// key is the managed entity result in the persistence context.
|
// key is the managed entity result in the persistence context.
|
||||||
// value is the associated entity to be merged; if multiple
|
// value is the associated entity to be merged; if multiple
|
||||||
|
@ -97,7 +92,7 @@ public class MergeContext implements Map {
|
||||||
|
|
||||||
// TODO: merge mergeEntityToOperatedOnFlagMap into mergeToManagedEntityXref, since they have the same key.
|
// TODO: merge mergeEntityToOperatedOnFlagMap into mergeToManagedEntityXref, since they have the same key.
|
||||||
// need to check if this would hurt performance.
|
// need to check if this would hurt performance.
|
||||||
private Map<Object,Boolean> mergeEntityToOperatedOnFlagMap = new IdentityHashMap<>( 10 );
|
private final Map<Object,Boolean> mergeEntityToOperatedOnFlagMap = new IdentityHashMap<>( 10 );
|
||||||
// key is a merge entity;
|
// key is a merge entity;
|
||||||
// value is a flag indicating if the merge entity is currently in the merge process.
|
// value is a flag indicating if the merge entity is currently in the merge process.
|
||||||
|
|
||||||
|
@ -188,12 +183,12 @@ public class MergeContext implements Map {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Associates the specified merge entity with the specified managed entity result in this MergeContext.
|
* Associates the specified merge entity with the specified managed entity result in this MergeContext.
|
||||||
* If this MergeContext already contains a cross-reference for <code>mergeEntity</code> when this
|
* If this MergeContext already contains a cross-reference for {@code mergeEntity} when this
|
||||||
* method is called, then <code>managedEntity</code> must be the same as what is already associated
|
* method is called, then <code>managedEntity</code> must be the same as what is already associated
|
||||||
* with <code>mergeEntity</code>.
|
* with {@code mergeEntity}.
|
||||||
* <p/>
|
* <p/>
|
||||||
* This method assumes that the merge process is not yet operating on <code>mergeEntity</code>.
|
* This method assumes that the merge process is not yet operating on {@code mergeEntity}.
|
||||||
* Later when <code>mergeEntity</code> enters the merge process, {@link #setOperatedOn(Object, boolean)}
|
* Later when {@code mergeEntity} enters the merge process, {@link #setOperatedOn(Object, boolean)}
|
||||||
* should be called.
|
* should be called.
|
||||||
* <p/>
|
* <p/>
|
||||||
* @param mergeEntity the merge entity; must be non-null
|
* @param mergeEntity the merge entity; must be non-null
|
||||||
|
@ -211,9 +206,9 @@ public class MergeContext implements Map {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Associates the specified merge entity with the specified managed entity in this MergeContext.
|
* Associates the specified merge entity with the specified managed entity in this MergeContext.
|
||||||
* If this MergeContext already contains a cross-reference for <code>mergeEntity</code> when this
|
* If this MergeContext already contains a cross-reference for {@code mergeEntity} when this
|
||||||
* method is called, then <code>managedEntity</code> must be the same as what is already associated
|
* method is called, then <code>managedEntity</code> must be the same as what is already associated
|
||||||
* with <code>mergeEntity</code>.
|
* with {@code mergeEntity}.
|
||||||
*
|
*
|
||||||
* @param mergeEntity the merge entity; must be non-null
|
* @param mergeEntity the merge entity; must be non-null
|
||||||
* @param managedEntity the managed entity; must be non-null
|
* @param managedEntity the managed entity; must be non-null
|
||||||
|
@ -222,8 +217,8 @@ public class MergeContext implements Map {
|
||||||
* @return previous managed entity associated with specified merge entity, or null if
|
* @return previous managed entity associated with specified merge entity, or null if
|
||||||
* there was no mapping for mergeEntity.
|
* there was no mapping for mergeEntity.
|
||||||
* @throws NullPointerException if mergeEntity or managedEntity is null
|
* @throws NullPointerException if mergeEntity or managedEntity is null
|
||||||
* @throws IllegalArgumentException if <code>managedEntity</code> is not the same as the previous
|
* @throws IllegalArgumentException if {@code managedEntity} is not the same as the previous
|
||||||
* managed entity associated with <code>mergeEntity</code>
|
* managed entity associated with {@code mergeEntity}
|
||||||
* @throws IllegalStateException if internal cross-references are out of sync,
|
* @throws IllegalStateException if internal cross-references are out of sync,
|
||||||
*/
|
*/
|
||||||
public Object put(Object mergeEntity, Object managedEntity, boolean isOperatedOn) {
|
public Object put(Object mergeEntity, Object managedEntity, boolean isOperatedOn) {
|
||||||
|
@ -337,7 +332,7 @@ public class MergeContext implements Map {
|
||||||
throw new NullPointerException( "null merge entities are not supported by " + getClass().getName() );
|
throw new NullPointerException( "null merge entities are not supported by " + getClass().getName() );
|
||||||
}
|
}
|
||||||
final Boolean isOperatedOn = mergeEntityToOperatedOnFlagMap.get( mergeEntity );
|
final Boolean isOperatedOn = mergeEntityToOperatedOnFlagMap.get( mergeEntity );
|
||||||
return isOperatedOn == null ? false : isOperatedOn;
|
return isOperatedOn != null && isOperatedOn;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue