HHH-11092 - NamedNativeQueries ordinal parameters are zero based

This commit is contained in:
Andrea Boriero 2016-09-23 13:47:39 +01:00
parent f8f5486fda
commit 30165d4aef
3 changed files with 20 additions and 2 deletions

View File

@ -151,7 +151,7 @@ public class HQLQueryPlan implements Serializable {
}
public ParameterMetadataImpl getParameterMetadata() {
return parameterMetadata;
return parameterMetadata.getOrdinalParametersZeroBasedCopy();
}
public ReturnMetadata getReturnMetadata() {

View File

@ -727,7 +727,9 @@ public abstract class AbstractSharedSessionContract implements SharedSessionCont
@Override
public QueryImplementor createNamedQuery(String name) {
return buildQueryFromName( name, null );
final QueryImplementor<Object> query = buildQueryFromName( name, null );
query.getParameterMetadata().setOrdinalParametersZeroBased( false );
return query;
}
protected <T> QueryImplementor<T> buildQueryFromName(String name, Class<T> resultType) {

View File

@ -33,6 +33,14 @@ public class ParameterMetadataImpl implements ParameterMetadata {
private final Map<String,NamedParameterDescriptor> namedDescriptorMap;
private boolean isOrdinalParametersZeroBased = true;
private ParameterMetadataImpl(
OrdinalParameterDescriptor[] ordinalDescriptors,
Map<String, NamedParameterDescriptor> namedDescriptorMap, boolean isOrdinalParametersZeroBased) {
this.ordinalDescriptors = ordinalDescriptors;
this.namedDescriptorMap = namedDescriptorMap;
this.isOrdinalParametersZeroBased = isOrdinalParametersZeroBased;
}
/**
* Instantiates a ParameterMetadata container.
*
@ -252,4 +260,12 @@ public class ParameterMetadataImpl implements ParameterMetadata {
public void setOrdinalParametersZeroBased(boolean isZeroBased) {
this.isOrdinalParametersZeroBased = isZeroBased;
}
public ParameterMetadataImpl getOrdinalParametersZeroBasedCopy() {
return new ParameterMetadataImpl(
this.ordinalDescriptors,
this.namedDescriptorMap,
true
);
}
}