Skip to content

Commit bf1eec6

Browse files
committed
minor fixes to generic types in QueryParameterBinding
gets rid of some warnings
1 parent 537953e commit bf1eec6

File tree

3 files changed

+11
-16
lines changed

3 files changed

+11
-16
lines changed

hibernate-core/src/main/java/org/hibernate/procedure/spi/ProcedureCallImplementor.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,7 @@ default List<R> getResultList() {
3737
ProcedureParameterMetadataImplementor getParameterMetadata();
3838

3939
@Override
40-
default R getSingleResult() {
41-
return uniqueResult();
42-
}
40+
R getSingleResult();
4341

4442
@Override
4543
ProcedureCallImplementor<R> registerStoredProcedureParameter(int position, BasicTypeReference<?> type, ParameterMode mode);

hibernate-core/src/main/java/org/hibernate/query/internal/QueryParameterBindingImpl.java

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public class QueryParameterBindingImpl<T> implements QueryParameterBinding<T>, J
4141
private TemporalType explicitTemporalPrecision;
4242

4343
private T bindValue;
44-
private Collection<T> bindValues;
44+
private Collection<? extends T> bindValues;
4545

4646
// todo (6.0) : add TemporalType to QueryParameter and use to default precision here
4747

@@ -164,8 +164,7 @@ private void bindValue(T value) {
164164

165165
if ( bindType == null ) {
166166
if ( value != null ) {
167-
//noinspection unchecked
168-
this.bindType = (AllowableParameterType<T>) typeResolver.resolveParameterBindType( value );
167+
this.bindType = typeResolver.resolveParameterBindType( value );
169168
}
170169
}
171170
}
@@ -239,7 +238,7 @@ else if ( queryParameter.getHibernateType() != null ) {
239238
// multi-valued binding support
240239

241240
@Override
242-
public Collection<T> getBindValues() {
241+
public Collection<? extends T> getBindValues() {
243242
if ( !isMultiValued ) {
244243
throw new IllegalStateException( "Binding is not multi-valued; illegal call to #getBindValues" );
245244
}
@@ -253,8 +252,7 @@ public void setBindValues(Collection<? extends T> values) {
253252
this.isMultiValued = true;
254253

255254
this.bindValue = null;
256-
//noinspection unchecked
257-
this.bindValues = (Collection<T>) values;
255+
this.bindValues = values;
258256

259257
final Iterator<? extends T> iterator = values.iterator();
260258
T value = null;
@@ -263,8 +261,7 @@ public void setBindValues(Collection<? extends T> values) {
263261
}
264262

265263
if ( bindType == null && value != null ) {
266-
//noinspection unchecked
267-
this.bindType = (AllowableParameterType<T>) typeResolver.resolveParameterBindType( value );
264+
this.bindType = typeResolver.resolveParameterBindType( value );
268265
}
269266

270267
}
@@ -300,12 +297,12 @@ private void setExplicitTemporalPrecision(TemporalType temporalTypePrecision) {
300297
}
301298

302299
@Override
303-
public MappingModelExpressable getType() {
300+
public MappingModelExpressable<T> getType() {
304301
return type;
305302
}
306303

307-
@Override
308-
public boolean setType(MappingModelExpressable type) {
304+
@Override @SuppressWarnings("unchecked")
305+
public boolean setType(MappingModelExpressable<T> type) {
309306
this.type = type;
310307
if ( bindType == null || bindType.getJavaType() == Object.class ) {
311308
if ( type instanceof AllowableParameterType<?> ) {
@@ -329,7 +326,7 @@ private void validate(T value) {
329326
QueryParameterBindingValidator.INSTANCE.validate( getBindType(), value );
330327
}
331328

332-
private void validate(T value, AllowableParameterType clarifiedType) {
329+
private void validate(T value, AllowableParameterType<?> clarifiedType) {
333330
QueryParameterBindingValidator.INSTANCE.validate( clarifiedType, value );
334331
}
335332

hibernate-core/src/main/java/org/hibernate/query/spi/QueryParameterBinding.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ default void setBindValue(T value) {
108108
*
109109
* @return The currently bound values
110110
*/
111-
Collection<T> getBindValues();
111+
Collection<? extends T> getBindValues();
112112

113113
/**
114114
* Returns the inferred mapping model expressable i.e. the model reference against which this parameter is compared.

0 commit comments

Comments
 (0)