Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public class DefaultCacheKeysFactory implements CacheKeysFactory {

public static Object staticCreateCollectionKey(Object id, CollectionPersister persister, SessionFactoryImplementor factory, String tenantIdentifier) {
final Type keyType = persister.getKeyType();
final var coercedId = getCoercedId( id, factory, keyType );
final var coercedId = getCoercedId( id, keyType );
final var disassembledKey = keyType.disassemble( coercedId, factory );
final boolean idIsArray = disassembledKey.getClass().isArray();
final String role = persister.getRole();
Expand All @@ -56,7 +56,7 @@ public static Object staticCreateCollectionKey(Object id, CollectionPersister pe

public static Object staticCreateEntityKey(Object id, EntityPersister persister, SessionFactoryImplementor factory, String tenantIdentifier) {
final Type keyType = persister.getIdentifierType();
final var coercedId = getCoercedId( id, factory, keyType );
final var coercedId = getCoercedId( id, keyType );
final var disassembledKey = keyType.disassemble( coercedId, factory );
final boolean idIsArray = disassembledKey.getClass().isArray();
final String rootEntityName = persister.getRootEntityName();
Expand All @@ -65,9 +65,9 @@ public static Object staticCreateEntityKey(Object id, EntityPersister persister,
: new CacheKeyImplementation( coercedId, disassembledKey, keyType, rootEntityName, tenantIdentifier );
}

private static Object getCoercedId(Object id, SessionFactoryImplementor factory, Type keyType) {
private static Object getCoercedId(Object id, Type keyType) {
return keyType instanceof BasicType<?> basicType
? basicType.getJavaTypeDescriptor().coerce( id, factory::getTypeConfiguration )
? basicType.getJavaTypeDescriptor().coerce( id )
: id;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,11 +227,9 @@ public boolean containsEntity(String entityName, Object identifier) {
final var persister = getEntityDescriptor( entityName );
final var cacheAccess = persister.getCacheAccessStrategy();
if ( cacheAccess != null ) {
final Object idValue =
persister.getIdentifierMapping().getJavaType()
.coerce( identifier, sessionFactory::getTypeConfiguration );
final Object key = cacheAccess.generateCacheKey(
idValue,
persister.getIdentifierMapping().getJavaType()
.coerce( identifier ),
persister.getRootEntityDescriptor().getEntityPersister(),
sessionFactory,
null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ private List<T> orderedMultiLoad(
final var lockOptions = lockOptions( loadOptions );

for ( int i = 0; i < ids.length; i++ ) {
final Object id = coerce( session, idType, ids[i] );
final Object id = coerce( idType, ids[i] );
final var entityKey = new EntityKey( id, getLoadable().getEntityPersister() );
if ( !loadFromEnabledCaches( loadOptions, session, id, lockOptions, entityKey, results, i ) ) {
// if we did not hit any of the continues above,
Expand Down Expand Up @@ -160,8 +160,8 @@ private List<T> orderedMultiLoad(
return (List<T>) results;
}

private Object coerce(SharedSessionContractImplementor session, JavaType<?> idType, Object id) {
return idCoercionEnabled ? idType.coerce( id, session ) : id;
private Object coerce(JavaType<?> idType, Object id) {
return idCoercionEnabled ? idType.coerce( id ) : id;
}

private static LockOptions lockOptions(MultiIdLoadOptions loadOptions) {
Expand Down Expand Up @@ -342,7 +342,7 @@ private <R> List<Object> unresolvedIds(
final var idType = getLoadable().getIdentifierMapping().getJavaType();
List<Object> unresolvedIds = null;
for ( int i = 0; i < ids.length; i++ ) {
final Object id = coerce( session, idType, ids[i] );
final Object id = coerce( idType, ids[i] );
unresolvedIds =
loadFromCaches(
loadOptions,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ public static <K> K[] normalizeKeys(
}
else {
for ( int i = 0; i < keys.length; i++ ) {
typedArray[i] = keyJavaType.coerce( keys[i], session );
typedArray[i] = keyJavaType.cast( keyJavaType.coerce( keys[i] ) );
}
}
return typedArray;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@
import org.hibernate.graph.GraphSemantic;
import org.hibernate.graph.spi.RootGraphImplementor;
import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.type.descriptor.java.JavaType;
import org.hibernate.type.spi.TypeConfiguration;

import static org.hibernate.proxy.HibernateProxy.extractLazyInitializer;

Expand All @@ -37,7 +35,7 @@
* @author Steve Ebersole
*/
// Hibernate Reactive extends this class: see ReactiveIdentifierLoadAccessImpl
public class IdentifierLoadAccessImpl<T> implements IdentifierLoadAccess<T>, JavaType.CoercionContext {
public class IdentifierLoadAccessImpl<T> implements IdentifierLoadAccess<T> {
private final LoadAccessContext context;
private final EntityPersister entityPersister;

Expand Down Expand Up @@ -199,7 +197,7 @@ protected Object coerceId(Object id, SessionFactoryImplementor factory) {
final var identifierMapping = entityPersister.getIdentifierMapping();
return identifierMapping.isVirtual()
? id // special case for a class with an @IdClass
: identifierMapping.getJavaType().coerce( id, this );
: identifierMapping.getJavaType().coerce( id );
}
catch ( Exception e ) {
throw new IllegalArgumentException( "Argument '" + id
Expand Down Expand Up @@ -233,11 +231,6 @@ private static boolean isLoadByIdComplianceEnabled(SessionFactoryImplementor fac
return factory.getSessionFactoryOptions().getJpaCompliance().isLoadByIdComplianceEnabled();
}

@Override
public TypeConfiguration getTypeConfiguration() {
return context.getSession().getSessionFactory().getTypeConfiguration();
}

@Override
public IdentifierLoadAccess<T> enableFetchProfile(String profileName) {
if ( !context.getSession().getFactory().containsFetchProfileDefinition( profileName ) ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,16 @@
import org.hibernate.sql.results.graph.DomainResult;
import org.hibernate.sql.results.graph.DomainResultCreationState;
import org.hibernate.type.descriptor.java.JavaType;
import org.hibernate.type.spi.TypeConfiguration;

import static org.hibernate.loader.ast.internal.MultiKeyLoadHelper.supportsSqlArrayType;

/**
* Single-attribute NaturalIdMapping implementation
*/
public class SimpleNaturalIdMapping extends AbstractNaturalIdMapping
implements JavaType.CoercionContext, BasicValuedMapping {
implements BasicValuedMapping {
private final SingularAttributeMapping attribute;
private final SessionFactoryImplementor sessionFactory;
private final TypeConfiguration typeConfiguration;

public SimpleNaturalIdMapping(
SingularAttributeMapping attribute,
Expand All @@ -54,7 +52,6 @@ public SimpleNaturalIdMapping(
super( declaringType, attribute.getAttributeMetadata().isUpdatable() );
this.attribute = attribute;
this.sessionFactory = creationProcess.getCreationContext().getSessionFactory();
this.typeConfiguration = creationProcess.getCreationContext().getTypeConfiguration();
}

public SingularAttributeMapping getAttribute() {
Expand Down Expand Up @@ -143,7 +140,7 @@ public Object normalizeInput(Object incoming) {
final Object normalizedValue = normalizedValue( incoming );
return isLoadByIdComplianceEnabled()
? normalizedValue
: getJavaType().coerce( normalizedValue, this );
: getJavaType().coerce( normalizedValue );
}

private Object normalizedValue(Object incoming) {
Expand Down Expand Up @@ -295,11 +292,6 @@ private Dialect getDialect() {
return sessionFactory.getJdbcServices().getDialect();
}

@Override
public TypeConfiguration getTypeConfiguration() {
return typeConfiguration;
}

@Override
public AttributeMapping asAttributeMapping() {
return getAttribute();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ protected AnyDiscriminatorSqmPath(

@Override
public AnyDiscriminatorSqmPath<T> copy(SqmCopyContext context) {
final AnyDiscriminatorSqmPath<T> existing = context.getCopy( this );
final var existing = context.getCopy( this );
if ( existing != null ) {
return existing;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public EmbeddableDomainType<T> getEmbeddableDomainType() {

@Override
public EmbeddedDiscriminatorSqmPath<T> copy(SqmCopyContext context) {
final EmbeddedDiscriminatorSqmPath<T> existing = context.getCopy( this );
final var existing = context.getCopy( this );
if ( existing != null ) {
return existing;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public EntityMappingType getEntityDescriptor() {

@Override
public EntityDiscriminatorSqmPath copy(SqmCopyContext context) {
final EntityDiscriminatorSqmPath existing = context.getCopy( this );
final var existing = context.getCopy( this );
if ( existing != null ) {
return existing;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,7 @@ private SemanticPathPart resolvePath(String identifier, boolean isTerminal, SqmC
if ( pathRootByExposedNavigable != null ) {
// identifier is an "unqualified attribute reference"
validateAsRoot( pathRootByExposedNavigable );
final SqmPath<?> sqmPath =
pathRootByExposedNavigable.get( identifier, true );
final var sqmPath = pathRootByExposedNavigable.get( identifier, true );
return isTerminal ? sqmPath : new DomainPathPart( sqmPath );
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import org.hibernate.query.hql.spi.SemanticPathPart;
import org.hibernate.query.hql.spi.SqmCreationProcessingState;
import org.hibernate.query.hql.spi.SqmCreationState;
import org.hibernate.query.hql.spi.SqmPathRegistry;
import org.hibernate.query.sqm.SqmJoinable;
import org.hibernate.query.sqm.SqmPathSource;
import org.hibernate.query.sqm.spi.SqmCreationHelper;
Expand Down Expand Up @@ -124,7 +123,7 @@ public void consumeTreat(String entityName, boolean isTerminal) {

private ConsumerDelegate resolveBase(String identifier, boolean isTerminal) {
final SqmCreationProcessingState processingState = creationState.getCurrentProcessingState();
final SqmPathRegistry pathRegistry = processingState.getPathRegistry();
final var pathRegistry = processingState.getPathRegistry();
final SqmFrom<?, Object> pathRootByAlias = pathRegistry.findFromByAlias( identifier, true );
if ( pathRootByAlias != null ) {
return resolveAlias( identifier, isTerminal, pathRootByAlias );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ private static <S extends SqmStatement<?>> S copyStatement(
final SqmCopyContext context = SqmCopyContext.noParamCopyContext();
// Copy the statement replacing the root's unmapped polymorphic reference with
// the concrete mapped descriptor entity domain type.
final SqmRoot<?> path = context.registerCopy(
final var path = context.registerCopy(
unmappedPolymorphicReference,
new SqmRoot<>(
mappedDescriptor,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
*
* @author Steve Ebersole
*/
public class QueryParameterBindingImpl<T> implements QueryParameterBinding<T>, JavaType.CoercionContext {
public class QueryParameterBindingImpl<T> implements QueryParameterBinding<T> {
private final QueryParameter<T> queryParameter;
private final SessionFactoryImplementor sessionFactory;

Expand Down Expand Up @@ -296,7 +296,6 @@ private void validate(Object value, TemporalType clarifiedTemporalType) {
QueryParameterBindingValidator.INSTANCE.validate( getBindType(), value, clarifiedTemporalType, getCriteriaBuilder() );
}

@Override
public TypeConfiguration getTypeConfiguration() {
return sessionFactory.getTypeConfiguration();
}
Expand Down Expand Up @@ -337,7 +336,7 @@ private Object coerce(T value, BindableType<? super T> parameterType) {
}
else {
return getCriteriaBuilder().resolveExpressible( parameterType )
.getExpressibleJavaType().coerce( value, this );
.getExpressibleJavaType().coerce( value );
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public SelfRenderingSqmAggregateFunction(

@Override
public SelfRenderingSqmAggregateFunction<T> copy(SqmCopyContext context) {
final SelfRenderingSqmAggregateFunction<T> existing = context.getCopy( this );
final var existing = context.getCopy( this );
if ( existing != null ) {
return existing;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public SelfRenderingSqmFunction(

@Override
public SelfRenderingSqmFunction<T> copy(SqmCopyContext context) {
final SelfRenderingSqmFunction<T> existing = context.getCopy( this );
final var existing = context.getCopy( this );
if ( existing != null ) {
return existing;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public SelfRenderingSqmOrderedSetAggregateFunction(

@Override
public SelfRenderingSqmOrderedSetAggregateFunction<T> copy(SqmCopyContext context) {
final SelfRenderingSqmOrderedSetAggregateFunction<T> existing = context.getCopy( this );
final var existing = context.getCopy( this );
if ( existing != null ) {
return existing;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public SelfRenderingSqmSetReturningFunction(

@Override
public SelfRenderingSqmSetReturningFunction<T> copy(SqmCopyContext context) {
final SelfRenderingSqmSetReturningFunction<T> existing = context.getCopy( this );
final var existing = context.getCopy( this );
if ( existing != null ) {
return existing;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public SelfRenderingSqmWindowFunction(

@Override
public SelfRenderingSqmWindowFunction<T> copy(SqmCopyContext context) {
final SelfRenderingSqmWindowFunction<T> existing = context.getCopy( this );
final var existing = context.getCopy( this );
if ( existing != null ) {
return existing;
}
Expand Down
Loading
Loading