29
29
import javax .sql .rowset .serial .SerialBlob ;
30
30
import javax .sql .rowset .serial .SerialClob ;
31
31
32
+ import org .hibernate .jpa .TypedParameterValue ;
32
33
import org .hibernate .procedure .ProcedureCall ;
33
34
import org .hibernate .type .BigDecimalType ;
34
35
import org .hibernate .type .BigIntegerType ;
71
72
72
73
/**
73
74
* @author Vlad Mihalcea
75
+ * @author Yanming Zhou
74
76
*/
75
77
public class StoredProcedureParameterTypeTest extends BaseNonConfigCoreFunctionalTestCase {
76
78
@@ -422,4 +424,45 @@ public void testStringTypeInParameterIsNullWithoutEnablePassingNulls() {
422
424
}
423
425
);
424
426
}
427
+
428
+ @ Test
429
+ @ TestForIssue (jiraKey = "HHH-15618" )
430
+ public void testTypedParameterValueInParameter () {
431
+ inTransaction (
432
+ session -> {
433
+ ProcedureCall procedureCall = session .createStoredProcedureCall ( "test" );
434
+ procedureCall .registerParameter ( 1 , StringType .class , ParameterMode .IN );
435
+ procedureCall .setParameter ( 1 , new TypedParameterValue ( StringType .INSTANCE , "test" ) );
436
+ }
437
+ );
438
+ }
439
+
440
+ @ Test
441
+ @ TestForIssue (jiraKey = "HHH-15618" )
442
+ public void testTypedParameterValueInParameterWithEnablePassingNulls () {
443
+ inTransaction (
444
+ session -> {
445
+ ProcedureCall procedureCall = session .createStoredProcedureCall ( "test" );
446
+ procedureCall .registerParameter ( 1 , StringType .class , ParameterMode .IN ).enablePassingNulls ( true );
447
+ procedureCall .setParameter ( 1 , new TypedParameterValue ( StringType .INSTANCE , null ) );
448
+ }
449
+ );
450
+ }
451
+
452
+ @ Test
453
+ @ TestForIssue (jiraKey = "HHH-15618" )
454
+ public void testTypedParameterValueInParameterWithNotSpecifiedType () {
455
+ inTransaction (
456
+ session -> {
457
+ try {
458
+ ProcedureCall procedureCall = session .createStoredProcedureCall ( "test" );
459
+ procedureCall .registerParameter ( 1 , StringType .class , ParameterMode .IN );
460
+ procedureCall .setParameter ( 1 , new TypedParameterValue ( IntegerType .INSTANCE , 1 ) );
461
+ }
462
+ catch (IllegalArgumentException e ) {
463
+ assertTrue ( e .getMessage ().contains ( "was not of specified type" ) );
464
+ }
465
+ }
466
+ );
467
+ }
425
468
}
0 commit comments