mirror of
https://github.com/hibernate/hibernate-orm
synced 2025-02-28 14:59:12 +00:00
squash some warnings and remove some obsolete code + parameters
This commit is contained in:
parent
476da28da9
commit
6ef9b03f8b
@ -15,10 +15,11 @@
|
||||
import org.hibernate.boot.spi.AbstractNamedQueryDefinition;
|
||||
import org.hibernate.boot.query.NamedNativeQueryDefinition;
|
||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||
import org.hibernate.internal.util.StringHelper;
|
||||
import org.hibernate.query.sql.internal.NamedNativeQueryMementoImpl;
|
||||
import org.hibernate.query.sql.spi.NamedNativeQueryMemento;
|
||||
|
||||
import static org.hibernate.internal.util.StringHelper.isNotEmpty;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
@ -27,8 +28,8 @@ public class NamedNativeQueryDefinitionImpl extends AbstractNamedQueryDefinition
|
||||
private final String resultSetMappingName;
|
||||
private final String resultSetMappingClassName;
|
||||
private final Set<String> querySpaces;
|
||||
private Integer firstResult;
|
||||
private Integer maxResults;
|
||||
private final Integer firstResult;
|
||||
private final Integer maxResults;
|
||||
|
||||
public NamedNativeQueryDefinitionImpl(
|
||||
String name,
|
||||
@ -85,15 +86,14 @@ public String getResultSetMappingClassName() {
|
||||
|
||||
@Override
|
||||
public NamedNativeQueryMemento resolve(SessionFactoryImplementor factory) {
|
||||
final Class resultSetMappingClass = StringHelper.isNotEmpty( resultSetMappingClassName )
|
||||
? factory.getServiceRegistry().getService( ClassLoaderService.class ).classForName( resultSetMappingClassName )
|
||||
: null;
|
||||
|
||||
return new NamedNativeQueryMementoImpl(
|
||||
getRegistrationName(),
|
||||
sqlString,
|
||||
resultSetMappingName,
|
||||
resultSetMappingClass,
|
||||
isNotEmpty( resultSetMappingClassName )
|
||||
? factory.getServiceRegistry().getService( ClassLoaderService.class )
|
||||
.classForName( resultSetMappingClassName )
|
||||
: null,
|
||||
querySpaces,
|
||||
getCacheable(),
|
||||
getCacheRegion(),
|
||||
|
@ -23,7 +23,6 @@
|
||||
import org.hibernate.procedure.internal.Util;
|
||||
import org.hibernate.procedure.spi.NamedCallableQueryMemento;
|
||||
import org.hibernate.procedure.spi.ParameterStrategy;
|
||||
import org.hibernate.query.internal.ResultSetMappingResolutionContext;
|
||||
import org.hibernate.query.results.ResultSetMappingImpl;
|
||||
|
||||
import jakarta.persistence.NamedStoredProcedureQuery;
|
||||
@ -55,7 +54,7 @@ public NamedProcedureCallDefinitionImpl(NamedStoredProcedureQuery annotation) {
|
||||
this.resultClasses = annotation.resultClasses();
|
||||
this.resultSetMappings = annotation.resultSetMappings();
|
||||
|
||||
this.parameterDefinitions = new ParameterDefinitions( annotation.parameters(), hints );
|
||||
this.parameterDefinitions = new ParameterDefinitions( annotation.parameters() );
|
||||
|
||||
final boolean specifiesResultClasses = resultClasses != null && resultClasses.length > 0;
|
||||
final boolean specifiesResultSetMappings = resultSetMappings != null && resultSetMappings.length > 0;
|
||||
@ -94,22 +93,7 @@ public NamedCallableQueryMemento resolve(SessionFactoryImplementor sessionFactor
|
||||
resultClasses,
|
||||
resultSetMapping,
|
||||
collectedQuerySpaces::add,
|
||||
new ResultSetMappingResolutionContext() {
|
||||
@Override
|
||||
public SessionFactoryImplementor getSessionFactory() {
|
||||
return sessionFactory;
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public void addQueryReturns(NativeSQLQueryReturn... queryReturns) {
|
||||
// Collections.addAll( collectedQueryReturns, queryReturns );
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void addQuerySpaces(String... spaces) {
|
||||
// Collections.addAll( collectedQuerySpaces, spaces );
|
||||
// }
|
||||
}
|
||||
() -> sessionFactory
|
||||
);
|
||||
}
|
||||
else if ( specifiesResultSetMappings ) {
|
||||
@ -117,27 +101,7 @@ else if ( specifiesResultSetMappings ) {
|
||||
resultSetMappings,
|
||||
resultSetMapping,
|
||||
collectedQuerySpaces::add,
|
||||
new ResultSetMappingResolutionContext() {
|
||||
@Override
|
||||
public SessionFactoryImplementor getSessionFactory() {
|
||||
return sessionFactory;
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public NamedResultSetMappingMemento findResultSetMapping(String name) {
|
||||
// return sessionFactory.getQueryEngine().getNamedObjectRepository().getResultSetMappingMemento( name );
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void addQueryReturns(NativeSQLQueryReturn... queryReturns) {
|
||||
// Collections.addAll( collectedQueryReturns, queryReturns );
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void addQuerySpaces(String... spaces) {
|
||||
// Collections.addAll( collectedQuerySpaces, spaces );
|
||||
// }
|
||||
}
|
||||
() -> sessionFactory
|
||||
);
|
||||
}
|
||||
|
||||
@ -163,9 +127,9 @@ public SessionFactoryImplementor getSessionFactory() {
|
||||
|
||||
static class ParameterDefinitions {
|
||||
private final ParameterStrategy parameterStrategy;
|
||||
private final ParameterDefinition[] parameterDefinitions;
|
||||
private final ParameterDefinition<?>[] parameterDefinitions;
|
||||
|
||||
ParameterDefinitions(StoredProcedureParameter[] parameters, Map<String, Object> queryHintMap) {
|
||||
ParameterDefinitions(StoredProcedureParameter[] parameters) {
|
||||
if ( parameters == null || parameters.length == 0 ) {
|
||||
parameterStrategy = ParameterStrategy.POSITIONAL;
|
||||
parameterDefinitions = new ParameterDefinition[0];
|
||||
@ -177,13 +141,8 @@ static class ParameterDefinitions {
|
||||
parameterDefinitions = new ParameterDefinition[ parameters.length ];
|
||||
|
||||
for ( int i = 0; i < parameters.length; i++ ) {
|
||||
parameterDefinitions[i] = ParameterDefinition.from(
|
||||
parameterStrategy,
|
||||
parameters[i],
|
||||
// i+1 for the position because the apis say the numbers are 1-based, not zero
|
||||
i+1,
|
||||
queryHintMap
|
||||
);
|
||||
// i+1 for the position because the apis say the numbers are 1-based, not zero
|
||||
parameterDefinitions[i] = new ParameterDefinition<>(i + 1, parameters[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -194,39 +153,20 @@ public ParameterStrategy getParameterStrategy() {
|
||||
|
||||
public List<ParameterMemento> toMementos(SessionFactoryImplementor sessionFactory) {
|
||||
final List<ParameterMemento> mementos = new ArrayList<>();
|
||||
for ( ParameterDefinition definition : parameterDefinitions ) {
|
||||
mementos.add(definition.toMemento( sessionFactory ));
|
||||
for ( ParameterDefinition<?> definition : parameterDefinitions ) {
|
||||
mementos.add( definition.toMemento( sessionFactory ) );
|
||||
}
|
||||
return mementos;
|
||||
}
|
||||
}
|
||||
|
||||
static class ParameterDefinition {
|
||||
static class ParameterDefinition<T> {
|
||||
private final Integer position;
|
||||
private final String name;
|
||||
private final ParameterMode parameterMode;
|
||||
private final Class<?> type;
|
||||
|
||||
static ParameterDefinition from(
|
||||
ParameterStrategy parameterStrategy,
|
||||
StoredProcedureParameter parameterAnnotation,
|
||||
int adjustedPosition,
|
||||
Map<String, Object> queryHintMap) {
|
||||
return new ParameterDefinition( adjustedPosition, parameterAnnotation );
|
||||
}
|
||||
|
||||
private static Boolean interpretBoolean(Object value) {
|
||||
if ( value == null ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if ( value instanceof Boolean ) {
|
||||
return (Boolean) value;
|
||||
}
|
||||
|
||||
return Boolean.valueOf( value.toString() );
|
||||
}
|
||||
private final Class<T> type;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
ParameterDefinition(int position, StoredProcedureParameter annotation) {
|
||||
this.position = position;
|
||||
this.name = normalize( annotation.name() );
|
||||
@ -240,7 +180,7 @@ public ParameterMemento toMemento(SessionFactoryImplementor sessionFactory) {
|
||||
// ? explicitPassNullSetting.booleanValue()
|
||||
// : sessionFactory.getSessionFactoryOptions().isProcedureParameterNullPassingEnabled();
|
||||
|
||||
return new NamedCallableQueryMementoImpl.ParameterMementoImpl(
|
||||
return new NamedCallableQueryMementoImpl.ParameterMementoImpl<>(
|
||||
position,
|
||||
name,
|
||||
parameterMode,
|
||||
|
@ -293,7 +293,6 @@ private static Object instantiateType(StandardServiceRegistry serviceRegistry,
|
||||
public static BasicValue.Resolution<?> createLocalResolution(
|
||||
String name,
|
||||
Class<?> typeImplementorClass,
|
||||
MutabilityPlan<?> explicitMutabilityPlan,
|
||||
Map<?,?> localTypeParams,
|
||||
MetadataBuildingContext buildingContext) {
|
||||
return createResolution(
|
||||
|
@ -27,6 +27,9 @@
|
||||
import org.hibernate.internal.log.DeprecationLogger;
|
||||
import org.hibernate.internal.util.StringHelper;
|
||||
|
||||
import static org.hibernate.internal.util.StringHelper.isNotEmpty;
|
||||
import static org.hibernate.internal.util.StringHelper.nullIfEmpty;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
@ -61,14 +64,15 @@ public static void processNamedQuery(
|
||||
|
||||
for ( Object content : namedQueryBinding.getContent() ) {
|
||||
if ( content instanceof String ) {
|
||||
final String hqlString = StringHelper.nullIfEmpty( ( (String) content ).trim() );
|
||||
if ( StringHelper.isNotEmpty( hqlString ) ) {
|
||||
final String hqlString = nullIfEmpty( ( (String) content ).trim() );
|
||||
if ( isNotEmpty( hqlString ) ) {
|
||||
queryBuilder.setHqlString( hqlString );
|
||||
foundQuery = true;
|
||||
}
|
||||
}
|
||||
else {
|
||||
final JaxbHbmQueryParamType paramTypeBinding = (JaxbHbmQueryParamType)( (JAXBElement) content ).getValue();
|
||||
final JaxbHbmQueryParamType paramTypeBinding = (JaxbHbmQueryParamType)
|
||||
( (JAXBElement<?>) content ).getValue();
|
||||
queryBuilder.addParameterTypeHint( paramTypeBinding.getName(), paramTypeBinding.getType() );
|
||||
}
|
||||
}
|
||||
@ -90,7 +94,9 @@ public static void processNamedQuery(
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// Named native query
|
||||
|
||||
public static void processNamedNativeQuery(HbmLocalMetadataBuildingContext context, JaxbHbmNamedNativeQueryType namedQueryBinding) {
|
||||
public static void processNamedNativeQuery(
|
||||
HbmLocalMetadataBuildingContext context,
|
||||
JaxbHbmNamedNativeQueryType namedQueryBinding) {
|
||||
processNamedNativeQuery( context, namedQueryBinding, "" );
|
||||
}
|
||||
|
||||
@ -117,11 +123,8 @@ public static void processNamedNativeQuery(
|
||||
.setFetchSize( namedQueryBinding.getFetchSize() )
|
||||
.setResultSetMappingName( namedQueryBinding.getResultsetRef() );
|
||||
|
||||
final ImplicitHbmResultSetMappingDescriptorBuilder
|
||||
implicitResultSetMappingBuilder = new ImplicitHbmResultSetMappingDescriptorBuilder(
|
||||
registrationName,
|
||||
context
|
||||
);
|
||||
final ImplicitHbmResultSetMappingDescriptorBuilder implicitResultSetMappingBuilder =
|
||||
new ImplicitHbmResultSetMappingDescriptorBuilder( registrationName, context );
|
||||
|
||||
boolean foundQuery = false;
|
||||
|
||||
@ -149,7 +152,7 @@ public static void processNamedNativeQuery(
|
||||
}
|
||||
|
||||
if ( implicitResultSetMappingBuilder.hasAnyReturns() ) {
|
||||
if ( StringHelper.isNotEmpty( namedQueryBinding.getResultsetRef() ) ) {
|
||||
if ( isNotEmpty( namedQueryBinding.getResultsetRef() ) ) {
|
||||
throw new org.hibernate.boot.MappingException(
|
||||
String.format(
|
||||
"Named native query [%s] specified both a resultset-ref and an inline mapping of results",
|
||||
@ -203,7 +206,7 @@ private static boolean processNamedQueryContentItem(
|
||||
// Especially when the query string is wrapped in CDATA we will get
|
||||
// "extra" Strings here containing just spaces and/or newlines. This
|
||||
// bit tries to account for them.
|
||||
final String contentString = StringHelper.nullIfEmpty( ( (String) content ).trim() );
|
||||
final String contentString = nullIfEmpty( ( (String) content ).trim() );
|
||||
if ( contentString != null ) {
|
||||
queryBuilder.setSqlString( (String) content );
|
||||
return true;
|
||||
@ -214,7 +217,7 @@ private static boolean processNamedQueryContentItem(
|
||||
}
|
||||
else if ( content instanceof JAXBElement ) {
|
||||
return processNamedQueryContentItem(
|
||||
( (JAXBElement) content ).getValue(),
|
||||
( (JAXBElement<?>) content ).getValue(),
|
||||
queryBuilder,
|
||||
implicitResultSetMappingBuilder,
|
||||
namedQueryBinding,
|
||||
@ -249,7 +252,7 @@ else if ( content instanceof JaxbHbmNativeQueryCollectionLoadReturnType ) {
|
||||
"Encountered unexpected content type [%s] for named native query [%s] : [%s]",
|
||||
content.getClass().getName(),
|
||||
namedQueryBinding.getName(),
|
||||
content.toString()
|
||||
content
|
||||
),
|
||||
context.getOrigin()
|
||||
);
|
||||
|
@ -12,9 +12,6 @@
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.hibernate.CacheMode;
|
||||
import org.hibernate.FlushMode;
|
||||
import org.hibernate.LockOptions;
|
||||
import org.hibernate.boot.internal.NamedNativeQueryDefinitionImpl;
|
||||
|
||||
/**
|
||||
@ -97,20 +94,6 @@ public String getResultSetMappingClassName() {
|
||||
return resultSetMappingClassName;
|
||||
}
|
||||
|
||||
public NamedNativeQueryDefinitionBuilder addSynchronizedQuerySpaces(Set<String> querySpaces) {
|
||||
if ( querySpaces == null || querySpaces.isEmpty() ) {
|
||||
return this;
|
||||
}
|
||||
|
||||
if ( this.querySpaces == null ) {
|
||||
this.querySpaces = new HashSet<>();
|
||||
}
|
||||
|
||||
this.querySpaces.addAll( querySpaces );
|
||||
|
||||
return getThis();
|
||||
}
|
||||
|
||||
public NamedNativeQueryDefinitionBuilder addSynchronizedQuerySpace(String space) {
|
||||
if ( this.querySpaces == null ) {
|
||||
this.querySpaces = new HashSet<>();
|
||||
@ -134,51 +117,6 @@ public NamedNativeQueryDefinitionBuilder setResultSetMappingClassName(String res
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NamedNativeQueryDefinitionBuilder setFetchSize(Integer fetchSize) {
|
||||
return (NamedNativeQueryDefinitionBuilder) super.setFetchSize( fetchSize );
|
||||
}
|
||||
|
||||
@Override
|
||||
public NamedNativeQueryDefinitionBuilder setCacheable(Boolean cacheable) {
|
||||
return (NamedNativeQueryDefinitionBuilder) super.setCacheable( cacheable );
|
||||
}
|
||||
|
||||
@Override
|
||||
public NamedNativeQueryDefinitionBuilder setCacheRegion(String cacheRegion) {
|
||||
return (NamedNativeQueryDefinitionBuilder) super.setCacheRegion( cacheRegion );
|
||||
}
|
||||
|
||||
@Override
|
||||
public NamedNativeQueryDefinitionBuilder setCacheMode(CacheMode cacheMode) {
|
||||
return (NamedNativeQueryDefinitionBuilder) super.setCacheMode( cacheMode );
|
||||
}
|
||||
|
||||
@Override
|
||||
public NamedNativeQueryDefinitionBuilder setLockOptions(LockOptions lockOptions) {
|
||||
return (NamedNativeQueryDefinitionBuilder) super.setLockOptions( lockOptions );
|
||||
}
|
||||
|
||||
@Override
|
||||
public NamedNativeQueryDefinitionBuilder setTimeout(Integer timeout) {
|
||||
return (NamedNativeQueryDefinitionBuilder) super.setTimeout( timeout );
|
||||
}
|
||||
|
||||
@Override
|
||||
public NamedNativeQueryDefinitionBuilder setFlushMode(FlushMode flushMode) {
|
||||
return (NamedNativeQueryDefinitionBuilder) super.setFlushMode( flushMode );
|
||||
}
|
||||
|
||||
@Override
|
||||
public NamedNativeQueryDefinitionBuilder setReadOnly(Boolean readOnly) {
|
||||
return (NamedNativeQueryDefinitionBuilder) super.setReadOnly( readOnly );
|
||||
}
|
||||
|
||||
@Override
|
||||
public NamedNativeQueryDefinitionBuilder setComment(String comment) {
|
||||
return (NamedNativeQueryDefinitionBuilder) super.setComment( comment );
|
||||
}
|
||||
|
||||
public void addParameterTypeHint(String name, String type) {
|
||||
if ( parameterTypes == null ) {
|
||||
parameterTypes = new HashMap<>();
|
||||
|
@ -9,7 +9,6 @@
|
||||
import java.util.Objects;
|
||||
|
||||
import org.hibernate.metamodel.mapping.JdbcMapping;
|
||||
import org.hibernate.metamodel.model.convert.spi.BasicValueConverter;
|
||||
import org.hibernate.sql.ast.tree.expression.JdbcParameter;
|
||||
import org.hibernate.sql.exec.internal.JdbcParameterBindingImpl;
|
||||
import org.hibernate.sql.exec.internal.JdbcParameterImpl;
|
||||
@ -40,11 +39,7 @@ public JdbcParameterBinder getBinder() {
|
||||
}
|
||||
|
||||
public JdbcParameterBinding getBinding() {
|
||||
final BasicValueConverter valueConverter = jdbcMapping.getValueConverter();
|
||||
if ( valueConverter == null ) {
|
||||
return new JdbcParameterBindingImpl( jdbcMapping, jdbcParameterValue );
|
||||
}
|
||||
return new JdbcParameterBindingImpl( jdbcMapping, valueConverter.toRelationalValue( jdbcParameterValue ) );
|
||||
return new JdbcParameterBindingImpl( jdbcMapping, jdbcMapping.convertToRelationalValue( jdbcParameterValue ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -351,8 +351,6 @@ protected Resolution<?> buildResolution() {
|
||||
if ( explicitTypeName != null ) {
|
||||
return interpretExplicitlyNamedType(
|
||||
explicitTypeName,
|
||||
enumerationStyle,
|
||||
implicitJavaTypeAccess,
|
||||
explicitJavaTypeAccess,
|
||||
explicitJdbcTypeAccess,
|
||||
explicitMutabilityPlanAccess,
|
||||
@ -377,85 +375,54 @@ protected Resolution<?> buildResolution() {
|
||||
);
|
||||
}
|
||||
|
||||
JavaType<?> jtd = null;
|
||||
|
||||
// determine JavaType if we can
|
||||
|
||||
final BasicJavaType explicitJtd;
|
||||
if ( explicitJavaTypeAccess != null ) {
|
||||
explicitJtd = explicitJavaTypeAccess.apply( typeConfiguration );
|
||||
if ( explicitJtd != null ) {
|
||||
jtd = explicitJtd;
|
||||
}
|
||||
}
|
||||
else {
|
||||
explicitJtd = null;
|
||||
}
|
||||
final BasicJavaType explicitJavaType = explicitJavaTypeAccess == null ? null
|
||||
: explicitJavaTypeAccess.apply( typeConfiguration );
|
||||
|
||||
if ( jtd == null ) {
|
||||
if ( implicitJavaTypeAccess != null ) {
|
||||
final java.lang.reflect.Type implicitJtd = implicitJavaTypeAccess.apply( typeConfiguration );
|
||||
if ( implicitJtd != null ) {
|
||||
jtd = typeConfiguration.getJavaTypeRegistry().getDescriptor( implicitJtd );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( jtd == null ) {
|
||||
final JavaType<?> reflectedJtd = determineReflectedJavaType();
|
||||
if ( reflectedJtd != null ) {
|
||||
jtd = reflectedJtd;
|
||||
}
|
||||
}
|
||||
final JavaType<?> javaType = determineJavaType( explicitJavaType );
|
||||
|
||||
final ConverterDescriptor attributeConverterDescriptor = getAttributeConverterDescriptor();
|
||||
final Selectable column = getColumn();
|
||||
if ( attributeConverterDescriptor != null ) {
|
||||
final ManagedBeanRegistry managedBeanRegistry = getBuildingContext().getBootstrapContext()
|
||||
.getServiceRegistry()
|
||||
.getService( ManagedBeanRegistry.class );
|
||||
|
||||
final JpaAttributeConverterCreationContext converterCreationContext = new JpaAttributeConverterCreationContext() {
|
||||
@Override
|
||||
public ManagedBeanRegistry getManagedBeanRegistry() {
|
||||
return managedBeanRegistry;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeConfiguration getTypeConfiguration() {
|
||||
return typeConfiguration;
|
||||
}
|
||||
};
|
||||
|
||||
final NamedConverterResolution<Object> converterResolution = NamedConverterResolution.from(
|
||||
final NamedConverterResolution<?> converterResolution = NamedConverterResolution.from(
|
||||
attributeConverterDescriptor,
|
||||
explicitJavaTypeAccess,
|
||||
explicitJdbcTypeAccess,
|
||||
explicitMutabilityPlanAccess,
|
||||
this,
|
||||
converterCreationContext,
|
||||
new JpaAttributeConverterCreationContext() {
|
||||
@Override
|
||||
public ManagedBeanRegistry getManagedBeanRegistry() {
|
||||
return managedBeanRegistry;
|
||||
}
|
||||
@Override
|
||||
public TypeConfiguration getTypeConfiguration() {
|
||||
return typeConfiguration;
|
||||
}
|
||||
},
|
||||
getBuildingContext()
|
||||
);
|
||||
|
||||
if ( jtd instanceof BasicPluralJavaType<?>
|
||||
if ( javaType instanceof BasicPluralJavaType<?>
|
||||
&& !attributeConverterDescriptor.getDomainValueResolvedType()
|
||||
.getErasedType()
|
||||
.isAssignableFrom( jtd.getJavaTypeClass() ) ) {
|
||||
.isAssignableFrom( javaType.getJavaTypeClass() ) ) {
|
||||
// In this case, the converter applies to the element of a BasicPluralJavaType
|
||||
final BasicPluralJavaType<?> containerJtd = (BasicPluralJavaType<?>) jtd;
|
||||
final BasicPluralJavaType<?> containerJtd = (BasicPluralJavaType<?>) javaType;
|
||||
final BasicType registeredElementType = converterResolution.getLegacyResolvedBasicType();
|
||||
final ColumnTypeInformation columnTypeInformation;
|
||||
if ( getColumn() instanceof ColumnTypeInformation ) {
|
||||
columnTypeInformation = (ColumnTypeInformation) getColumn();
|
||||
}
|
||||
else {
|
||||
columnTypeInformation = null;
|
||||
}
|
||||
final BasicType<?> registeredType = registeredElementType == null ? null : containerJtd.resolveType(
|
||||
typeConfiguration,
|
||||
getMetadata().getDatabase().getDialect(),
|
||||
registeredElementType,
|
||||
columnTypeInformation
|
||||
);
|
||||
final BasicType<?> registeredType = registeredElementType == null ? null
|
||||
: containerJtd.resolveType(
|
||||
typeConfiguration,
|
||||
getMetadata().getDatabase().getDialect(),
|
||||
registeredElementType,
|
||||
column instanceof ColumnTypeInformation ? (ColumnTypeInformation) column : null
|
||||
);
|
||||
if ( registeredType != null ) {
|
||||
typeConfiguration.getBasicTypeRegistry().register( registeredType );
|
||||
|
||||
@ -477,40 +444,57 @@ public TypeConfiguration getTypeConfiguration() {
|
||||
? explicitJdbcTypeAccess.apply( typeConfiguration )
|
||||
: null;
|
||||
|
||||
if ( jtd == null && jdbcType != null ) {
|
||||
jtd = jdbcType.getJdbcRecommendedJavaTypeMapping( null, null, typeConfiguration );
|
||||
}
|
||||
|
||||
if ( jtd == null ) {
|
||||
final BasicJavaType<?> basicJavaType = javaType == null && jdbcType != null
|
||||
? jdbcType.getJdbcRecommendedJavaTypeMapping( null, null, typeConfiguration )
|
||||
: (BasicJavaType<?>) javaType;
|
||||
if ( basicJavaType == null ) {
|
||||
throw new MappingException( "Unable to determine JavaType to use : " + this );
|
||||
}
|
||||
|
||||
final TypeDefinitionRegistry typeDefinitionRegistry = getBuildingContext().getTypeDefinitionRegistry();
|
||||
final TypeDefinition autoAppliedTypeDef = typeDefinitionRegistry.resolveAutoApplied( (BasicJavaType<?>) jtd );
|
||||
if ( autoAppliedTypeDef != null && ( !jtd.getJavaTypeClass().isEnum() || enumerationStyle == null ) ) {
|
||||
final TypeDefinition autoAppliedTypeDef =
|
||||
getBuildingContext().getTypeDefinitionRegistry().resolveAutoApplied( basicJavaType );
|
||||
if ( autoAppliedTypeDef != null
|
||||
&& ( !basicJavaType.getJavaTypeClass().isEnum() || enumerationStyle == null ) ) {
|
||||
log.debug( "BasicValue resolution matched auto-applied type-definition" );
|
||||
return autoAppliedTypeDef.resolve(
|
||||
typeParameters,
|
||||
null,
|
||||
getBuildingContext(),
|
||||
this
|
||||
return autoAppliedTypeDef.resolve( typeParameters, null, getBuildingContext(), this );
|
||||
}
|
||||
else {
|
||||
return InferredBasicValueResolver.from(
|
||||
explicitJavaType,
|
||||
jdbcType,
|
||||
resolvedJavaType,
|
||||
this::determineReflectedJavaType,
|
||||
this,
|
||||
getTable(),
|
||||
column,
|
||||
ownerName,
|
||||
propertyName,
|
||||
getMetadata().getDatabase().getDialect(),
|
||||
typeConfiguration
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return InferredBasicValueResolver.from(
|
||||
explicitJtd,
|
||||
jdbcType,
|
||||
resolvedJavaType,
|
||||
this::determineReflectedJavaType,
|
||||
this,
|
||||
getTable(),
|
||||
getColumn(),
|
||||
ownerName,
|
||||
propertyName,
|
||||
getMetadata().getDatabase().getDialect(),
|
||||
typeConfiguration
|
||||
);
|
||||
private JavaType<?> determineJavaType(JavaType<?> explicitJavaType) {
|
||||
JavaType<?> javaType = explicitJavaType;
|
||||
|
||||
if ( javaType == null ) {
|
||||
if ( implicitJavaTypeAccess != null ) {
|
||||
final java.lang.reflect.Type implicitJtd = implicitJavaTypeAccess.apply( typeConfiguration );
|
||||
if ( implicitJtd != null ) {
|
||||
javaType = typeConfiguration.getJavaTypeRegistry().getDescriptor( implicitJtd );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( javaType == null ) {
|
||||
final JavaType<?> reflectedJtd = determineReflectedJavaType();
|
||||
if ( reflectedJtd != null ) {
|
||||
javaType = reflectedJtd;
|
||||
}
|
||||
}
|
||||
|
||||
return javaType;
|
||||
}
|
||||
|
||||
private JavaType<?> determineReflectedJavaType() {
|
||||
@ -548,8 +532,6 @@ else if ( ownerName != null && propertyName != null ) {
|
||||
|
||||
private static Resolution<?> interpretExplicitlyNamedType(
|
||||
String name,
|
||||
EnumType enumerationStyle,
|
||||
Function<TypeConfiguration, java.lang.reflect.Type> implicitJavaTypeAccess,
|
||||
Function<TypeConfiguration, BasicJavaType> explicitJtdAccess,
|
||||
Function<TypeConfiguration, JdbcType> explicitStdAccess,
|
||||
Function<TypeConfiguration, MutabilityPlan> explicitMutabilityPlanAccess,
|
||||
@ -671,15 +653,7 @@ public TypeConfiguration getTypeConfiguration() {
|
||||
);
|
||||
}
|
||||
|
||||
return TypeDefinition.createLocalResolution(
|
||||
name,
|
||||
typeNamedClass,
|
||||
explicitMutabilityPlanAccess != null
|
||||
? explicitMutabilityPlanAccess.apply( typeConfiguration )
|
||||
: null,
|
||||
localTypeParams,
|
||||
context
|
||||
);
|
||||
return TypeDefinition.createLocalResolution( name, typeNamedClass, localTypeParams, context );
|
||||
}
|
||||
catch (ClassLoadingException e) {
|
||||
// allow the exception below to trigger
|
||||
@ -838,7 +812,7 @@ public <T extends UserType<?>> void setExplicitCustomType(Class<T> explicitCusto
|
||||
setTypeParameters( properties );
|
||||
|
||||
this.resolution = new UserTypeResolution(
|
||||
new CustomType<>( (UserType<Object>) typeInstance, typeConfiguration ),
|
||||
new CustomType<>( (UserType<?>) typeInstance, typeConfiguration ),
|
||||
null,
|
||||
properties
|
||||
);
|
||||
|
@ -81,6 +81,16 @@ default BasicValueConverter getValueConverter() {
|
||||
return null;
|
||||
}
|
||||
|
||||
//TODO: would it be better to just give JdbcMapping a
|
||||
// noop converter by default, instead of having
|
||||
// to deal with null here?
|
||||
@SuppressWarnings({"rawtypes", "unchecked"})
|
||||
default Object convertToRelationalValue(Object value) {
|
||||
BasicValueConverter valueConverter = getValueConverter();
|
||||
return valueConverter == null ? value : valueConverter.toRelationalValue( value );
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
default int getJdbcTypeCount() {
|
||||
return 1;
|
||||
|
@ -21,7 +21,6 @@
|
||||
import org.hibernate.metamodel.mapping.SelectableConsumer;
|
||||
import org.hibernate.metamodel.mapping.SelectableMapping;
|
||||
import org.hibernate.metamodel.mapping.SingularAttributeMapping;
|
||||
import org.hibernate.metamodel.model.convert.spi.BasicValueConverter;
|
||||
import org.hibernate.metamodel.model.domain.NavigableRole;
|
||||
import org.hibernate.property.access.spi.PropertyAccess;
|
||||
import org.hibernate.spi.NavigablePath;
|
||||
@ -39,7 +38,6 @@
|
||||
import org.hibernate.sql.results.graph.basic.BasicFetch;
|
||||
import org.hibernate.sql.results.graph.basic.BasicResult;
|
||||
import org.hibernate.tuple.ValueGeneration;
|
||||
import org.hibernate.type.BasicType;
|
||||
import org.hibernate.type.descriptor.java.JavaType;
|
||||
|
||||
/**
|
||||
@ -124,7 +122,7 @@ public static BasicAttributeMapping withSelectableMapping(
|
||||
SelectableMapping selectableMapping) {
|
||||
String attributeName = null;
|
||||
int stateArrayPosition = 0;
|
||||
AttributeMetadataAccess attributeMetadataAccess = null;
|
||||
AttributeMetadataAccess attributeMetadataAccess;
|
||||
if ( original instanceof SingleAttributeIdentifierMapping ) {
|
||||
final SingleAttributeIdentifierMapping mapping = (SingleAttributeIdentifierMapping) original;
|
||||
attributeName = mapping.getAttributeName();
|
||||
@ -136,6 +134,9 @@ else if ( original instanceof SingularAttributeMapping ) {
|
||||
stateArrayPosition = mapping.getStateArrayPosition();
|
||||
attributeMetadataAccess = mapping.getAttributeMetadataAccess();
|
||||
}
|
||||
else {
|
||||
attributeMetadataAccess = null;
|
||||
}
|
||||
return new BasicAttributeMapping(
|
||||
attributeName,
|
||||
original.getNavigableRole(),
|
||||
@ -334,11 +335,7 @@ public Fetch generateFetch(
|
||||
|
||||
@Override
|
||||
public Object disassemble(Object value, SharedSessionContractImplementor session) {
|
||||
if ( jdbcMapping.getValueConverter() != null ) {
|
||||
//noinspection unchecked
|
||||
return jdbcMapping.getValueConverter().toRelationalValue( value );
|
||||
}
|
||||
return value;
|
||||
return jdbcMapping.convertToRelationalValue( value );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -310,9 +310,6 @@ public int forEachDisassembledJdbcValue(
|
||||
|
||||
@Override
|
||||
public Object disassemble(Object value, SharedSessionContractImplementor session) {
|
||||
if ( selectableMapping.getJdbcMapping().getValueConverter() != null ) {
|
||||
return selectableMapping.getJdbcMapping().getValueConverter().toRelationalValue( value );
|
||||
}
|
||||
return value;
|
||||
return selectableMapping.getJdbcMapping().convertToRelationalValue( value );
|
||||
}
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ public class NamedCallableQueryMementoImpl extends AbstractNamedQueryMemento imp
|
||||
private final List<NamedCallableQueryMemento.ParameterMemento> parameterMementos;
|
||||
|
||||
private final String[] resultSetMappingNames;
|
||||
private final Class[] resultSetMappingClasses;
|
||||
private final Class<?>[] resultSetMappingClasses;
|
||||
|
||||
private final Set<String> querySpaces;
|
||||
|
||||
@ -51,7 +51,7 @@ public NamedCallableQueryMementoImpl(
|
||||
ParameterStrategy parameterStrategy,
|
||||
List<NamedCallableQueryMemento.ParameterMemento> parameterMementos,
|
||||
String[] resultSetMappingNames,
|
||||
Class[] resultSetMappingClasses,
|
||||
Class<?>[] resultSetMappingClasses,
|
||||
Set<String> querySpaces,
|
||||
Boolean cacheable,
|
||||
String cacheRegion,
|
||||
@ -103,7 +103,7 @@ public String[] getResultSetMappingNames() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class[] getResultSetMappingClasses() {
|
||||
public Class<?>[] getResultSetMappingClasses() {
|
||||
return resultSetMappingClasses;
|
||||
}
|
||||
|
||||
@ -138,7 +138,7 @@ public <T> QueryImplementor<T> toQuery(SharedSessionContractImplementor session)
|
||||
|
||||
@Override
|
||||
public <T> ProcedureCallImplementor<T> toQuery(SharedSessionContractImplementor session, Class<T> javaType) {
|
||||
return new ProcedureCallImpl( session, this, javaType );
|
||||
return new ProcedureCallImpl<>( session, this, javaType );
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -171,12 +171,12 @@ public void validate(QueryEngine queryEngine) {
|
||||
/**
|
||||
* A "disconnected" copy of the metadata for a parameter, that can be used in ProcedureCallMementoImpl.
|
||||
*/
|
||||
public static class ParameterMementoImpl implements NamedCallableQueryMemento.ParameterMemento {
|
||||
public static class ParameterMementoImpl<T> implements NamedCallableQueryMemento.ParameterMemento {
|
||||
private final Integer position;
|
||||
private final String name;
|
||||
private final ParameterMode mode;
|
||||
private final Class type;
|
||||
private final BindableType hibernateType;
|
||||
private final Class<T> type;
|
||||
private final BindableType<T> hibernateType;
|
||||
|
||||
/**
|
||||
* Create the memento
|
||||
@ -185,8 +185,8 @@ public ParameterMementoImpl(
|
||||
int position,
|
||||
String name,
|
||||
ParameterMode mode,
|
||||
Class type,
|
||||
BindableType hibernateType) {
|
||||
Class<T> type,
|
||||
BindableType<T> hibernateType) {
|
||||
this.position = position;
|
||||
this.name = name;
|
||||
this.mode = mode;
|
||||
@ -206,19 +206,18 @@ public ParameterMode getMode() {
|
||||
return mode;
|
||||
}
|
||||
|
||||
public Class getType() {
|
||||
public Class<T> getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public BindableType getHibernateType() {
|
||||
public BindableType<T> getHibernateType() {
|
||||
return hibernateType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ProcedureParameterImplementor resolve(SharedSessionContractImplementor session) {
|
||||
public ProcedureParameterImplementor<T> resolve(SharedSessionContractImplementor session) {
|
||||
if ( getName() != null ) {
|
||||
//noinspection unchecked
|
||||
return new ProcedureParameterImpl(
|
||||
return new ProcedureParameterImpl<>(
|
||||
getName(),
|
||||
getMode(),
|
||||
type,
|
||||
@ -226,8 +225,7 @@ public ProcedureParameterImplementor resolve(SharedSessionContractImplementor se
|
||||
);
|
||||
}
|
||||
else {
|
||||
//noinspection unchecked
|
||||
return new ProcedureParameterImpl(
|
||||
return new ProcedureParameterImpl<>(
|
||||
getPosition(),
|
||||
getMode(),
|
||||
type,
|
||||
@ -244,8 +242,8 @@ public ProcedureParameterImplementor resolve(SharedSessionContractImplementor se
|
||||
*
|
||||
* @return The memento
|
||||
*/
|
||||
public static ParameterMementoImpl fromRegistration(ProcedureParameterImplementor registration) {
|
||||
return new ParameterMementoImpl(
|
||||
public static <U> ParameterMementoImpl<U> fromRegistration(ProcedureParameterImplementor<U> registration) {
|
||||
return new ParameterMementoImpl<>(
|
||||
registration.getPosition(),
|
||||
registration.getName(),
|
||||
registration.getMode(),
|
||||
|
@ -95,6 +95,7 @@
|
||||
import jakarta.persistence.TransactionRequiredException;
|
||||
|
||||
import static org.hibernate.jpa.HibernateHints.HINT_CALLABLE_FUNCTION;
|
||||
import static org.hibernate.procedure.internal.NamedCallableQueryMementoImpl.ParameterMementoImpl.fromRegistration;
|
||||
|
||||
/**
|
||||
* Standard implementation of {@link ProcedureCall}
|
||||
@ -119,7 +120,6 @@ public class ProcedureCallImpl<R>
|
||||
|
||||
private final QueryOptionsImpl queryOptions = new QueryOptionsImpl();
|
||||
|
||||
private JdbcCall call;
|
||||
private ProcedureOutputsImpl outputs;
|
||||
|
||||
|
||||
@ -584,7 +584,7 @@ private ProcedureOutputsImpl buildOutputs() {
|
||||
.getJdbcEnvironment()
|
||||
.getDialect()
|
||||
.getCallableStatementSupport();
|
||||
this.call = callableStatementSupport.interpretCall( this );
|
||||
JdbcCall call = callableStatementSupport.interpretCall(this);
|
||||
|
||||
final Map<ProcedureParameter<?>, JdbcCallParameterRegistration> parameterRegistrations = new IdentityHashMap<>();
|
||||
final List<JdbcCallRefCursorExtractor> refCursorExtractors = new ArrayList<>();
|
||||
@ -606,7 +606,7 @@ private ProcedureOutputsImpl buildOutputs() {
|
||||
}
|
||||
}
|
||||
|
||||
LOG.debugf( "Preparing procedure call : %s", call );
|
||||
LOG.debugf( "Preparing procedure call : %s", call);
|
||||
final CallableStatement statement = (CallableStatement) getSession()
|
||||
.getJdbcCoordinator()
|
||||
.getStatementPreparer()
|
||||
@ -637,18 +637,12 @@ private ProcedureOutputsImpl buildOutputs() {
|
||||
}
|
||||
}
|
||||
final JdbcMapping parameterType = (JdbcMapping) registration.getParameterType();
|
||||
final Object bindValue;
|
||||
if ( parameterType.getValueConverter() == null ) {
|
||||
bindValue = binding.getBindValue();
|
||||
}
|
||||
else {
|
||||
bindValue = parameterType.getValueConverter().toRelationalValue( binding.getBindValue() );
|
||||
}
|
||||
final Object bindValue = binding.getBindValue();
|
||||
jdbcParameterBindings.addBinding(
|
||||
(JdbcParameter) registration.getParameterBinder(),
|
||||
new JdbcParameterBindingImpl(
|
||||
parameterType,
|
||||
bindValue
|
||||
parameterType.convertToRelationalValue( bindValue )
|
||||
)
|
||||
);
|
||||
}
|
||||
@ -810,18 +804,7 @@ private static List<NamedCallableQueryMemento.ParameterMemento> toParameterMemen
|
||||
final List<NamedCallableQueryMemento.ParameterMemento> mementos = new ArrayList<>();
|
||||
|
||||
parameterMetadata.visitRegistrations(
|
||||
queryParameter -> {
|
||||
final ProcedureParameterImplementor<?> procedureParameter = (ProcedureParameterImplementor<?>) queryParameter;
|
||||
mementos.add(
|
||||
new NamedCallableQueryMementoImpl.ParameterMementoImpl(
|
||||
procedureParameter.getPosition(),
|
||||
procedureParameter.getName(),
|
||||
procedureParameter.getMode(),
|
||||
procedureParameter.getParameterType(),
|
||||
procedureParameter.getHibernateType()
|
||||
)
|
||||
);
|
||||
}
|
||||
queryParameter -> mementos.add( fromRegistration( (ProcedureParameterImplementor<?>) queryParameter) )
|
||||
);
|
||||
|
||||
return mementos;
|
||||
|
@ -56,7 +56,7 @@ default ProcedureCall makeProcedureCall(SessionImplementor session) {
|
||||
|
||||
String[] getResultSetMappingNames();
|
||||
|
||||
Class[] getResultSetMappingClasses();
|
||||
Class<?>[] getResultSetMappingClasses();
|
||||
|
||||
Set<String> getQuerySpaces();
|
||||
|
||||
@ -88,6 +88,6 @@ default ProcedureCall makeProcedureCall(SessionImplementor session) {
|
||||
ProcedureCall makeProcedureCall(SharedSessionContractImplementor session, Class<?>... resultSetJavaTypes);
|
||||
|
||||
interface ParameterMemento extends NamedQueryMemento.ParameterMemento {
|
||||
ProcedureParameterImplementor resolve(SharedSessionContractImplementor session);
|
||||
ProcedureParameterImplementor<?> resolve(SharedSessionContractImplementor session);
|
||||
}
|
||||
}
|
||||
|
@ -13,6 +13,7 @@
|
||||
*
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
@FunctionalInterface
|
||||
public interface ResultSetMappingResolutionContext {
|
||||
SessionFactoryImplementor getSessionFactory();
|
||||
}
|
||||
|
@ -175,7 +175,7 @@ public void addAffectedTableNames(Set<String> affectedTableNames, SessionFactory
|
||||
return;
|
||||
}
|
||||
|
||||
Collections.addAll( affectedTableNames, (String[]) entityDescriptor.getQuerySpaces());
|
||||
Collections.addAll( affectedTableNames, (String[]) entityDescriptor.getQuerySpaces() );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -16,7 +16,6 @@
|
||||
import org.hibernate.sql.ast.tree.expression.Expression;
|
||||
import org.hibernate.sql.results.jdbc.spi.JdbcValuesMetadata;
|
||||
import org.hibernate.type.descriptor.ValueExtractor;
|
||||
import org.hibernate.type.descriptor.java.JavaType;
|
||||
import org.hibernate.type.spi.TypeConfiguration;
|
||||
|
||||
/**
|
||||
@ -51,7 +50,6 @@ public ValueExtractor getJdbcValueExtractor() {
|
||||
public SqlSelection createSqlSelection(
|
||||
int jdbcPosition,
|
||||
int valuesArrayPosition,
|
||||
JavaType javaType,
|
||||
TypeConfiguration typeConfiguration) {
|
||||
return this;
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ public NamedNativeQueryMementoImpl(
|
||||
String name,
|
||||
String sqlString,
|
||||
String resultSetMappingName,
|
||||
Class resultSetMappingClass,
|
||||
Class<?> resultSetMappingClass,
|
||||
Set<String> querySpaces,
|
||||
Boolean cacheable,
|
||||
String cacheRegion,
|
||||
|
@ -609,8 +609,8 @@ protected List<R> doList() {
|
||||
}
|
||||
|
||||
private SelectQueryPlan<R> resolveSelectQueryPlan() {
|
||||
final QueryInterpretationCache.Key cacheKey = generateSelectInterpretationsKey( resultSetMapping );
|
||||
if ( cacheKey != null ) {
|
||||
if ( isCacheableQuery() ) {
|
||||
final QueryInterpretationCache.Key cacheKey = generateSelectInterpretationsKey( resultSetMapping );
|
||||
return getSession().getFactory().getQueryEngine().getInterpretationCache()
|
||||
.resolveSelectQueryPlan( cacheKey, () -> createQueryPlan( resultSetMapping ) );
|
||||
}
|
||||
@ -790,10 +790,6 @@ public static int determineBindValueMaxCount(boolean paddingEnabled, int inExprL
|
||||
}
|
||||
|
||||
private SelectInterpretationsKey generateSelectInterpretationsKey(JdbcValuesMappingProducer resultSetMapping) {
|
||||
if ( !isCacheable( this ) ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return new SelectInterpretationsKey(
|
||||
getQueryString(),
|
||||
resultSetMapping,
|
||||
@ -803,7 +799,7 @@ private SelectInterpretationsKey generateSelectInterpretationsKey(JdbcValuesMapp
|
||||
);
|
||||
}
|
||||
|
||||
private static boolean isCacheable(NativeQueryImpl<?> query) {
|
||||
private boolean isCacheableQuery() {
|
||||
// todo (6.0): unless we move the limit rendering from DeferredResultSetAccess to NativeSelectQueryPlanImpl
|
||||
// we don't need to consider the limit here at all because that is applied on demand.
|
||||
// It certainly is better for performance to include the limit early, but then we might trash the cache
|
||||
@ -812,7 +808,7 @@ private static boolean isCacheable(NativeQueryImpl<?> query) {
|
||||
// }
|
||||
|
||||
// For now, don't cache plans that have parameter lists
|
||||
return !query.parameterBindings.hasAnyMultiValuedBindings();
|
||||
return !parameterBindings.hasAnyMultiValuedBindings();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -845,15 +841,10 @@ private NonSelectQueryPlan resolveNonSelectQueryPlan() {
|
||||
|
||||
|
||||
protected NonSelectInterpretationsKey generateNonSelectInterpretationsKey() {
|
||||
if ( !isCacheable( this ) ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// todo (6.0) - should this account for query-spaces in determining "cacheable"?
|
||||
return new NonSelectInterpretationsKey(
|
||||
getQueryString(),
|
||||
getSynchronizedQuerySpaces()
|
||||
);
|
||||
// todo (6.0) - should this account for query spaces in determining "cacheable"?
|
||||
return isCacheableQuery()
|
||||
? new NonSelectInterpretationsKey( getQueryString(), getSynchronizedQuerySpaces() )
|
||||
: null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -880,7 +871,8 @@ public NativeQuery<R> addScalar(String columnAlias, @SuppressWarnings("rawtypes"
|
||||
return registerBuilder(
|
||||
Builders.scalar(
|
||||
columnAlias,
|
||||
getSessionFactory().getTypeConfiguration().getBasicTypeRegistry().resolve( type )
|
||||
getSessionFactory().getTypeConfiguration().getBasicTypeRegistry()
|
||||
.resolve( (BasicTypeReference<?>) type )
|
||||
)
|
||||
);
|
||||
}
|
||||
@ -1475,7 +1467,7 @@ public NativeQueryImplementor<R> setProperties(Object bean) {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override @Deprecated
|
||||
@Override @Deprecated @SuppressWarnings("deprecation")
|
||||
public <S> NativeQueryImplementor<S> setResultTransformer(ResultTransformer<S> transformer) {
|
||||
return setTupleTransformer( transformer ).setResultListTransformer( transformer );
|
||||
}
|
||||
|
@ -8,7 +8,6 @@
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
@ -30,7 +29,6 @@
|
||||
import org.hibernate.persister.collection.QueryableCollection;
|
||||
import org.hibernate.persister.collection.SQLLoadableCollection;
|
||||
import org.hibernate.persister.entity.EntityPersister;
|
||||
import org.hibernate.persister.entity.Joinable;
|
||||
import org.hibernate.persister.entity.Loadable;
|
||||
import org.hibernate.persister.entity.SQLLoadable;
|
||||
import org.hibernate.query.NativeQuery;
|
||||
@ -47,7 +45,6 @@
|
||||
import org.hibernate.type.EntityType;
|
||||
import org.hibernate.type.Type;
|
||||
|
||||
import static org.hibernate.internal.util.collections.ArrayHelper.EMPTY_STRING_ARRAY;
|
||||
|
||||
/**
|
||||
* Responsible for processing the {@link ResultSetMapping} defined by a
|
||||
@ -457,7 +454,7 @@ private String generateCollectionSuffix() {
|
||||
|
||||
private void processReturn(NativeQuery.ResultNode rtn) {
|
||||
if ( rtn instanceof NativeQuery.RootReturn ) {
|
||||
processRootReturn( ( NativeQuery.RootReturn ) rtn );
|
||||
processRootReturn( (NativeQuery.RootReturn) rtn );
|
||||
}
|
||||
else if ( rtn instanceof NativeQuery.FetchReturn ) {
|
||||
processFetchReturn( (NativeQuery.FetchReturn) rtn );
|
||||
@ -466,9 +463,10 @@ else if ( rtn instanceof NativeQuery.InstantiationResultNode<?> ) {
|
||||
processConstructorReturn( (NativeQuery.InstantiationResultNode<?>) rtn );
|
||||
}
|
||||
else if ( rtn instanceof NativeQuery.ReturnProperty ) {
|
||||
processScalarReturn( ( NativeQuery.ReturnProperty ) rtn );
|
||||
processScalarReturn( (NativeQuery.ReturnProperty) rtn );
|
||||
}
|
||||
else if ( rtn instanceof NativeQuery.ReturnableResultNode ) {
|
||||
processPropertyReturn( (NativeQuery.ReturnableResultNode) rtn );
|
||||
}
|
||||
else {
|
||||
throw new IllegalStateException(
|
||||
@ -477,8 +475,12 @@ else if ( rtn instanceof NativeQuery.ReturnableResultNode ) {
|
||||
}
|
||||
}
|
||||
|
||||
private void processConstructorReturn(NativeQuery.InstantiationResultNode<?> rtn) {
|
||||
private void processPropertyReturn(NativeQuery.ReturnableResultNode rtn) {
|
||||
//nothing to do
|
||||
}
|
||||
|
||||
private void processConstructorReturn(NativeQuery.InstantiationResultNode<?> rtn) {
|
||||
//nothing to do
|
||||
}
|
||||
|
||||
private void processScalarReturn(NativeQuery.ReturnProperty typeReturn) {
|
||||
@ -613,22 +615,22 @@ public Map<String, String[]> getPropertyResultsMap(String alias) {
|
||||
return internalGetPropertyResultsMap( alias );
|
||||
}
|
||||
|
||||
public String[] collectQuerySpaces() {
|
||||
final HashSet<String> spaces = new HashSet<>();
|
||||
collectQuerySpaces( spaces );
|
||||
return spaces.toArray( EMPTY_STRING_ARRAY );
|
||||
}
|
||||
|
||||
public void collectQuerySpaces(Collection<String> spaces) {
|
||||
for ( EntityPersister persister : alias2Persister.values() ) {
|
||||
Collections.addAll( spaces, (String[]) persister.getQuerySpaces() );
|
||||
}
|
||||
for ( CollectionPersister persister : alias2CollectionPersister.values() ) {
|
||||
final Type elementType = persister.getElementType();
|
||||
if ( elementType.isEntityType() && ! elementType.isAnyType() ) {
|
||||
final Joinable joinable = ( (EntityType) elementType ).getAssociatedJoinable( factory );
|
||||
Collections.addAll( spaces, (String[]) ( (EntityPersister) joinable ).getQuerySpaces() );
|
||||
}
|
||||
}
|
||||
}
|
||||
// public String[] collectQuerySpaces() {
|
||||
// final HashSet<String> spaces = new HashSet<>();
|
||||
// collectQuerySpaces( spaces );
|
||||
// return spaces.toArray( EMPTY_STRING_ARRAY );
|
||||
// }
|
||||
//
|
||||
// public void collectQuerySpaces(Collection<String> spaces) {
|
||||
// for ( EntityPersister persister : alias2Persister.values() ) {
|
||||
// Collections.addAll( spaces, (String[]) persister.getQuerySpaces() );
|
||||
// }
|
||||
// for ( CollectionPersister persister : alias2CollectionPersister.values() ) {
|
||||
// final Type elementType = persister.getElementType();
|
||||
// if ( elementType.isEntityType() && ! elementType.isAnyType() ) {
|
||||
// final Joinable joinable = ( (EntityType) elementType ).getAssociatedJoinable( factory );
|
||||
// Collections.addAll( spaces, (String[]) ( (EntityPersister) joinable ).getQuerySpaces() );
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
@ -16,7 +16,6 @@
|
||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
||||
import org.hibernate.query.named.AbstractNamedQueryMemento;
|
||||
import org.hibernate.query.named.NamedQueryMemento;
|
||||
import org.hibernate.query.spi.QueryImplementor;
|
||||
import org.hibernate.query.sql.internal.NamedNativeQueryMementoImpl;
|
||||
|
||||
/**
|
||||
|
@ -89,17 +89,12 @@ protected FunctionRenderingSupport getRenderer() {
|
||||
public SqlSelection createSqlSelection(
|
||||
int jdbcPosition,
|
||||
int valuesArrayPosition,
|
||||
JavaType javaType,
|
||||
TypeConfiguration typeConfiguration) {
|
||||
return new SqlSelectionImpl(
|
||||
jdbcPosition,
|
||||
valuesArrayPosition,
|
||||
this
|
||||
);
|
||||
return new SqlSelectionImpl( jdbcPosition, valuesArrayPosition, this );
|
||||
}
|
||||
|
||||
@Override
|
||||
public DomainResult createDomainResult(
|
||||
public DomainResult<?> createDomainResult(
|
||||
String resultVariable,
|
||||
DomainResultCreationState creationState) {
|
||||
final JdbcMapping jdbcMapping = getJdbcMapping();
|
||||
@ -119,7 +114,8 @@ public DomainResult createDomainResult(
|
||||
this,
|
||||
jdbcJavaType,
|
||||
null,
|
||||
creationState.getSqlAstCreationState().getCreationContext().getMappingMetamodel().getTypeConfiguration()
|
||||
creationState.getSqlAstCreationState().getCreationContext()
|
||||
.getMappingMetamodel().getTypeConfiguration()
|
||||
)
|
||||
.getValuesArrayPosition(),
|
||||
resultVariable,
|
||||
|
@ -18,7 +18,6 @@
|
||||
import java.util.Set;
|
||||
import java.util.function.Function;
|
||||
|
||||
import org.hibernate.NotYetImplementedFor6Exception;
|
||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
||||
import org.hibernate.internal.util.collections.CollectionHelper;
|
||||
@ -290,20 +289,17 @@ else if ( domainParamBinding.getBindValue() == null ) {
|
||||
}
|
||||
else {
|
||||
final JdbcMapping jdbcMapping;
|
||||
final BasicValueConverter valueConverter;
|
||||
if ( domainParamBinding.getType() instanceof JdbcMapping ) {
|
||||
jdbcMapping = (JdbcMapping) domainParamBinding.getType();
|
||||
valueConverter = jdbcMapping.getValueConverter();
|
||||
}
|
||||
else if ( domainParamBinding.getBindType() instanceof BasicValuedModelPart ) {
|
||||
jdbcMapping = ( (BasicValuedModelPart) domainParamBinding.getType() ).getJdbcMapping();
|
||||
valueConverter = jdbcMapping.getValueConverter();
|
||||
}
|
||||
else {
|
||||
jdbcMapping = null;
|
||||
valueConverter = null;
|
||||
}
|
||||
|
||||
final BasicValueConverter valueConverter = jdbcMapping == null ? null : jdbcMapping.getValueConverter();
|
||||
if ( valueConverter != null ) {
|
||||
final Object convertedValue = valueConverter.toRelationalValue( domainParamBinding.getBindValue() );
|
||||
|
||||
|
@ -1692,13 +1692,9 @@ private String getCteName(SqmCteTable<?> sqmCteTable) {
|
||||
if ( generatedCteName != null ) {
|
||||
return generatedCteName;
|
||||
}
|
||||
final String cteName;
|
||||
if ( name != null ) {
|
||||
cteName = generateCteName( name );
|
||||
}
|
||||
else {
|
||||
cteName = generateCteName( "cte" + cteNameMapping.size() );
|
||||
}
|
||||
final String cteName = name != null
|
||||
? generateCteName( name )
|
||||
: generateCteName( "cte" + cteNameMapping.size() );
|
||||
cteNameMapping.put( key, cteName );
|
||||
return cteName;
|
||||
}
|
||||
@ -4072,18 +4068,16 @@ public Object visitFkExpression(SqmFkExpression<?> fkExpression) {
|
||||
final EmbeddableValuedModelPart compositeFkPart = (EmbeddableValuedModelPart) fkKeyPart;
|
||||
final List<JdbcMapping> jdbcMappings = compositeFkPart.getJdbcMappings();
|
||||
final List<Expression> tupleElements = new ArrayList<>( jdbcMappings.size() );
|
||||
compositeFkPart.forEachSelectable( (position, selectable) -> {
|
||||
tupleElements.add(
|
||||
getSqlExpressionResolver().resolveSqlExpression(
|
||||
createColumnReferenceKey( tableReference, selectable.getSelectionExpression() ),
|
||||
(sqlAstProcessingState) -> new ColumnReference(
|
||||
tableReference,
|
||||
selectable,
|
||||
creationContext.getSessionFactory()
|
||||
)
|
||||
)
|
||||
);
|
||||
} );
|
||||
compositeFkPart.forEachSelectable( (position, selectable) -> tupleElements.add(
|
||||
getSqlExpressionResolver().resolveSqlExpression(
|
||||
createColumnReferenceKey( tableReference, selectable.getSelectionExpression() ),
|
||||
(sqlAstProcessingState) -> new ColumnReference(
|
||||
tableReference,
|
||||
selectable,
|
||||
creationContext.getSessionFactory()
|
||||
)
|
||||
)
|
||||
) );
|
||||
|
||||
return new SqlTuple( tupleElements, compositeFkPart );
|
||||
}
|
||||
@ -4652,9 +4646,7 @@ else if ( modelPart instanceof EmbeddableValuedModelPart ) {
|
||||
if ( jdbcTypeCount == 1 ) {
|
||||
return new SelfRenderingFunctionSqlAstExpression(
|
||||
pathName,
|
||||
(sqlAppender, sqlAstArguments, walker) -> {
|
||||
sqlAstArguments.get( 0 ).accept( walker );
|
||||
},
|
||||
(sqlAppender, sqlAstArguments, walker) -> sqlAstArguments.get( 0 ).accept( walker ),
|
||||
resultColumnReferences,
|
||||
(ReturnableType<?>) resultColumnReferences.get( 0 ).getJdbcMapping(),
|
||||
resultColumnReferences.get( 0 ).getJdbcMapping()
|
||||
@ -4676,9 +4668,7 @@ else if ( modelPart instanceof EmbeddableValuedModelPart ) {
|
||||
.getSqlSelections();
|
||||
return new SelfRenderingFunctionSqlAstExpression(
|
||||
pathName,
|
||||
(sqlAppender, sqlAstArguments, walker) -> {
|
||||
sqlAstArguments.get( 0 ).accept( walker );
|
||||
},
|
||||
(sqlAppender, sqlAstArguments, walker) -> sqlAstArguments.get( 0 ).accept( walker ),
|
||||
Collections.singletonList(
|
||||
new ColumnReference(
|
||||
identifierVariable,
|
||||
@ -5131,7 +5121,7 @@ protected Expression consumeSqmParameter(SqmParameter<?> sqmParameter) {
|
||||
}
|
||||
|
||||
final Collection<?> bindValues = domainParamBinding.getBindValues();
|
||||
final List<Expression> expressions = new ArrayList<>( bindValues.size());
|
||||
final List<Expression> expressions = new ArrayList<>( bindValues.size() );
|
||||
boolean first = true;
|
||||
for ( Object bindValue : bindValues ) {
|
||||
final SqmParameter<?> sqmParamToConsume;
|
||||
@ -5366,7 +5356,7 @@ else if ( paramType instanceof EntityDomainType ) {
|
||||
}
|
||||
|
||||
if ( paramSqmType instanceof AnyDiscriminatorSqmPathSource ) {
|
||||
return (MappingModelExpressible<?>) ((AnyDiscriminatorSqmPathSource)paramSqmType).getSqmPathType();
|
||||
return (MappingModelExpressible<?>) ((AnyDiscriminatorSqmPathSource<?>) paramSqmType).getSqmPathType();
|
||||
}
|
||||
|
||||
if ( paramSqmType instanceof SqmPathSource<?> || paramSqmType instanceof BasicDomainType<?> ) {
|
||||
@ -5894,15 +5884,13 @@ else if ( rhs != expression.getRightHandOperand() ) {
|
||||
final SqlExpressionResolver resolver = getSqlAstCreationState().getSqlExpressionResolver();
|
||||
final TableReference tableReference = tableGroup.getPrimaryTableReference();
|
||||
valueMapping.forEachSelectable(
|
||||
(selectionIndex, selection) -> {
|
||||
resolver.resolveSqlExpression(
|
||||
SqlExpressionResolver.createColumnReferenceKey(
|
||||
tableReference,
|
||||
selection.getSelectionExpression()
|
||||
),
|
||||
processingState -> (Expression) (selectionIndex == 0 ? result : offset)
|
||||
);
|
||||
}
|
||||
(selectionIndex, selection) -> resolver.resolveSqlExpression(
|
||||
SqlExpressionResolver.createColumnReferenceKey(
|
||||
tableReference,
|
||||
selection.getSelectionExpression()
|
||||
),
|
||||
processingState -> (Expression) (selectionIndex == 0 ? result : offset)
|
||||
)
|
||||
);
|
||||
return new EmbeddableValuedPathInterpretation<>(
|
||||
new SqlTuple( List.of( (Expression) result, (Expression) offset ), valueMapping ),
|
||||
@ -6443,9 +6431,9 @@ public Expression visitEntityTypeLiteralExpression(SqmLiteralEntityType<?> sqmEx
|
||||
|
||||
@Override
|
||||
public Expression visitAnyDiscriminatorTypeValueExpression(SqmAnyDiscriminatorValue expression) {
|
||||
final BasicType domainType = expression.getDomainType();
|
||||
final BasicType<?> domainType = expression.getDomainType();
|
||||
return new QueryLiteral<>(
|
||||
domainType.getValueConverter().toRelationalValue( expression.getEntityValue().getJavaType() ),
|
||||
domainType.convertToRelationalValue( expression.getEntityValue().getJavaType() ),
|
||||
domainType
|
||||
);
|
||||
}
|
||||
@ -6456,39 +6444,32 @@ public Expression visitParameterizedEntityTypeExpression(SqmParameterizedEntityT
|
||||
return (Expression) sqmExpression.getDiscriminatorSource().accept( this );
|
||||
}
|
||||
|
||||
@SuppressWarnings({"raw","unchecked"})
|
||||
@Override
|
||||
public Object visitEnumLiteral(SqmEnumLiteral<?> sqmEnumLiteral) {
|
||||
final BasicValuedMapping inferrableType = (BasicValuedMapping) resolveInferredType();
|
||||
if ( inferrableType != null ) {
|
||||
final BasicValueConverter<Enum<?>,?> valueConverter = (BasicValueConverter<Enum<?>, ?>) inferrableType.getJdbcMapping().getValueConverter();
|
||||
final Object jdbcValue;
|
||||
if ( valueConverter == null ) {
|
||||
jdbcValue = sqmEnumLiteral.getEnumValue();
|
||||
}
|
||||
else {
|
||||
jdbcValue = valueConverter.toRelationalValue( sqmEnumLiteral.getEnumValue() );
|
||||
}
|
||||
final Object jdbcValue = inferrableType.getJdbcMapping().convertToRelationalValue( sqmEnumLiteral.getEnumValue() );
|
||||
return new QueryLiteral<>( jdbcValue, inferrableType );
|
||||
}
|
||||
else {
|
||||
// This can only happen when selecting an enum literal, in which case we default to ordinal encoding
|
||||
final EnumJavaType<?> enumJtd = sqmEnumLiteral.getExpressibleJavaType();
|
||||
final TypeConfiguration typeConfiguration = getTypeConfiguration();
|
||||
final JdbcType jdbcType = typeConfiguration.getJdbcTypeRegistry().getDescriptor( SqlTypes.SMALLINT );
|
||||
final JavaType<Number> relationalJtd = typeConfiguration.getJavaTypeRegistry().getDescriptor( Integer.class );
|
||||
|
||||
// This can only happen when selecting an enum literal, in which case we default to ordinal encoding
|
||||
final EnumJavaType<?> enumJtd = sqmEnumLiteral.getExpressibleJavaType();
|
||||
final TypeConfiguration typeConfiguration = getTypeConfiguration();
|
||||
final JdbcType jdbcType = typeConfiguration.getJdbcTypeRegistry().getDescriptor( SqlTypes.SMALLINT );
|
||||
final JavaType<Number> relationalJtd = typeConfiguration.getJavaTypeRegistry().getDescriptor( Integer.class );
|
||||
|
||||
return new QueryLiteral<>(
|
||||
sqmEnumLiteral.getEnumValue().ordinal(),
|
||||
new CustomType<>(
|
||||
new EnumType<>(
|
||||
enumJtd.getJavaTypeClass(),
|
||||
new OrdinalEnumValueConverter<>( enumJtd, jdbcType, relationalJtd ),
|
||||
typeConfiguration
|
||||
),
|
||||
typeConfiguration
|
||||
)
|
||||
);
|
||||
return new QueryLiteral<>(
|
||||
sqmEnumLiteral.getEnumValue().ordinal(),
|
||||
new CustomType<>(
|
||||
new EnumType<>(
|
||||
enumJtd.getJavaTypeClass(),
|
||||
new OrdinalEnumValueConverter<>( enumJtd, jdbcType, relationalJtd ),
|
||||
typeConfiguration
|
||||
),
|
||||
typeConfiguration
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -18,7 +18,6 @@
|
||||
import org.hibernate.sql.ast.tree.from.TableGroup;
|
||||
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;
|
||||
|
||||
/**
|
||||
@ -53,7 +52,6 @@ public EntityDiscriminatorMapping getExpressionType() {
|
||||
public SqlSelection createSqlSelection(
|
||||
int jdbcPosition,
|
||||
int valuesArrayPosition,
|
||||
JavaType javaType,
|
||||
TypeConfiguration typeConfiguration) {
|
||||
return new ResultSetMappingSqlSelection( valuesArrayPosition, getDiscriminatorMapping() );
|
||||
}
|
||||
|
@ -124,7 +124,6 @@ else if ( fetchParent != null ) {
|
||||
final SqlSelection sqlSelection = expression.createSqlSelection(
|
||||
valuesArrayPosition + 1,
|
||||
valuesArrayPosition,
|
||||
javaType,
|
||||
typeConfiguration
|
||||
);
|
||||
|
||||
|
@ -7,7 +7,6 @@
|
||||
package org.hibernate.sql.ast.spi;
|
||||
|
||||
import org.hibernate.sql.results.jdbc.spi.RowProcessingState;
|
||||
import org.hibernate.type.descriptor.java.JavaType;
|
||||
import org.hibernate.type.spi.TypeConfiguration;
|
||||
|
||||
/**
|
||||
@ -16,15 +15,12 @@
|
||||
public interface SqlSelectionProducer {
|
||||
/**
|
||||
* Create a SqlSelection for the given JDBC ResultSet position
|
||||
*
|
||||
* @param jdbcPosition The index position used to read values from JDBC
|
||||
* @param jdbcPosition The index position used to read values from JDBC
|
||||
* @param valuesArrayPosition The position in our {@linkplain RowProcessingState#getJdbcValue(SqlSelection) "current JDBC values array"}
|
||||
* @param javaType The descriptor for the Java type to read the value as
|
||||
* @param typeConfiguration The associated TypeConfiguration
|
||||
*/
|
||||
SqlSelection createSqlSelection(
|
||||
int jdbcPosition,
|
||||
int valuesArrayPosition,
|
||||
JavaType javaType,
|
||||
TypeConfiguration typeConfiguration);
|
||||
}
|
||||
|
@ -11,7 +11,6 @@
|
||||
import org.hibernate.sql.ast.spi.SqlSelectionProducer;
|
||||
import org.hibernate.sql.ast.tree.SqlAstNode;
|
||||
import org.hibernate.sql.results.internal.SqlSelectionImpl;
|
||||
import org.hibernate.type.descriptor.java.JavaType;
|
||||
import org.hibernate.type.spi.TypeConfiguration;
|
||||
|
||||
/**
|
||||
@ -33,12 +32,7 @@ default ColumnReference getColumnReference() {
|
||||
default SqlSelection createSqlSelection(
|
||||
int jdbcPosition,
|
||||
int valuesArrayPosition,
|
||||
JavaType javaType,
|
||||
TypeConfiguration typeConfiguration) {
|
||||
return new SqlSelectionImpl(
|
||||
jdbcPosition,
|
||||
valuesArrayPosition,
|
||||
this
|
||||
);
|
||||
return new SqlSelectionImpl( jdbcPosition, valuesArrayPosition, this );
|
||||
}
|
||||
}
|
||||
|
@ -18,7 +18,6 @@
|
||||
import org.hibernate.sql.ast.tree.expression.Expression;
|
||||
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;
|
||||
|
||||
/**
|
||||
@ -47,14 +46,8 @@ public ColumnReference getColumnReference() {
|
||||
public SqlSelection createSqlSelection(
|
||||
int jdbcPosition,
|
||||
int valuesArrayPosition,
|
||||
JavaType javaType,
|
||||
TypeConfiguration typeConfiguration) {
|
||||
return getTableGroup().createSqlSelection(
|
||||
jdbcPosition,
|
||||
valuesArrayPosition,
|
||||
javaType,
|
||||
typeConfiguration
|
||||
);
|
||||
return getTableGroup().createSqlSelection( jdbcPosition, valuesArrayPosition, typeConfiguration );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -25,7 +25,6 @@
|
||||
import org.hibernate.sql.exec.spi.JdbcParameterBinding;
|
||||
import org.hibernate.sql.exec.spi.JdbcParameterBindings;
|
||||
import org.hibernate.sql.results.internal.SqlSelectionImpl;
|
||||
import org.hibernate.type.descriptor.java.JavaType;
|
||||
import org.hibernate.type.spi.TypeConfiguration;
|
||||
|
||||
/**
|
||||
@ -59,17 +58,12 @@ public void accept(SqlAstWalker sqlTreeWalker) {
|
||||
public SqlSelection createSqlSelection(
|
||||
int jdbcPosition,
|
||||
int valuesArrayPosition,
|
||||
JavaType javaType,
|
||||
TypeConfiguration typeConfiguration) {
|
||||
// todo (6.0) : investigate "virtual" or "static" selections
|
||||
// - anything that is the same for each row always - parameter, literal, etc;
|
||||
// the idea would be to write the value directly into the JdbcValues array
|
||||
// and not generating a SQL selection in the query sent to DB
|
||||
return new SqlSelectionImpl(
|
||||
jdbcPosition,
|
||||
valuesArrayPosition,
|
||||
this
|
||||
);
|
||||
return new SqlSelectionImpl( jdbcPosition, valuesArrayPosition, this );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -49,7 +49,7 @@ public BasicArrayType(BasicType<T> baseDescriptor, JdbcType arrayJdbcType, JavaT
|
||||
//noinspection unchecked
|
||||
final BasicValueConverter<T, Object> valueConverter = (BasicValueConverter<T, Object>) baseDescriptor.getValueConverter();
|
||||
if ( valueConverter != null ) {
|
||||
this.jdbcValueBinder = new ValueBinder<T[]>() {
|
||||
this.jdbcValueBinder = new ValueBinder<>() {
|
||||
@Override
|
||||
public void bind(PreparedStatement st, T[] value, int index, WrapperOptions options)
|
||||
throws SQLException {
|
||||
|
Loading…
x
Reference in New Issue
Block a user