deal with some warnings
This commit is contained in:
parent
9f59f93b6e
commit
8205506104
|
@ -33,7 +33,6 @@ import org.hibernate.boot.spi.InFlightMetadataCollector;
|
|||
import org.hibernate.boot.spi.MetadataBuildingContext;
|
||||
import org.hibernate.boot.spi.PropertyData;
|
||||
import org.hibernate.internal.log.DeprecationLogger;
|
||||
import org.hibernate.internal.util.StringHelper;
|
||||
import org.hibernate.internal.util.collections.ArrayHelper;
|
||||
import org.hibernate.mapping.Any;
|
||||
import org.hibernate.mapping.AttributeContainer;
|
||||
|
@ -882,9 +881,10 @@ public class BinderHelper {
|
|||
final ClassDetailsRegistry classDetailsRegistry = buildingContext.getMetadataCollector()
|
||||
.getSourceModelBuildingContext()
|
||||
.getClassDetailsRegistry();
|
||||
final String name = StringHelper.isEmpty( propertyHolder.getPersistentClass().getClassName() )
|
||||
? propertyHolder.getPersistentClass().getEntityName()
|
||||
: propertyHolder.getPersistentClass().getClassName();
|
||||
final PersistentClass persistentClass = propertyHolder.getPersistentClass();
|
||||
final String name = isEmpty( persistentClass.getClassName() )
|
||||
? persistentClass.getEntityName()
|
||||
: persistentClass.getClassName();
|
||||
final ClassDetails classDetails = classDetailsRegistry.resolveClassDetails( name );
|
||||
final InFlightMetadataCollector metadataCollector = buildingContext.getMetadataCollector();
|
||||
if ( propertyHolder.isInIdClass() ) {
|
||||
|
|
|
@ -242,9 +242,7 @@ public class Component extends SimpleValue implements MetaAttributable, Sortable
|
|||
|
||||
private void collectAggregatedColumns(List<Column> aggregatedColumns, Component component) {
|
||||
for ( Property property : component.getProperties() ) {
|
||||
final Value value = property.getValue();
|
||||
if ( value instanceof Component ) {
|
||||
final Component subComponent = (Component) value;
|
||||
if ( property.getValue() instanceof Component subComponent ) {
|
||||
final AggregateColumn subAggregate = subComponent.getAggregateColumn();
|
||||
if ( subAggregate != null ) {
|
||||
aggregatedColumns.add( subAggregate );
|
||||
|
@ -254,7 +252,7 @@ public class Component extends SimpleValue implements MetaAttributable, Sortable
|
|||
}
|
||||
}
|
||||
else {
|
||||
aggregatedColumns.addAll( value.getColumns() );
|
||||
aggregatedColumns.addAll( property.getValue().getColumns() );
|
||||
}
|
||||
}
|
||||
if ( component.isPolymorphic() ) {
|
||||
|
@ -267,17 +265,16 @@ public class Component extends SimpleValue implements MetaAttributable, Sortable
|
|||
// Let the BasicValue of every sub-column know about the aggregate,
|
||||
// which is needed in type resolution
|
||||
final Value value = property.getValue();
|
||||
if ( value instanceof BasicValue ) {
|
||||
assert ( (BasicValue) value ).getResolution() == null;
|
||||
( (BasicValue) value ).setAggregateColumn( aggregateColumn );
|
||||
if ( value instanceof BasicValue basicValue ) {
|
||||
assert basicValue.getResolution() == null;
|
||||
basicValue.setAggregateColumn( aggregateColumn );
|
||||
}
|
||||
else if ( value instanceof Component ) {
|
||||
final Component subComponent = (Component) value;
|
||||
else if ( value instanceof Component subComponent ) {
|
||||
if ( subComponent.getAggregateColumn() == null ) {
|
||||
subComponent.notifyPropertiesAboutAggregateColumn( aggregateColumn, subComponent );
|
||||
}
|
||||
else {
|
||||
( (Component) value ).setParentAggregateColumn( aggregateColumn );
|
||||
subComponent.setParentAggregateColumn( aggregateColumn );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,7 +30,6 @@ import org.hibernate.sql.exec.spi.JdbcParameterBindings;
|
|||
import org.hibernate.sql.exec.spi.JdbcParametersList;
|
||||
import org.hibernate.sql.results.internal.RowTransformerArrayImpl;
|
||||
|
||||
import static org.hibernate.internal.util.NullnessUtil.castNonNull;
|
||||
import static org.hibernate.sql.results.spi.ListResultsConsumer.UniqueSemantic.FILTER;
|
||||
|
||||
/**
|
||||
|
|
|
@ -119,10 +119,10 @@ public class InsertCoordinatorStandard extends AbstractMutationCoordinator imple
|
|||
SharedSessionContractImplementor session) {
|
||||
// apply any pre-insert in-memory value generation
|
||||
final boolean needsDynamicInsert = preInsertInMemoryValueGeneration( values, entity, session );
|
||||
|
||||
final EntityMetamodel entityMetamodel = entityPersister().getEntityMetamodel();
|
||||
final boolean forceIdentifierBinding = entityPersister().getGenerator().generatedOnExecution() && id != null;
|
||||
if ( entityMetamodel.isDynamicInsert() || needsDynamicInsert || forceIdentifierBinding ) {
|
||||
final EntityPersister persister = entityPersister();
|
||||
final boolean forceIdentifierBinding = persister.getGenerator().generatedOnExecution() && id != null;
|
||||
if ( persister.getEntityMetamodel().isDynamicInsert()
|
||||
|| needsDynamicInsert || forceIdentifierBinding ) {
|
||||
return doDynamicInserts( id, values, entity, session, forceIdentifierBinding );
|
||||
}
|
||||
else {
|
||||
|
@ -430,7 +430,7 @@ public class InsertCoordinatorStandard extends AbstractMutationCoordinator imple
|
|||
if ( tableMapping.isIdentifierTable() && entityPersister().isIdentifierAssignedByInsert() && !forceIdentifierBinding ) {
|
||||
assert entityPersister().getInsertDelegate() != null;
|
||||
final OnExecutionGenerator generator = (OnExecutionGenerator) entityPersister().getGenerator();
|
||||
if ( generator.referenceColumnsInSql( dialect() ) ) {
|
||||
if ( generator.referenceColumnsInSql( dialect ) ) {
|
||||
final BasicEntityIdentifierMapping identifierMapping = (BasicEntityIdentifierMapping) entityPersister().getIdentifierMapping();
|
||||
final String[] columnValues = generator.getReferencedColumnValues( dialect );
|
||||
tableMapping.getKeyMapping().forEachKeyColumn( (i, column) -> tableInsertBuilder.addKeyColumn(
|
||||
|
|
|
@ -9,7 +9,6 @@ import java.util.List;
|
|||
import java.util.Locale;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import org.hibernate.AssertionFailure;
|
||||
import org.hibernate.HibernateException;
|
||||
import org.hibernate.Internal;
|
||||
import org.hibernate.StaleObjectStateException;
|
||||
|
@ -198,7 +197,6 @@ public class UpdateCoordinatorStandard extends AbstractMutationCoordinator imple
|
|||
|
||||
final boolean[] attributeUpdateability;
|
||||
boolean forceDynamicUpdate;
|
||||
|
||||
if ( entityPersister().getEntityMetamodel().isDynamicUpdate() && dirtyAttributeIndexes != null ) {
|
||||
attributeUpdateability = getPropertiesToUpdate( dirtyAttributeIndexes, hasDirtyCollection );
|
||||
forceDynamicUpdate = true;
|
||||
|
@ -372,21 +370,15 @@ public class UpdateCoordinatorStandard extends AbstractMutationCoordinator imple
|
|||
int position,
|
||||
SingularAttributeMapping attribute,
|
||||
EntityPersister persister) {
|
||||
switch ( persister.optimisticLockStyle() ) {
|
||||
case NONE:
|
||||
return false;
|
||||
case VERSION:
|
||||
return versionMapping != null
|
||||
return switch ( persister.optimisticLockStyle() ) {
|
||||
case NONE -> false;
|
||||
case VERSION -> versionMapping != null
|
||||
&& versionMapping.getVersionAttribute() == attribute;
|
||||
// && updateableAttributeIndexes[position];
|
||||
case ALL:
|
||||
return attribute.getAttributeMetadata().isIncludedInOptimisticLocking();
|
||||
case DIRTY:
|
||||
return attribute.getAttributeMetadata().isIncludedInOptimisticLocking()
|
||||
case ALL -> attribute.getAttributeMetadata().isIncludedInOptimisticLocking();
|
||||
case DIRTY -> attribute.getAttributeMetadata().isIncludedInOptimisticLocking()
|
||||
&& dirtinessChecker.include( position, attribute );
|
||||
default:
|
||||
throw new AssertionFailure( "unknown OptimisticLockStyle" );
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
protected Supplier<GeneratedValues> handlePotentialImplicitForcedVersionIncrement(
|
||||
|
@ -1226,9 +1218,7 @@ public class UpdateCoordinatorStandard extends AbstractMutationCoordinator imple
|
|||
TableUpdateBuilder<?> tableUpdateBuilder,
|
||||
SharedSessionContractImplementor session) {
|
||||
final Generator generator = attributeMapping.getGenerator();
|
||||
if ( isValueGenerated( generator )
|
||||
&& ( session == null && generator.generatedOnExecution() || generator.generatedOnExecution( entity, session ) )
|
||||
&& isValueGenerationInSql( generator, dialect ) ) {
|
||||
if ( needsValueGeneration( entity, session, generator ) ) {
|
||||
handleValueGeneration( attributeMapping, updateGroupBuilder, (OnExecutionGenerator) generator );
|
||||
}
|
||||
else if ( versionMapping != null
|
||||
|
@ -1245,6 +1235,12 @@ public class UpdateCoordinatorStandard extends AbstractMutationCoordinator imple
|
|||
}
|
||||
}
|
||||
|
||||
private boolean needsValueGeneration(Object entity, SharedSessionContractImplementor session, Generator generator) {
|
||||
return isValueGenerated( generator )
|
||||
&& (session == null && generator.generatedOnExecution() || generator.generatedOnExecution( entity, session ) )
|
||||
&& isValueGenerationInSql( generator, dialect );
|
||||
}
|
||||
|
||||
/**
|
||||
* Contains the aggregated analysis of the update values to determine
|
||||
* what SQL UPDATE statement(s) should be used to update the entity
|
||||
|
@ -1606,18 +1602,18 @@ public class UpdateCoordinatorStandard extends AbstractMutationCoordinator imple
|
|||
null,
|
||||
null,
|
||||
null,
|
||||
(index,attribute) -> isValueGenerated( attribute.getGenerator() ) && isValueGenerationInSql( attribute.getGenerator(), dialect() )
|
||||
(index,attribute) ->
|
||||
isValueGenerated( attribute.getGenerator() )
|
||||
&& isValueGenerationInSql( attribute.getGenerator(), dialect() )
|
||||
|| entityPersister().getPropertyUpdateability()[index],
|
||||
(index,attribute) -> {
|
||||
(index,attribute) ->
|
||||
switch ( entityPersister().optimisticLockStyle() ) {
|
||||
case ALL:
|
||||
return true;
|
||||
case VERSION:
|
||||
case ALL -> true;
|
||||
case VERSION -> {
|
||||
final EntityVersionMapping versionMapping = entityPersister().getVersionMapping();
|
||||
return versionMapping != null && attribute == versionMapping.getVersionAttribute();
|
||||
default:
|
||||
return false;
|
||||
yield versionMapping != null && attribute == versionMapping.getVersionAttribute();
|
||||
}
|
||||
default -> false;
|
||||
},
|
||||
(index,attribute) -> true,
|
||||
"", // pass anything here to generate the row id restriction if possible
|
||||
|
|
|
@ -402,7 +402,6 @@ import org.hibernate.sql.results.graph.Fetch;
|
|||
import org.hibernate.sql.results.graph.FetchParent;
|
||||
import org.hibernate.sql.results.graph.Fetchable;
|
||||
import org.hibernate.sql.results.graph.FetchableContainer;
|
||||
import org.hibernate.sql.results.graph.collection.internal.EagerCollectionFetch;
|
||||
import org.hibernate.sql.results.graph.entity.EntityResultGraphNode;
|
||||
import org.hibernate.sql.results.graph.instantiation.internal.DynamicInstantiation;
|
||||
import org.hibernate.sql.results.graph.internal.ImmutableFetchList;
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
* SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
* Copyright Red Hat Inc. and Hibernate Authors
|
||||
*/
|
||||
package org.hibernate.type;
|
||||
|
||||
|
|
|
@ -63,15 +63,15 @@ public class NativeGenerator
|
|||
|
||||
@Override
|
||||
public void registerExportables(Database database) {
|
||||
if ( generator instanceof ExportableProducer ) {
|
||||
((ExportableProducer) generator).registerExportables(database);
|
||||
if ( generator instanceof ExportableProducer exportableProducer ) {
|
||||
exportableProducer.registerExportables(database);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialize(SqlStringGenerationContext context) {
|
||||
if ( generator instanceof Configurable ) {
|
||||
((Configurable) generator).initialize(context);
|
||||
if ( generator instanceof Configurable configurable ) {
|
||||
configurable.initialize(context);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue