squash more warnings
This commit is contained in:
parent
8b83a53678
commit
67e7b895cc
|
@ -36,6 +36,7 @@ import org.hibernate.type.ManyToOneType;
|
|||
import org.hibernate.type.OneToOneType;
|
||||
import org.hibernate.type.Type;
|
||||
|
||||
import static java.util.Collections.EMPTY_LIST;
|
||||
import static org.hibernate.engine.internal.ManagedTypeHelper.isHibernateProxy;
|
||||
import static org.hibernate.engine.spi.CascadingActions.CHECK_ON_FLUSH;
|
||||
import static org.hibernate.pretty.MessageHelper.infoString;
|
||||
|
@ -89,7 +90,8 @@ public final class Cascade {
|
|||
LOG.tracev( "Processing cascade {0} for: {1}", action, persister.getEntityName() );
|
||||
}
|
||||
final PersistenceContext persistenceContext = eventSource.getPersistenceContextInternal();
|
||||
final boolean enhancedForLazyLoading = persister.getBytecodeEnhancementMetadata().isEnhancedForLazyLoading();
|
||||
final boolean enhancedForLazyLoading =
|
||||
persister.getBytecodeEnhancementMetadata().isEnhancedForLazyLoading();
|
||||
final EntityEntry entry;
|
||||
if ( enhancedForLazyLoading ) {
|
||||
entry = persistenceContext.getEntry( parent );
|
||||
|
@ -112,8 +114,9 @@ public final class Cascade {
|
|||
final String propertyName = propertyNames[ i ];
|
||||
final Type type = types[i];
|
||||
final boolean isUninitializedProperty =
|
||||
hasUninitializedLazyProperties &&
|
||||
!persister.getBytecodeEnhancementMetadata().isAttributeLoaded( parent, propertyName );
|
||||
hasUninitializedLazyProperties
|
||||
&& !persister.getBytecodeEnhancementMetadata()
|
||||
.isAttributeLoaded( parent, propertyName );
|
||||
|
||||
if ( style.doCascade( action ) ) {
|
||||
final Object child;
|
||||
|
@ -129,14 +132,13 @@ public final class Cascade {
|
|||
// parent was not in the PersistenceContext
|
||||
continue;
|
||||
}
|
||||
if ( type instanceof CollectionType ) {
|
||||
if ( type instanceof CollectionType collectionType ) {
|
||||
// CollectionType#getCollection gets the PersistentCollection
|
||||
// that corresponds to the uninitialized collection from the
|
||||
// PersistenceContext. If not present, an uninitialized
|
||||
// PersistentCollection will be added to the PersistenceContext.
|
||||
// The action may initialize it later, if necessary.
|
||||
// This needs to be done even when action.performOnLazyProperty() returns false.
|
||||
final CollectionType collectionType = (CollectionType) type;
|
||||
child = collectionType.getCollection(
|
||||
collectionType.getKeyOfOwner( parent, eventSource ),
|
||||
eventSource,
|
||||
|
@ -146,15 +148,14 @@ public final class Cascade {
|
|||
}
|
||||
else if ( type instanceof AnyType || type instanceof ComponentType ) {
|
||||
// Hibernate does not support lazy embeddables, so this shouldn't happen.
|
||||
throw new UnsupportedOperationException(
|
||||
"Lazy components are not supported."
|
||||
);
|
||||
throw new UnsupportedOperationException( "Lazy embeddables are not supported" );
|
||||
}
|
||||
else if ( action.performOnLazyProperty() && type instanceof EntityType ) {
|
||||
// Only need to initialize a lazy entity attribute when action.performOnLazyProperty()
|
||||
// returns true.
|
||||
LazyAttributeLoadingInterceptor interceptor = persister.getBytecodeEnhancementMetadata()
|
||||
.extractInterceptor( parent );
|
||||
final LazyAttributeLoadingInterceptor interceptor =
|
||||
persister.getBytecodeEnhancementMetadata()
|
||||
.extractInterceptor( parent );
|
||||
child = interceptor.fetchAttribute( parent, propertyName );
|
||||
|
||||
}
|
||||
|
@ -238,10 +239,10 @@ public final class Cascade {
|
|||
style,
|
||||
anything,
|
||||
isCascadeDeleteEnabled
|
||||
);
|
||||
);
|
||||
}
|
||||
}
|
||||
else if ( type instanceof ComponentType ) {
|
||||
else if ( type instanceof ComponentType componentType ) {
|
||||
if ( componentPath == null && propertyName != null ) {
|
||||
componentPath = new ArrayList<>();
|
||||
}
|
||||
|
@ -255,7 +256,7 @@ public final class Cascade {
|
|||
componentPath,
|
||||
parent,
|
||||
child,
|
||||
(CompositeType) type,
|
||||
componentType,
|
||||
anything
|
||||
);
|
||||
if ( componentPath != null ) {
|
||||
|
@ -273,7 +274,8 @@ public final class Cascade {
|
|||
type,
|
||||
style,
|
||||
propertyName,
|
||||
isCascadeDeleteEnabled );
|
||||
isCascadeDeleteEnabled
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -376,8 +378,8 @@ public final class Cascade {
|
|||
|
||||
private static boolean isForeignKeyToParent(Type type) {
|
||||
return type instanceof CollectionType
|
||||
|| type instanceof OneToOneType
|
||||
&& ((OneToOneType) type).getForeignKeyDirection() == ForeignKeyDirection.TO_PARENT;
|
||||
|| type instanceof OneToOneType oneToOneType
|
||||
&& oneToOneType.getForeignKeyDirection() == ForeignKeyDirection.TO_PARENT;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -389,7 +391,7 @@ public final class Cascade {
|
|||
* @return True if the attribute represents a logical one to one association
|
||||
*/
|
||||
private static boolean isLogicalOneToOne(Type type) {
|
||||
return type instanceof EntityType && ( (EntityType) type ).isLogicalOneToOne();
|
||||
return type instanceof EntityType entityType && entityType.isLogicalOneToOne();
|
||||
}
|
||||
|
||||
private static boolean cascadeAssociationNow(
|
||||
|
@ -399,24 +401,22 @@ public final class Cascade {
|
|||
SessionFactoryImplementor factory,
|
||||
boolean unownedTransient) {
|
||||
return associationType.getForeignKeyDirection().cascadeNow( cascadePoint )
|
||||
// For check on flush, we should only check unowned associations when strictness is enforced
|
||||
&& ( action != CHECK_ON_FLUSH || unownedTransient || !isUnownedAssociation( associationType, factory ) );
|
||||
// For check on flush, we should only check unowned associations when strictness is enforced
|
||||
&& ( action != CHECK_ON_FLUSH || unownedTransient || !isUnownedAssociation( associationType, factory ) );
|
||||
}
|
||||
|
||||
private static boolean isUnownedAssociation(AssociationType associationType, SessionFactoryImplementor factory) {
|
||||
if ( associationType instanceof ManyToOneType ) {
|
||||
final ManyToOneType manyToOne = (ManyToOneType) associationType;
|
||||
if ( associationType instanceof ManyToOneType manyToOne ) {
|
||||
// logical one-to-one + non-null unique key property name indicates unowned
|
||||
return manyToOne.isLogicalOneToOne() && manyToOne.getRHSUniqueKeyPropertyName() != null;
|
||||
}
|
||||
else if ( associationType instanceof OneToOneType ) {
|
||||
final OneToOneType oneToOne = (OneToOneType) associationType;
|
||||
else if ( associationType instanceof OneToOneType oneToOne ) {
|
||||
// constrained false + non-null unique key property name indicates unowned
|
||||
return oneToOne.isNullable() && oneToOne.getRHSUniqueKeyPropertyName() != null;
|
||||
}
|
||||
else if ( associationType instanceof CollectionType ) {
|
||||
else if ( associationType instanceof CollectionType collectionType ) {
|
||||
// for collections, we can ask the persister if we're on the inverse side
|
||||
return ( (CollectionType) associationType ).isInverse( factory );
|
||||
return collectionType.isInverse( factory );
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -454,7 +454,7 @@ public final class Cascade {
|
|||
subPropertyName,
|
||||
anything,
|
||||
false
|
||||
);
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -473,7 +473,7 @@ public final class Cascade {
|
|||
if ( type instanceof EntityType || type instanceof AnyType ) {
|
||||
cascadeToOne( action, eventSource, parent, child, type, style, anything, isCascadeDeleteEnabled );
|
||||
}
|
||||
else if ( type instanceof CollectionType ) {
|
||||
else if ( type instanceof CollectionType collectionType ) {
|
||||
cascadeCollection(
|
||||
action,
|
||||
cascadePoint,
|
||||
|
@ -483,7 +483,7 @@ public final class Cascade {
|
|||
child,
|
||||
style,
|
||||
anything,
|
||||
(CollectionType) type
|
||||
collectionType
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -505,17 +505,13 @@ public final class Cascade {
|
|||
eventSource.getFactory().getMappingMetamodel()
|
||||
.getCollectionDescriptor( type.getRole() );
|
||||
final Type elemType = persister.getElementType();
|
||||
|
||||
CascadePoint elementsCascadePoint = cascadePoint;
|
||||
if ( cascadePoint == CascadePoint.AFTER_INSERT_BEFORE_DELETE ) {
|
||||
elementsCascadePoint = CascadePoint.AFTER_INSERT_BEFORE_DELETE_VIA_COLLECTION;
|
||||
}
|
||||
|
||||
//cascade to current collection elements
|
||||
if ( elemType instanceof EntityType || elemType instanceof AnyType || elemType instanceof ComponentType ) {
|
||||
cascadeCollectionElements(
|
||||
action,
|
||||
elementsCascadePoint,
|
||||
cascadePoint == CascadePoint.AFTER_INSERT_BEFORE_DELETE
|
||||
? CascadePoint.AFTER_INSERT_BEFORE_DELETE_VIA_COLLECTION
|
||||
: cascadePoint,
|
||||
eventSource,
|
||||
componentPath,
|
||||
parent,
|
||||
|
@ -541,9 +537,10 @@ public final class Cascade {
|
|||
final CascadeStyle style,
|
||||
final T anything,
|
||||
final boolean isCascadeDeleteEnabled) {
|
||||
final String entityName = type instanceof EntityType
|
||||
? ( (EntityType) type ).getAssociatedEntityName()
|
||||
: null;
|
||||
final String entityName =
|
||||
type instanceof EntityType entityType
|
||||
? entityType.getAssociatedEntityName()
|
||||
: null;
|
||||
if ( style.reallyDoCascade( action ) ) {
|
||||
//not really necessary, but good for consistency...
|
||||
final PersistenceContext persistenceContext = eventSource.getPersistenceContextInternal();
|
||||
|
@ -572,6 +569,7 @@ public final class Cascade {
|
|||
final Type elemType,
|
||||
final T anything,
|
||||
final boolean isCascadeDeleteEnabled) throws HibernateException {
|
||||
|
||||
final boolean reallyDoCascade = style.reallyDoCascade( action )
|
||||
&& child != CollectionType.UNFETCHED_COLLECTION;
|
||||
|
||||
|
@ -581,15 +579,15 @@ public final class Cascade {
|
|||
LOG.tracev( "Cascade {0} for collection: {1}", action, collectionType.getRole() );
|
||||
}
|
||||
|
||||
final Iterator<?> itr = action.getCascadableChildrenIterator( eventSource, collectionType, child );
|
||||
while ( itr.hasNext() ) {
|
||||
final Iterator<?> iterator = action.getCascadableChildrenIterator( eventSource, collectionType, child );
|
||||
while ( iterator.hasNext() ) {
|
||||
cascadeProperty(
|
||||
action,
|
||||
cascadePoint,
|
||||
eventSource,
|
||||
componentPath,
|
||||
parent,
|
||||
itr.next(),
|
||||
iterator.next(),
|
||||
elemType,
|
||||
style,
|
||||
collectionType.getRole().substring( collectionType.getRole().lastIndexOf('.') + 1 ),
|
||||
|
@ -606,9 +604,9 @@ public final class Cascade {
|
|||
final boolean deleteOrphans = style.hasOrphanDelete()
|
||||
&& action.deleteOrphans()
|
||||
&& elemType instanceof EntityType
|
||||
&& child instanceof PersistentCollection
|
||||
&& child instanceof PersistentCollection<?> persistentCollection
|
||||
// a newly instantiated collection can't have orphans
|
||||
&& ! ( (PersistentCollection<?>) child ).isNewlyInstantiated();
|
||||
&& !persistentCollection.isNewlyInstantiated();
|
||||
|
||||
if ( deleteOrphans ) {
|
||||
final boolean traceEnabled = LOG.isTraceEnabled();
|
||||
|
@ -634,10 +632,8 @@ public final class Cascade {
|
|||
//TODO: suck this logic into the collection!
|
||||
final Collection<?> orphans;
|
||||
if ( pc.wasInitialized() ) {
|
||||
final CollectionEntry ce = eventSource.getPersistenceContextInternal().getCollectionEntry( pc );
|
||||
orphans = ce==null
|
||||
? java.util.Collections.EMPTY_LIST
|
||||
: ce.getOrphans( entityName, pc );
|
||||
final CollectionEntry entry = eventSource.getPersistenceContextInternal().getCollectionEntry( pc );
|
||||
orphans = entry == null ? EMPTY_LIST : entry.getOrphans( entityName, pc );
|
||||
}
|
||||
else {
|
||||
orphans = pc.getQueuedOrphans( entityName );
|
||||
|
|
|
@ -1167,8 +1167,7 @@ public class ActionQueue {
|
|||
if ( value == null ) {
|
||||
return;
|
||||
}
|
||||
if ( type instanceof EntityType ) {
|
||||
final EntityType entityType = (EntityType) type;
|
||||
if ( type instanceof EntityType entityType ) {
|
||||
final InsertInfo insertInfo = insertInfosByEntity.get( value );
|
||||
if ( insertInfo != null ) {
|
||||
if ( entityType.isOneToOne()
|
||||
|
@ -1188,8 +1187,7 @@ public class ActionQueue {
|
|||
}
|
||||
}
|
||||
}
|
||||
else if ( type instanceof CollectionType ) {
|
||||
CollectionType collectionType = (CollectionType) type;
|
||||
else if ( type instanceof CollectionType collectionType ) {
|
||||
final PluralAttributeMapping pluralAttributeMapping = insertAction.getSession()
|
||||
.getFactory()
|
||||
.getMappingMetamodel()
|
||||
|
@ -1212,9 +1210,8 @@ public class ActionQueue {
|
|||
}
|
||||
}
|
||||
}
|
||||
else if ( type instanceof ComponentType ) {
|
||||
else if ( type instanceof ComponentType compositeType ) {
|
||||
// Support recursive checks of composite type properties for associations and collections.
|
||||
ComponentType compositeType = (ComponentType) type;
|
||||
final SharedSessionContractImplementor session = insertAction.getSession();
|
||||
final Object[] componentValues = compositeType.getPropertyValues( value, session );
|
||||
for ( int j = 0; j < componentValues.length; ++j ) {
|
||||
|
|
|
@ -22,7 +22,7 @@ public interface CascadeStyle extends Serializable {
|
|||
*
|
||||
* @return True if the action should be cascaded under this style; false otherwise.
|
||||
*/
|
||||
boolean doCascade(CascadingAction action);
|
||||
boolean doCascade(CascadingAction<?> action);
|
||||
|
||||
/**
|
||||
* Probably more aptly named something like doCascadeToCollectionElements(); it is
|
||||
|
@ -38,7 +38,7 @@ public interface CascadeStyle extends Serializable {
|
|||
* @return True if the action should be really cascaded under this style;
|
||||
* false otherwise.
|
||||
*/
|
||||
boolean reallyDoCascade(CascadingAction action);
|
||||
boolean reallyDoCascade(CascadingAction<?> action);
|
||||
|
||||
/**
|
||||
* Do we need to delete orphaned collection elements?
|
||||
|
|
|
@ -30,7 +30,7 @@ public final class CascadeStyles {
|
|||
*/
|
||||
public static final CascadeStyle ALL_DELETE_ORPHAN = new BaseCascadeStyle() {
|
||||
@Override
|
||||
public boolean doCascade(CascadingAction action) {
|
||||
public boolean doCascade(CascadingAction<?> action) {
|
||||
return action != CascadingActions.CHECK_ON_FLUSH;
|
||||
}
|
||||
|
||||
|
@ -50,7 +50,7 @@ public final class CascadeStyles {
|
|||
*/
|
||||
public static final CascadeStyle ALL = new BaseCascadeStyle() {
|
||||
@Override
|
||||
public boolean doCascade(CascadingAction action) {
|
||||
public boolean doCascade(CascadingAction<?> action) {
|
||||
return action != CascadingActions.CHECK_ON_FLUSH;
|
||||
}
|
||||
|
||||
|
@ -65,7 +65,7 @@ public final class CascadeStyles {
|
|||
*/
|
||||
public static final CascadeStyle LOCK = new BaseCascadeStyle() {
|
||||
@Override
|
||||
public boolean doCascade(CascadingAction action) {
|
||||
public boolean doCascade(CascadingAction<?> action) {
|
||||
return action == CascadingActions.LOCK
|
||||
|| action == CascadingActions.CHECK_ON_FLUSH;
|
||||
}
|
||||
|
@ -81,7 +81,7 @@ public final class CascadeStyles {
|
|||
*/
|
||||
public static final CascadeStyle REFRESH = new BaseCascadeStyle() {
|
||||
@Override
|
||||
public boolean doCascade(CascadingAction action) {
|
||||
public boolean doCascade(CascadingAction<?> action) {
|
||||
return action == CascadingActions.REFRESH
|
||||
|| action == CascadingActions.CHECK_ON_FLUSH;
|
||||
}
|
||||
|
@ -97,7 +97,7 @@ public final class CascadeStyles {
|
|||
*/
|
||||
public static final CascadeStyle EVICT = new BaseCascadeStyle() {
|
||||
@Override
|
||||
public boolean doCascade(CascadingAction action) {
|
||||
public boolean doCascade(CascadingAction<?> action) {
|
||||
return action == CascadingActions.EVICT
|
||||
|| action == CascadingActions.CHECK_ON_FLUSH;
|
||||
}
|
||||
|
@ -113,7 +113,7 @@ public final class CascadeStyles {
|
|||
*/
|
||||
public static final CascadeStyle REPLICATE = new BaseCascadeStyle() {
|
||||
@Override
|
||||
public boolean doCascade(CascadingAction action) {
|
||||
public boolean doCascade(CascadingAction<?> action) {
|
||||
return action == CascadingActions.REPLICATE
|
||||
|| action == CascadingActions.CHECK_ON_FLUSH;
|
||||
}
|
||||
|
@ -129,7 +129,7 @@ public final class CascadeStyles {
|
|||
*/
|
||||
public static final CascadeStyle MERGE = new BaseCascadeStyle() {
|
||||
@Override
|
||||
public boolean doCascade(CascadingAction action) {
|
||||
public boolean doCascade(CascadingAction<?> action) {
|
||||
return action == CascadingActions.MERGE
|
||||
|| action == CascadingActions.CHECK_ON_FLUSH;
|
||||
}
|
||||
|
@ -145,7 +145,7 @@ public final class CascadeStyles {
|
|||
*/
|
||||
public static final CascadeStyle PERSIST = new BaseCascadeStyle() {
|
||||
@Override
|
||||
public boolean doCascade(CascadingAction action) {
|
||||
public boolean doCascade(CascadingAction<?> action) {
|
||||
return action == CascadingActions.PERSIST
|
||||
|| action == CascadingActions.PERSIST_ON_FLUSH;
|
||||
}
|
||||
|
@ -161,7 +161,7 @@ public final class CascadeStyles {
|
|||
*/
|
||||
public static final CascadeStyle DELETE = new BaseCascadeStyle() {
|
||||
@Override
|
||||
public boolean doCascade(CascadingAction action) {
|
||||
public boolean doCascade(CascadingAction<?> action) {
|
||||
return action == CascadingActions.REMOVE
|
||||
|| action == CascadingActions.CHECK_ON_FLUSH;
|
||||
}
|
||||
|
@ -177,14 +177,14 @@ public final class CascadeStyles {
|
|||
*/
|
||||
public static final CascadeStyle DELETE_ORPHAN = new BaseCascadeStyle() {
|
||||
@Override
|
||||
public boolean doCascade(CascadingAction action) {
|
||||
public boolean doCascade(CascadingAction<?> action) {
|
||||
return action == CascadingActions.REMOVE
|
||||
|| action == CascadingActions.PERSIST_ON_FLUSH
|
||||
|| action == CascadingActions.CHECK_ON_FLUSH;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean reallyDoCascade(CascadingAction action) {
|
||||
public boolean reallyDoCascade(CascadingAction<?> action) {
|
||||
return action == CascadingActions.REMOVE
|
||||
|| action == CascadingActions.CHECK_ON_FLUSH;
|
||||
}
|
||||
|
@ -205,7 +205,7 @@ public final class CascadeStyles {
|
|||
*/
|
||||
public static final CascadeStyle NONE = new BaseCascadeStyle() {
|
||||
@Override
|
||||
public boolean doCascade(CascadingAction action) {
|
||||
public boolean doCascade(CascadingAction<?> action) {
|
||||
return action == CascadingActions.CHECK_ON_FLUSH;
|
||||
}
|
||||
|
||||
|
@ -268,7 +268,7 @@ public final class CascadeStyles {
|
|||
|
||||
public static abstract class BaseCascadeStyle implements CascadeStyle {
|
||||
@Override
|
||||
public boolean reallyDoCascade(CascadingAction action) {
|
||||
public boolean reallyDoCascade(CascadingAction<?> action) {
|
||||
return doCascade( action );
|
||||
}
|
||||
|
||||
|
@ -286,7 +286,7 @@ public final class CascadeStyles {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean doCascade(CascadingAction action) {
|
||||
public boolean doCascade(CascadingAction<?> action) {
|
||||
if ( action == CascadingActions.CHECK_ON_FLUSH ) {
|
||||
return !reallyDoCascade( CascadingActions.PERSIST_ON_FLUSH );
|
||||
}
|
||||
|
@ -299,7 +299,7 @@ public final class CascadeStyles {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean reallyDoCascade(CascadingAction action) {
|
||||
public boolean reallyDoCascade(CascadingAction<?> action) {
|
||||
for ( CascadeStyle style : styles ) {
|
||||
if ( style.reallyDoCascade( action ) ) {
|
||||
return true;
|
||||
|
|
|
@ -17,9 +17,8 @@ import org.jboss.logging.Logger;
|
|||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
/**
|
||||
* Think of this as the composite modeling of a graph
|
||||
* and the semantic.
|
||||
*
|
||||
* Think of this as the composite modeling of a graph and the semantic.
|
||||
* <p>
|
||||
* Its graph and semantic can be obtained by {@link #getGraph()} and
|
||||
* {@link #getSemantic()}
|
||||
*
|
||||
|
@ -100,7 +99,7 @@ public class EffectiveEntityGraph implements AppliedGraph, Serializable {
|
|||
* Apply a graph and semantic based on configuration properties or hints
|
||||
* based on {@link GraphSemantic#getJpaHintName()} for {@link GraphSemantic#LOAD} or
|
||||
* {@link GraphSemantic#FETCH}.
|
||||
*
|
||||
* <p>
|
||||
* The semantic is required. The graph
|
||||
* may be null, but that should generally be considered mis-use.
|
||||
*
|
||||
|
@ -114,10 +113,10 @@ public class EffectiveEntityGraph implements AppliedGraph, Serializable {
|
|||
|
||||
RootGraphImplementor<?> fetchHint = (RootGraphImplementor<?>) properties.get( GraphSemantic.FETCH.getJpaHintName() );
|
||||
RootGraphImplementor<?> loadHint = (RootGraphImplementor<?>) properties.get( GraphSemantic.LOAD.getJpaHintName() );
|
||||
if (fetchHint == null) {
|
||||
if ( fetchHint == null ) {
|
||||
fetchHint = (RootGraphImplementor<?>) properties.get( GraphSemantic.FETCH.getJakartaHintName() );
|
||||
}
|
||||
if (loadHint == null) {
|
||||
if ( loadHint == null ) {
|
||||
loadHint = (RootGraphImplementor<?>) properties.get( GraphSemantic.LOAD.getJakartaHintName() );
|
||||
}
|
||||
|
||||
|
|
|
@ -81,28 +81,29 @@ public interface ManagedEntity extends Managed {
|
|||
/**
|
||||
* Used to understand if the tracker can be used to detect dirty properties.
|
||||
*
|
||||
* E.g:
|
||||
* @Entity
|
||||
* class MyEntity{
|
||||
* @Id Integer id
|
||||
* String name
|
||||
* }
|
||||
* <pre>
|
||||
* @Entity
|
||||
* class MyEntity{
|
||||
* @Id Integer id
|
||||
* String name
|
||||
* }
|
||||
*
|
||||
* inSession (
|
||||
* session -> {
|
||||
* MyEntity entity = new MyEntity(1, "Poul");
|
||||
* session.persist(entity);
|
||||
* });
|
||||
* inSession (
|
||||
* session -> {
|
||||
* MyEntity entity = new MyEntity(1, "Poul");
|
||||
* session.persist(entity);
|
||||
* });
|
||||
*
|
||||
*
|
||||
* inSession (
|
||||
* session -> {
|
||||
* MyEntity entity = new MyEntity(1, null);
|
||||
* session.merge(entity);
|
||||
* });
|
||||
*
|
||||
* Because the attribute `name` has been set to null the SelfDirtyTracker does not detect any change and
|
||||
* so doesn't mark the attribute as dirty so the merge does not perform any update.
|
||||
* inSession (
|
||||
* session -> {
|
||||
* MyEntity entity = new MyEntity(1, null);
|
||||
* session.merge(entity);
|
||||
* });
|
||||
* </pre>
|
||||
* Because the attribute `name` has been set to null the SelfDirtyTracker
|
||||
* does not detect any change and so doesn't mark the attribute as dirty
|
||||
* so the merge does not perform any update.
|
||||
*
|
||||
*
|
||||
* @param useTracker true if the tracker can be used to detect dirty properties, false otherwise
|
||||
|
|
|
@ -74,7 +74,7 @@ public class SubselectFetch {
|
|||
|
||||
/**
|
||||
*The entity-keys of all owners loaded from a particular execution
|
||||
*
|
||||
* <p>
|
||||
* Used for "empty collection" handling mostly
|
||||
*/
|
||||
public Set<EntityKey> getResultingEntityKeys() {
|
||||
|
|
|
@ -394,7 +394,7 @@ public class Any extends SimpleValue {
|
|||
@Override
|
||||
public boolean isValid(MappingContext mappingContext) {
|
||||
return columnName != null
|
||||
&& getType().getColumnSpan( mappingContext ) == 1;
|
||||
&& getType().getColumnSpan( mappingContext ) == 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -464,11 +464,5 @@ public class Any extends SimpleValue {
|
|||
|
||||
selectableConsumer.accept( formula );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid(MappingContext mappingContext) throws MappingException {
|
||||
// check
|
||||
return super.isValid( mappingContext );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -85,8 +85,7 @@ public class CheckConstraint {
|
|||
|
||||
@Override
|
||||
public boolean equals(Object object) {
|
||||
if ( object instanceof CheckConstraint ) {
|
||||
CheckConstraint other = (CheckConstraint) object;
|
||||
if ( object instanceof CheckConstraint other ) {
|
||||
return Objects.equals( name, other.name )
|
||||
&& Objects.equals( constraint, other.constraint );
|
||||
}
|
||||
|
|
|
@ -493,14 +493,14 @@ public class Column implements Selectable, Serializable, Cloneable, ColumnTypeIn
|
|||
final Type[] subtypes = ( (ComponentType) type ).getSubtypes();
|
||||
int typeStartIndex = 0;
|
||||
for ( Type subtype : subtypes ) {
|
||||
final int columnSpan = subtype.getColumnSpan(mappingContext);
|
||||
final int columnSpan = subtype.getColumnSpan( mappingContext );
|
||||
if ( typeStartIndex + columnSpan > typeIndex ) {
|
||||
final int subtypeIndex = typeIndex - typeStartIndex;
|
||||
if ( subtype instanceof EntityType ) {
|
||||
return getTypeForEntityValue(mappingContext, subtype, subtypeIndex);
|
||||
return getTypeForEntityValue( mappingContext, subtype, subtypeIndex );
|
||||
}
|
||||
if ( subtype instanceof ComponentType ) {
|
||||
return getTypeForComponentValue(mappingContext, subtype, subtypeIndex);
|
||||
return getTypeForComponentValue( mappingContext, subtype, subtypeIndex );
|
||||
}
|
||||
if ( subtypeIndex == 0 ) {
|
||||
return subtype;
|
||||
|
|
|
@ -77,7 +77,7 @@ public class Index implements Exportable, Serializable {
|
|||
*/
|
||||
@Deprecated(since = "6.3")
|
||||
public java.util.List<Column> getColumns() {
|
||||
return selectables.stream().map( s -> (Column) s ).toList();
|
||||
return selectables.stream().map( selectable -> (Column) selectable ).toList();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -325,8 +325,7 @@ public class RootClass extends PersistentClass implements TableOwner, SoftDeleta
|
|||
* <em>correct</em>) we simply log a warning.
|
||||
*/
|
||||
private void checkCompositeIdentifier() {
|
||||
if ( getIdentifier() instanceof Component ) {
|
||||
final Component id = (Component) getIdentifier();
|
||||
if ( getIdentifier() instanceof Component id ) {
|
||||
if ( !id.isDynamic() ) {
|
||||
final Class<?> idClass = id.getComponentClass();
|
||||
if ( idClass != null ) {
|
||||
|
|
|
@ -89,8 +89,7 @@ public class Set extends Collection {
|
|||
pk = new PrimaryKey( getCollectionTable() );
|
||||
pk.addColumns( getKey() );
|
||||
for ( Selectable selectable : getElement().getSelectables() ) {
|
||||
if ( selectable instanceof Column ) {
|
||||
Column col = (Column) selectable;
|
||||
if ( selectable instanceof Column col ) {
|
||||
if ( !col.isNullable() ) {
|
||||
pk.addColumn( col );
|
||||
}
|
||||
|
|
|
@ -12,7 +12,6 @@ import org.hibernate.boot.spi.MetadataBuildingContext;
|
|||
import org.hibernate.engine.OptimisticLockStyle;
|
||||
import org.hibernate.internal.FilterConfiguration;
|
||||
import org.hibernate.internal.util.collections.JoinedList;
|
||||
import org.hibernate.persister.entity.EntityPersister;
|
||||
|
||||
/**
|
||||
* A mapping model object that represents a subclass in an entity class
|
||||
|
@ -23,7 +22,6 @@ import org.hibernate.persister.entity.EntityPersister;
|
|||
public class Subclass extends PersistentClass {
|
||||
|
||||
private PersistentClass superclass;
|
||||
private Class<? extends EntityPersister> classPersisterClass;
|
||||
private final int subclassId;
|
||||
|
||||
public Subclass(PersistentClass superclass, MetadataBuildingContext buildingContext) {
|
||||
|
|
|
@ -102,11 +102,6 @@ public abstract class ToOne extends SimpleValue implements Fetchable, SortableVa
|
|||
return referencedEntityName!=null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object accept(ValueVisitor visitor) {
|
||||
return visitor.accept(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSame(SimpleValue other) {
|
||||
return other instanceof ToOne && isSame( (ToOne) other );
|
||||
|
@ -120,7 +115,7 @@ public abstract class ToOne extends SimpleValue implements Fetchable, SortableVa
|
|||
|
||||
@Override
|
||||
public boolean isValid(MappingContext mappingContext) throws MappingException {
|
||||
if (referencedEntityName==null) {
|
||||
if ( referencedEntityName==null ) {
|
||||
throw new MappingException("association must specify the referenced entity");
|
||||
}
|
||||
return super.isValid( mappingContext );
|
||||
|
|
|
@ -87,15 +87,13 @@ public interface Value extends Serializable {
|
|||
}
|
||||
|
||||
private JdbcMapping getType(MappingContext factory, Type elementType, int index) {
|
||||
if ( elementType instanceof CompositeType ) {
|
||||
final Type[] subtypes = ( (CompositeType) elementType ).getSubtypes();
|
||||
if ( elementType instanceof CompositeType compositeType ) {
|
||||
final Type[] subtypes = compositeType.getSubtypes();
|
||||
for ( int i = 0; i < subtypes.length; i++ ) {
|
||||
final Type subtype = subtypes[i];
|
||||
final int columnSpan;
|
||||
if ( subtype instanceof EntityType ) {
|
||||
final EntityType entityType = (EntityType) subtype;
|
||||
final Type idType = getIdType( entityType );
|
||||
columnSpan = idType.getColumnSpan( factory );
|
||||
if ( subtype instanceof EntityType entityType ) {
|
||||
columnSpan = getIdType( entityType ).getColumnSpan( factory );
|
||||
}
|
||||
else {
|
||||
columnSpan = subtype.getColumnSpan( factory );
|
||||
|
@ -110,13 +108,11 @@ public interface Value extends Serializable {
|
|||
// Should never happen
|
||||
throw new IllegalStateException( "Type index is past the types column span!" );
|
||||
}
|
||||
else if ( elementType instanceof EntityType ) {
|
||||
final EntityType entityType = (EntityType) elementType;
|
||||
final Type idType = getIdType( entityType );
|
||||
return getType( factory, idType, index );
|
||||
else if ( elementType instanceof EntityType entityType ) {
|
||||
return getType( factory, getIdType( entityType ), index );
|
||||
}
|
||||
else if ( elementType instanceof MetaType ) {
|
||||
return (JdbcMapping) ( (MetaType) elementType ).getBaseType();
|
||||
else if ( elementType instanceof MetaType metaType ) {
|
||||
return (JdbcMapping) metaType.getBaseType();
|
||||
}
|
||||
return (JdbcMapping) elementType;
|
||||
}
|
||||
|
|
|
@ -49,7 +49,7 @@ public abstract class AbstractStandardBasicType<T>
|
|||
private final ValueExtractor<T> jdbcValueExtractor;
|
||||
private final JdbcLiteralFormatter<T> jdbcLiteralFormatter;
|
||||
private final @Nullable Type typeForEqualsHashCode;
|
||||
private final Class javaTypeClass;
|
||||
private final Class<?> javaTypeClass;
|
||||
private final MutabilityPlan<T> mutabilityPlan;
|
||||
private final Comparator<T> javatypeComparator;
|
||||
|
||||
|
@ -124,7 +124,7 @@ public abstract class AbstractStandardBasicType<T>
|
|||
}
|
||||
|
||||
@Override
|
||||
public final Class getReturnedClass() {
|
||||
public final Class<?> getReturnedClass() {
|
||||
return javaTypeClass;
|
||||
}
|
||||
|
||||
|
|
|
@ -514,13 +514,10 @@ public abstract class CollectionType extends AbstractType implements Association
|
|||
// One thing to be careful of here is a "bare" original collection
|
||||
// in which case we should never ever ever reset the dirty flag
|
||||
// on the target because we simply do not know...
|
||||
if ( original instanceof PersistentCollection && result instanceof PersistentCollection ) {
|
||||
final PersistentCollection<?> originalPersistentCollection = (PersistentCollection<?>) original;
|
||||
final PersistentCollection<?> resultPersistentCollection = (PersistentCollection<?>) result;
|
||||
|
||||
if ( original instanceof PersistentCollection<?> originalPersistentCollection
|
||||
&& result instanceof PersistentCollection<?> resultPersistentCollection) {
|
||||
preserveSnapshot( originalPersistentCollection, resultPersistentCollection, elemType, owner, copyCache, session );
|
||||
|
||||
if ( ! originalPersistentCollection.isDirty() ) {
|
||||
if ( !originalPersistentCollection.isDirty() ) {
|
||||
resultPersistentCollection.clearDirty();
|
||||
}
|
||||
}
|
||||
|
@ -582,10 +579,9 @@ public abstract class CollectionType extends AbstractType implements Association
|
|||
}
|
||||
|
||||
}
|
||||
else if ( originalSnapshot instanceof Object[] ) {
|
||||
Object[] arr = (Object[]) originalSnapshot;
|
||||
for ( int i = 0; i < arr.length; i++ ) {
|
||||
arr[i] = elemType.replace( arr[i], null, session, owner, copyCache );
|
||||
else if ( originalSnapshot instanceof Object[] array ) {
|
||||
for ( int i = 0; i < array.length; i++ ) {
|
||||
array[i] = elemType.replace( array[i], null, session, owner, copyCache );
|
||||
}
|
||||
targetSnapshot = originalSnapshot;
|
||||
|
||||
|
|
|
@ -668,8 +668,8 @@ public abstract class EntityType extends AbstractType implements AssociationType
|
|||
}
|
||||
else {
|
||||
final Type type = mappingContext.getReferencedPropertyType( getAssociatedEntityName(), uniqueKeyPropertyName );
|
||||
if ( type instanceof EntityType ) {
|
||||
return ( (EntityType) type ).getIdentifierOrUniqueKeyType( mappingContext );
|
||||
if ( type instanceof EntityType entityType ) {
|
||||
return entityType.getIdentifierOrUniqueKeyType( mappingContext );
|
||||
}
|
||||
else {
|
||||
return type;
|
||||
|
|
|
@ -146,7 +146,7 @@ public class ConvertedBasicTypeImpl<J> implements ConvertedBasicType<J>,
|
|||
}
|
||||
|
||||
@Override
|
||||
public final Class getReturnedClass() {
|
||||
public final Class<?> getReturnedClass() {
|
||||
return converter.getDomainJavaType().getJavaTypeClass();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue