HHH-18551 Fix memory leak caused by creation of new BasicTypeImpl

This commit is contained in:
Piotr Wolny 2024-09-02 15:02:13 +02:00 committed by Christian Beikov
parent e55bdbcc94
commit 2d6303db3b
4 changed files with 8 additions and 8 deletions

View File

@ -1334,7 +1334,7 @@ public class SqmCriteriaNodeBuilder implements NodeBuilder, SqmCreationContext,
final EnumJavaType javaType = new EnumJavaType<>( type );
final JdbcType jdbcType =
javaType.getRecommendedJdbcType( typeConfiguration.getCurrentBaseSqlTypeIndicators() );
return new BasicTypeImpl<>( javaType, jdbcType );
return typeConfiguration.getBasicTypeRegistry().resolve( javaType, jdbcType );
}
else {
return result;

View File

@ -18,7 +18,6 @@ import org.hibernate.metamodel.mapping.JdbcMapping;
import org.hibernate.metamodel.mapping.MappingModelExpressible;
import org.hibernate.metamodel.mapping.MappingType;
import org.hibernate.metamodel.mapping.SqlExpressible;
import org.hibernate.metamodel.model.domain.internal.BasicTypeImpl;
import org.hibernate.query.BindableType;
import org.hibernate.sql.ast.SqlAstWalker;
import org.hibernate.sql.ast.tree.expression.JdbcParameter;
@ -27,6 +26,7 @@ import org.hibernate.sql.exec.spi.ExecutionContext;
import org.hibernate.sql.exec.spi.JdbcParameterBinder;
import org.hibernate.sql.exec.spi.JdbcParameterBinding;
import org.hibernate.sql.exec.spi.JdbcParameterBindings;
import org.hibernate.type.BasicType;
import org.hibernate.type.descriptor.java.EnumJavaType;
import org.hibernate.type.descriptor.jdbc.JdbcType;
import org.hibernate.type.descriptor.jdbc.JdbcTypeIndicators;
@ -135,7 +135,7 @@ public abstract class AbstractJdbcParameter
}
}
private static <E extends Enum<E>> BasicTypeImpl<E> createEnumType(ExecutionContext executionContext, Class<E> enumClass) {
private static <E extends Enum<E>> BasicType<E> createEnumType(ExecutionContext executionContext, Class<E> enumClass) {
final EnumJavaType<E> enumJavaType = new EnumJavaType<>( enumClass );
final JdbcTypeIndicators indicators =
executionContext.getSession().getTypeConfiguration().getCurrentBaseSqlTypeIndicators();
@ -144,7 +144,7 @@ public abstract class AbstractJdbcParameter
// so just accept the default from the TypeConfiguration, which
// is usually ORDINAL (the default according to JPA)
enumJavaType.getRecommendedJdbcType(indicators);
return new BasicTypeImpl<>( enumJavaType, jdbcType );
return indicators.getTypeConfiguration().getBasicTypeRegistry().resolve( enumJavaType, jdbcType );
}
@Override

View File

@ -20,7 +20,6 @@ import org.hibernate.type.descriptor.converter.spi.BasicValueConverter;
import org.hibernate.type.descriptor.java.spi.UnknownBasicJavaType;
import org.hibernate.type.descriptor.jdbc.JdbcType;
import org.hibernate.type.descriptor.jdbc.JdbcTypeIndicators;
import org.hibernate.type.internal.BasicTypeImpl;
import org.hibernate.type.spi.TypeConfiguration;
public abstract class AbstractArrayJavaType<T, E> extends AbstractClassJavaType<T>
@ -49,7 +48,8 @@ public abstract class AbstractArrayJavaType<T, E> extends AbstractClassJavaType<
// Always determine the recommended type to make sure this is a valid basic java type
return indicators.getTypeConfiguration().getJdbcTypeRegistry().resolveTypeConstructorDescriptor(
indicators.getPreferredSqlTypeCodeForArray(),
new BasicTypeImpl<>( componentJavaType, componentJavaType.getRecommendedJdbcType( indicators ) ),
indicators.getTypeConfiguration().getBasicTypeRegistry().resolve(
componentJavaType, componentJavaType.getRecommendedJdbcType( indicators ) ),
ColumnTypeInformation.EMPTY
);
}

View File

@ -40,7 +40,6 @@ import org.hibernate.type.descriptor.java.JavaType;
import org.hibernate.type.descriptor.java.MutabilityPlan;
import org.hibernate.type.descriptor.jdbc.JdbcType;
import org.hibernate.type.descriptor.jdbc.JdbcTypeIndicators;
import org.hibernate.type.internal.BasicTypeImpl;
import org.hibernate.type.spi.TypeConfiguration;
/**
@ -78,7 +77,8 @@ public class BasicCollectionJavaType<C extends Collection<E>, E> extends Abstrac
// (even though we only use this inside the if block, we want it to throw here if something wrong)
return indicators.getTypeConfiguration().getJdbcTypeRegistry().resolveTypeConstructorDescriptor(
indicators.getPreferredSqlTypeCodeForArray(),
new BasicTypeImpl<>( componentJavaType, componentJavaType.getRecommendedJdbcType( indicators ) ),
indicators.getTypeConfiguration().getBasicTypeRegistry().resolve(
componentJavaType, componentJavaType.getRecommendedJdbcType( indicators ) ),
ColumnTypeInformation.EMPTY
);
}