Skip to content

Commit

Permalink
Fix CoercionException conversion to IllegalArgumentException for Quer…
Browse files Browse the repository at this point in the history
…y parameter binding
  • Loading branch information
dreab8 authored and beikov committed Oct 5, 2021
1 parent 8df7a3a commit b872d8a
Showing 1 changed file with 16 additions and 4 deletions.
Expand Up @@ -105,11 +105,23 @@ public void setBindValue(T value, boolean resolveJdbcTypeIfNecessary) {
}

if ( ! getTypeConfiguration().getSessionFactory().getJpaMetamodel().getJpaCompliance().isLoadByIdComplianceEnabled() ) {
if ( bindType != null ) {
value = bindType.getExpressableJavaTypeDescriptor().coerce( value, this );
try {
if ( bindType != null ) {
value = bindType.getExpressableJavaTypeDescriptor().coerce( value, this );
}
else if ( queryParameter.getHibernateType() != null ) {
value = queryParameter.getHibernateType().getExpressableJavaTypeDescriptor().coerce( value, this );
}
}
else if ( queryParameter.getHibernateType() != null ) {
value = queryParameter.getHibernateType().getExpressableJavaTypeDescriptor().coerce( value, this );
catch (CoercionException ce) {
throw new IllegalArgumentException(
String.format(
"Parameter value [%s] did not match expected type [%s ]",
value,
bindType.getTypeName()
),
ce
);
}
}

Expand Down

0 comments on commit b872d8a

Please sign in to comment.