SpringBoot 2.5.1
SimpleJpaRepository.deleteAllByIdInBatch(Iterable<ID> ids)
accepts Iterable
, but in deep QueryParameterBindingValidator.validate
checking against for Collection
.
public <P> void validate(Type paramType, Object bind, TemporalType temporalType) {
if ( bind == null || paramType == null ) {
// nothing we can check
return;
}
final Class parameterType = paramType.getReturnedClass();
if ( parameterType == null ) {
// nothing we can check
return;
}
if ( Collection.class.isInstance( bind ) && !Collection.class.isAssignableFrom( parameterType ) ) {
// we have a collection passed in where we are expecting a non-collection.
// NOTE : this can happen in Hibernate's notion of "parameter list" binding
// NOTE2 : the case of a collection value and an expected collection (if that can even happen)
// will fall through to the main check.
validateCollectionValuedParameterBinding( parameterType, (Collection) bind, temporalType );
}
else if ( bind.getClass().isArray() ) {
validateArrayValuedParameterBinding( parameterType, bind, temporalType );
}
else {
if ( !isValidBindValue( parameterType, bind, temporalType ) ) {
throw new IllegalArgumentException(
String.format(
"Parameter value [%s] did not match expected type [%s (%s)]",
bind,
parameterType.getName(),
extractName( temporalType )
)
);
}
}
}
If calling SimpleJpaRepository.deleteAllByIdInBatch
with Iterable
but this class not implement Collection
we got exception.
Caused by: java.lang.IllegalArgumentException: Parameter value [xxx] did not match expected type [java.util.UUID (n/a)]
at org.hibernate.query.spi.QueryParameterBindingValidator.validate(QueryParameterBindingValidator.java:54)
at org.hibernate.query.spi.QueryParameterBindingValidator.validate(QueryParameterBindingValidator.java:27)
at org.hibernate.query.internal.QueryParameterBindingImpl.validate(QueryParameterBindingImpl.java:90)
at org.hibernate.query.internal.QueryParameterBindingImpl.setBindValue(QueryParameterBindingImpl.java:55)
at org.hibernate.query.internal.AbstractProducedQuery.setParameter(AbstractProducedQuery.java:494)
at org.hibernate.query.internal.AbstractProducedQuery.setParameter(AbstractProducedQuery.java:115)
at org.springframework.data.jpa.repository.support.SimpleJpaRepository.deleteAllByIdInBatch(SimpleJpaRepository.java:229)
Comment From: snicoll
@onlyonce thanks for the report but Spring Data JPA has a dedicated issue tracker. I think the team will need more than an exception to investigate this so consider preparing a small sample before reporting this at the appropriate place.
Comment From: onlyonce
OK, thx, sorry