HHH-12905 Improve the error message and update the tests accordingly

Also fix a loose end in the MySQL test: at least with MariaDB, using
a bit(1) as datatype for boolean does not work: it always return true
even if you set it to 0. Using either boolean or tinyint(1) solves
the issue.

As I'm not sure older versions of MySQL supports a real boolean type I
used a tinyint(1).
This commit is contained in:
Guillaume Smet 2018-08-14 00:41:44 +02:00
parent cac2cd057b
commit 8e6fcce523
3 changed files with 8 additions and 8 deletions

View File

@ -81,10 +81,10 @@ public class ParameterBindImpl<T> implements ParameterBind<T> {
if ( procedureParameter.getParameterType() != null ) {
if ( value == null ) {
if ( !procedureParameter.isPassNullsEnabled() ) {
throw new IllegalArgumentException( "The parameter with the [" +
throw new IllegalArgumentException( "The parameter " +
( procedureParameter.getName() != null
? procedureParameter.getName() + "] name"
: procedureParameter.getPosition() + "] position" )
? "named [" + procedureParameter.getName() + "]"
: "at position [" + procedureParameter.getPosition() + "]" )
+ " was null. You need to call ParameterRegistration#enablePassingNulls(true) in order to pass null parameters." );
}
}

View File

@ -107,11 +107,11 @@ public class MySQLStoredProcedureTest extends BaseEntityManagerFunctionalTestCas
statement.executeUpdate(
"CREATE PROCEDURE sp_is_null (" +
" IN param varchar(255), " +
" OUT result BIT(1) " +
" OUT result tinyint(1) " +
") " +
"BEGIN " +
" IF (param IS NULL) THEN SET result = 1; " +
" ELSE SET result = 0; " +
" IF (param IS NULL) THEN SET result = true; " +
" ELSE SET result = false; " +
" END IF; " +
"END"
);
@ -411,7 +411,7 @@ public class MySQLStoredProcedureTest extends BaseEntityManagerFunctionalTestCas
fail("Should have thrown exception");
}
catch (IllegalArgumentException e) {
assertEquals( "The parameter on the [1] position was null. You need to call ParameterRegistration#enablePassingNulls(true) in order to pass null parameters.", e.getMessage() );
assertEquals( "The parameter at position [1] was null. You need to call ParameterRegistration#enablePassingNulls(true) in order to pass null parameters.", e.getMessage() );
}
});
}

View File

@ -405,7 +405,7 @@ public class PostgreSQLStoredProcedureTest extends BaseEntityManagerFunctionalTe
fail("Should have thrown exception");
}
catch (IllegalArgumentException e) {
assertEquals( "The parameter with the [param] name was null. You need to call ParameterRegistration#enablePassingNulls(true) in order to pass null parameters.", e.getMessage() );
assertEquals( "The parameter named [param] was null. You need to call ParameterRegistration#enablePassingNulls(true) in order to pass null parameters.", e.getMessage() );
}
} );
}