very minor cleanups to engine package

This commit is contained in:
Gavin King 2022-01-26 00:56:09 +01:00
parent ee1d27719c
commit f6287cedc2
15 changed files with 82 additions and 97 deletions

View File

@ -112,13 +112,13 @@ public class EffectiveEntityGraph implements AppliedGraph, Serializable {
return;
}
RootGraphImplementor fetchHint = (RootGraphImplementor) properties.get( GraphSemantic.FETCH.getJpaHintName() );
RootGraphImplementor loadHint = (RootGraphImplementor) properties.get( GraphSemantic.LOAD.getJpaHintName() );
RootGraphImplementor<?> fetchHint = (RootGraphImplementor<?>) properties.get( GraphSemantic.FETCH.getJpaHintName() );
RootGraphImplementor<?> loadHint = (RootGraphImplementor<?>) properties.get( GraphSemantic.LOAD.getJpaHintName() );
if (fetchHint == null) {
fetchHint = (RootGraphImplementor) properties.get( GraphSemantic.FETCH.getJakartaHintName() );
fetchHint = (RootGraphImplementor<?>) properties.get( GraphSemantic.FETCH.getJakartaHintName() );
}
if (loadHint == null) {
loadHint = (RootGraphImplementor) properties.get( GraphSemantic.LOAD.getJakartaHintName() );
loadHint = (RootGraphImplementor<?>) properties.get( GraphSemantic.LOAD.getJakartaHintName() );
}
if ( fetchHint == null && loadHint == null ) {

View File

@ -18,7 +18,7 @@ import org.hibernate.type.Type;
* Used to uniquely key an entity instance in relation to a particular session
* by some unique property reference, as opposed to identifier.
* <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.
*
* @author Gavin King

View File

@ -26,9 +26,9 @@ public interface ExceptionConverter {
RuntimeException convertCommitException(RuntimeException e);
/**
* Converts a Hibernate-specific exception into a JPA-specified exception; note that the JPA specification makes use
* of exceptions outside its exception hierarchy, though they are all runtime exceptions.
* <p/>
* Converts a Hibernate-specific exception into a JPA-specified exception;
* note that the JPA specification makes use of exceptions outside its
* exception hierarchy, though they are all runtime exceptions.
*
* @param e The Hibernate exception.
* @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);
/**
* Converts a Hibernate-specific exception into a JPA-specified exception; note that the JPA specification makes use
* of exceptions outside its exception hierarchy, though they are all runtime exceptions.
* <p/>
* Converts a Hibernate-specific exception into a JPA-specified exception;
* note that the JPA specification makes use of exceptions outside its
* exception hierarchy, though they are all runtime exceptions.
*
* @param e The Hibernate exception.
*

View File

@ -7,8 +7,8 @@
package org.hibernate.engine.spi;
/**
* For persistence operations (INSERT, UPDATE, DELETE) what style of determining
* results (success/failure) is to be used.
* For persistence operations (INSERT, UPDATE, DELETE) what style of
* determining results (success/failure) is to be used.
*
* @author Steve Ebersole
*/
@ -22,7 +22,7 @@ public enum ExecuteUpdateResultCheckStyle {
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.Statement#executeBatch()}. These values are checked
* against some expected count.
@ -39,7 +39,7 @@ public enum ExecuteUpdateResultCheckStyle {
private final String name;
private ExecuteUpdateResultCheckStyle(String name) {
ExecuteUpdateResultCheckStyle(String name) {
this.name = name;
}

View File

@ -11,8 +11,9 @@ import org.hibernate.bytecode.enhance.spi.interceptor.LazyAttributeLoadingInterc
import org.hibernate.engine.spi.SelfDirtinessTracker;
/**
* A self dirtiness tracker that declares additional methods that are intended for internal communication. This
* interface can be implemented optionally instead of the plain {@link SelfDirtinessTracker}.
* A self dirtiness tracker that declares additional methods that are intended for
* internal communication. This interface can be implemented optionally instead of
* the plain {@link SelfDirtinessTracker}.
*/
public interface ExtendedSelfDirtinessTracker extends SelfDirtinessTracker {

View File

@ -16,8 +16,9 @@ import org.hibernate.metamodel.mapping.JdbcMapping;
/**
* Represents the definition of a {@link org.hibernate.Filter filter}.
* This information includes the {@linkplain #filterName name} of the
* filter, along with the {@linkplain #parameterTypes name and type}
* of every parameter of the filter. A filter may optionally have a
* filter, along with the {@linkplain #getParameterJdbcMapping(String)
* names} and {@linkplain #getParameterJdbcMapping(String) types} of
* every parameter of the filter. A filter may optionally have a
* {@linkplain #defaultFilterCondition default condition}.
*
* @see org.hibernate.annotations.FilterDef

View File

@ -30,7 +30,7 @@ public class IdentifierValue implements UnsavedValueStrategy {
*/
public static final IdentifierValue ANY = new IdentifierValue() {
@Override
public final Boolean isUnsaved(Object id) {
public Boolean isUnsaved(Object id) {
LOG.trace( "ID unsaved-value strategy ANY" );
return Boolean.TRUE;
}
@ -51,7 +51,7 @@ public class IdentifierValue implements UnsavedValueStrategy {
*/
public static final IdentifierValue NONE = new IdentifierValue() {
@Override
public final Boolean isUnsaved(Object id) {
public Boolean isUnsaved(Object id) {
LOG.trace( "ID unsaved-value strategy NONE" );
return Boolean.FALSE;
}
@ -73,7 +73,7 @@ public class IdentifierValue implements UnsavedValueStrategy {
*/
public static final IdentifierValue NULL = new IdentifierValue() {
@Override
public final Boolean isUnsaved(Object id) {
public Boolean isUnsaved(Object id) {
LOG.trace( "ID unsaved-value strategy NULL" );
return id == null;
}
@ -94,7 +94,7 @@ public class IdentifierValue implements UnsavedValueStrategy {
*/
public static final IdentifierValue UNDEFINED = new IdentifierValue() {
@Override
public final Boolean isUnsaved(Object id) {
public Boolean isUnsaved(Object id) {
LOG.trace( "ID unsaved-value strategy UNDEFINED" );
return null;
}

View File

@ -741,7 +741,6 @@ public interface PersistenceContext {
/**
* Registers an {@link EntityKey} as nullifiable on this {@link PersistenceContext}.
* @param key
*/
void registerNullifiableEntityKey(EntityKey key);
@ -772,8 +771,7 @@ public interface PersistenceContext {
/**
* Adds a collection in the collections-by-key map.
* @param collectionKey
* @param persistentCollection
*
* @return the previous collection, it the key was already mapped.
*/
PersistentCollection<?> addCollectionByKey(CollectionKey collectionKey, PersistentCollection<?> persistentCollection);

View File

@ -14,7 +14,7 @@ import org.hibernate.bytecode.enhance.spi.CollectionTracker;
* <p/>
* Entity classes are free to implement this contract themselves. This contract is
* 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>
*/

View File

@ -9,8 +9,8 @@ package org.hibernate.engine.spi;
import org.hibernate.SessionBuilder;
/**
* Defines the internal contract between the {@code SessionBuilder} and other parts of
* Hibernate..
* Defines the internal contract between the {@link SessionBuilder} and
* other parts of Hibernate.
*
* @see SessionBuilder
*

View File

@ -60,7 +60,6 @@ import jakarta.persistence.SynchronizationType;
*
* @author Steve Ebersole
*/
@SuppressWarnings({"deprecation", "unused"})
public class SessionFactoryDelegatingImpl implements SessionFactoryImplementor, SessionFactory {
private final SessionFactoryImplementor delegate;
@ -107,17 +106,17 @@ public class SessionFactoryDelegatingImpl implements SessionFactoryImplementor,
return delegate.openStatelessSession( connection );
}
@Override
@Override @Deprecated
public ClassMetadata getClassMetadata(@SuppressWarnings("rawtypes") Class entityClass) {
return delegate.getClassMetadata( entityClass );
}
@Override
@Override @Deprecated
public ClassMetadata getClassMetadata(String entityName) {
return delegate.getClassMetadata( entityName );
}
@Override
@Override @Deprecated
public CollectionMetadata getCollectionMetadata(String roleName) {
return delegate.getCollectionMetadata( roleName );
}
@ -367,7 +366,7 @@ public class SessionFactoryDelegatingImpl implements SessionFactoryImplementor,
return delegate.getCriteriaBuilder();
}
@Override
@Override @SuppressWarnings("deprecation")
public MetamodelImplementor getMetamodel() {
return delegate.getMetamodel();
}

View File

@ -128,14 +128,10 @@ public interface SessionFactoryImplementor
void addObserver(SessionFactoryObserver observer);
/**
* @todo make a Service ?
*/
//todo make a Service ?
CustomEntityDirtinessStrategy getCustomEntityDirtinessStrategy();
/**
* @todo make a Service ?
*/
//todo make a Service ?
CurrentTenantIdentifierResolver getCurrentTenantIdentifierResolver();
/**

View File

@ -66,11 +66,6 @@ public final class TypedValue implements Serializable {
}
private void initTransients() {
this.hashcode = new ValueHolder<>( new ValueHolder.DeferredInitializer<Integer>() {
@Override
public Integer initialize() {
return value == null ? 0 : type.getHashCode( value );
}
} );
this.hashcode = new ValueHolder<>( () -> value == null ? 0 : type.getHashCode( value ) );
}
}

View File

@ -30,7 +30,7 @@ public class VersionValue implements UnsavedValueStrategy {
*/
public static final VersionValue NULL = new VersionValue() {
@Override
public final Boolean isUnsaved(Object version) {
public Boolean isUnsaved(Object version) {
LOG.trace( "Version unsaved-value strategy NULL" );
return version == null;
}
@ -52,7 +52,7 @@ public class VersionValue implements UnsavedValueStrategy {
*/
public static final VersionValue UNDEFINED = new VersionValue() {
@Override
public final Boolean isUnsaved(Object version) {
public Boolean isUnsaved(Object version) {
LOG.trace( "Version unsaved-value strategy UNDEFINED" );
return version == null ? Boolean.TRUE : null;
}
@ -75,7 +75,7 @@ public class VersionValue implements UnsavedValueStrategy {
public static final VersionValue NEGATIVE = new VersionValue() {
@Override
public final Boolean isUnsaved(Object version) throws MappingException {
public Boolean isUnsaved(Object version) throws MappingException {
LOG.trace( "Version unsaved-value strategy NEGATIVE" );
if ( version == null ) {
return Boolean.TRUE;

View File

@ -16,78 +16,73 @@ import org.hibernate.event.spi.EntityCopyObserver;
import org.hibernate.event.spi.EventSource;
import org.hibernate.pretty.MessageHelper;
import org.jboss.logging.Logger;
/**
* 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
* managed result. Entities to be merged may to be added to the MergeContext before
* the merge operation has cascaded to that entity.
*
* "Merge entity" and "mergeEntity" method parameter refer to an entity that is (or will be)
* merged via {@link EventSource#merge(Object mergeEntity)}.
*
* "Managed entity" and "managedEntity" method parameter refer to the managed entity that is
* the result of merging an entity.
*
* A merge entity can be transient, detached, or managed. If it is managed, then it must be
* the same as its associated entity result.
*
* <p>
* "Merge entity" and "mergeEntity" method parameter refer to an entity that is
* (or will be) merged via {@link EventSource#merge(Object mergeEntity)}.
* <p>
* "Managed entity" and "managedEntity" method parameter refer to the managed 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 the same as its associated entity result.
* <p>
* If {@link #put(Object mergeEntity, Object managedEntity)} is called, and this
* MergeContext already contains an entry with a different entity as the key, but
* with the same (managedEntity) value, this means that multiple entity representations
* for the same persistent entity are being merged. If this happens,
* with the same (managedEntity) value, this means that multiple entity
* representations for the same persistent entity are being merged. If this happens,
* {@link EntityCopyObserver#entityCopyDetected(
* Object managedEntity, Object mergeEntity1, Object mergeEntity2, EventSource)}
* will be called. It is up to that method to determine the property course of
* action for this situation.
*
* <p>
* There are several restrictions.
* <ul>
* <li>Methods that return collections (e.g., {@link #keySet()},
* {@link #values()}, {@link #entrySet()}) return an
* unmodifiable view of the collection;</li>
* <li>Methods that return collections (e.g., {@link #keySet()}, {@link #values()},
* {@link #entrySet()}) return an unmodifiable view of the collection;
* <li>If {@link #put(Object mergeEntity, Object) managedEntity} or
* {@link #put(Object mergeEntity, Object managedEntity, boolean isOperatedOn)}
* is executed and this MergeMap already contains a cross-reference for
* <code>mergeEntity</code>, then <code>managedEntity</code> must be the
* same as what is already associated with <code>mergeEntity</code> in this
* MergeContext.
* </li>
* <li>If {@link #putAll(Map map)} is executed, the previous restriction
* applies to each entry in the Map;</li>
* <li>The {@link #remove(Object)} operation is not supported;
* The only way to remove data from a MergeContext is by calling
* {@link #clear()};</li>
* <li>the Map returned by {@link #invertMap()} will only contain the
* managed-to-merge entity cross-reference to its "newest"
* (most recently added) merge entity.</li>
* is executed and this {@link MergeContext} already contains a cross-reference
* for {@code mergeEntity}, then {@code managedEntity} must be the same as
* what is already associated with {@code mergeEntity} in this
* {@link MergeContext}.
* <li>If {@link #putAll(Map map)} is executed, the previous restriction applies
* to each entry in the {@link Map};
* <li>The {@link #remove(Object)} operation is not supported; the only way to
* remove data from a {@link MergeContext} is by calling {@link #clear()};
* <li>the {@link Map} returned by {@link #invertMap()} will only contain the
* managed-to-merge entity cross-reference to its "newest" (most recently
* added) merge entity.
* </ul>
* <p>
* 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
* 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)}
* <p/>
* <p>
* 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
* 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)}
*
* @author Gail Badner
*/
public class MergeContext implements Map {
private static final Logger LOG = Logger.getLogger( MergeContext.class );
private final EventSource session;
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;
// 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.
// key is the managed entity result in the persistence context.
// 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.
// 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;
// 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.
* 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
* with <code>mergeEntity</code>.
* with {@code mergeEntity}.
* <p/>
* This method assumes that the merge process is not yet operating on <code>mergeEntity</code>.
* Later when <code>mergeEntity</code> enters the merge process, {@link #setOperatedOn(Object, boolean)}
* This method assumes that the merge process is not yet operating on {@code mergeEntity}.
* Later when {@code mergeEntity} enters the merge process, {@link #setOperatedOn(Object, boolean)}
* should be called.
* <p/>
* @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.
* 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
* with <code>mergeEntity</code>.
* with {@code mergeEntity}.
*
* @param mergeEntity the merge 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
* there was no mapping for mergeEntity.
* @throws NullPointerException if mergeEntity or managedEntity is null
* @throws IllegalArgumentException if <code>managedEntity</code> is not the same as the previous
* managed entity associated with <code>mergeEntity</code>
* @throws IllegalArgumentException if {@code managedEntity} is not the same as the previous
* managed entity associated with {@code mergeEntity}
* @throws IllegalStateException if internal cross-references are out of sync,
*/
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() );
}
final Boolean isOperatedOn = mergeEntityToOperatedOnFlagMap.get( mergeEntity );
return isOperatedOn == null ? false : isOperatedOn;
return isOperatedOn != null && isOperatedOn;
}
/**