|
30 | 30 | import javax.sql.rowset.serial.SerialClob;
|
31 | 31 |
|
32 | 32 | import org.hibernate.procedure.ProcedureCall;
|
| 33 | +import org.hibernate.query.TypedParameterValue; |
33 | 34 | import org.hibernate.type.NumericBooleanConverter;
|
34 | 35 | import org.hibernate.type.StandardBasicTypes;
|
35 | 36 | import org.hibernate.type.TrueFalseConverter;
|
|
46 | 47 |
|
47 | 48 | /**
|
48 | 49 | * @author Vlad Mihalcea
|
| 50 | + * @author Yanming Zhou |
49 | 51 | */
|
50 | 52 | @DomainModel
|
51 | 53 | @SessionFactory
|
@@ -425,4 +427,37 @@ public void testStringTypeInParameterIsNullWithoutEnablePassingNulls(SessionFact
|
425 | 427 | );
|
426 | 428 | }
|
427 | 429 |
|
| 430 | + |
| 431 | + @Test |
| 432 | + @TestForIssue(jiraKey = "HHH-15618") |
| 433 | + public void testTypedParameterValueInParameter(SessionFactoryScope scope) { |
| 434 | + scope.inTransaction( |
| 435 | + session -> { |
| 436 | + ProcedureCall procedureCall = session.createStoredProcedureCall( "test" ); |
| 437 | + procedureCall.registerParameter( 1, StandardBasicTypes.STRING, ParameterMode.IN ); |
| 438 | + procedureCall.setParameter( 1, new TypedParameterValue( StandardBasicTypes.STRING, "test" ) ); |
| 439 | + |
| 440 | + procedureCall = session.createStoredProcedureCall( "test" ); |
| 441 | + procedureCall.registerParameter( "test", StandardBasicTypes.STRING, ParameterMode.IN ); |
| 442 | + procedureCall.setParameter( "test", new TypedParameterValue( StandardBasicTypes.STRING, "test" ) ); |
| 443 | + } |
| 444 | + ); |
| 445 | + } |
| 446 | + |
| 447 | + @Test |
| 448 | + @TestForIssue(jiraKey = "HHH-15618") |
| 449 | + public void testTypedParameterValueInParameterWithNotSpecifiedType(SessionFactoryScope scope) { |
| 450 | + scope.inTransaction( |
| 451 | + session -> { |
| 452 | + try { |
| 453 | + ProcedureCall procedureCall = session.createStoredProcedureCall( "test" ); |
| 454 | + procedureCall.registerParameter( 1, StandardBasicTypes.STRING, ParameterMode.IN ); |
| 455 | + procedureCall.setParameter( 1, new TypedParameterValue( StandardBasicTypes.INTEGER, 1 ) ); |
| 456 | + } |
| 457 | + catch (IllegalArgumentException e) { |
| 458 | + assertTrue( e.getMessage().contains( "was not of specified type" ) ); |
| 459 | + } |
| 460 | + } |
| 461 | + ); |
| 462 | + } |
428 | 463 | }
|
0 commit comments