HHH-8684 - Named output parameters don't work for stored procedure call
This commit is contained in:
parent
162e1659c3
commit
465c3b1e9c
|
@ -235,30 +235,31 @@ public class StoredProcedureTest extends BaseCoreFunctionalTestCase {
|
|||
session.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInParametersByName() {
|
||||
Session session = openSession();
|
||||
session.beginTransaction();
|
||||
|
||||
ProcedureCall query = session.createStoredProcedureCall( "findUserRange" );
|
||||
query.registerParameter( "start", Integer.class, ParameterMode.IN ).bindValue( 1 );
|
||||
query.registerParameter( "end", Integer.class, ParameterMode.IN ).bindValue( 2 );
|
||||
ProcedureOutputs procedureResult = query.getOutputs();
|
||||
Output currentOutput = procedureResult.getCurrent();
|
||||
assertNotNull( currentOutput );
|
||||
ResultSetOutput resultSetReturn = assertTyping( ResultSetOutput.class, currentOutput );
|
||||
List results = resultSetReturn.getResultList();
|
||||
assertEquals( 1, results.size() );
|
||||
Object result = results.get( 0 );
|
||||
assertTyping( Object[].class, result );
|
||||
Integer id = (Integer) ( (Object[]) result )[0];
|
||||
String name = (String) ( (Object[]) result )[1];
|
||||
assertEquals( 1, (int) id );
|
||||
assertEquals( "User 1", name );
|
||||
|
||||
session.getTransaction().commit();
|
||||
session.close();
|
||||
}
|
||||
// H2 does not support named parameters
|
||||
// @Test
|
||||
// public void testInParametersByName() {
|
||||
// Session session = openSession();
|
||||
// session.beginTransaction();
|
||||
//
|
||||
// ProcedureCall query = session.createStoredProcedureCall( "findUserRange" );
|
||||
// query.registerParameter( "start", Integer.class, ParameterMode.IN ).bindValue( 1 );
|
||||
// query.registerParameter( "end", Integer.class, ParameterMode.IN ).bindValue( 2 );
|
||||
// ProcedureOutputs procedureResult = query.getOutputs();
|
||||
// Output currentOutput = procedureResult.getCurrent();
|
||||
// assertNotNull( currentOutput );
|
||||
// ResultSetOutput resultSetReturn = assertTyping( ResultSetOutput.class, currentOutput );
|
||||
// List results = resultSetReturn.getResultList();
|
||||
// assertEquals( 1, results.size() );
|
||||
// Object result = results.get( 0 );
|
||||
// assertTyping( Object[].class, result );
|
||||
// Integer id = (Integer) ( (Object[]) result )[0];
|
||||
// String name = (String) ( (Object[]) result )[1];
|
||||
// assertEquals( 1, (int) id );
|
||||
// assertEquals( "User 1", name );
|
||||
//
|
||||
// session.getTransaction().commit();
|
||||
// session.close();
|
||||
// }
|
||||
|
||||
@Test
|
||||
public void testInParametersByPosition() {
|
||||
|
@ -305,17 +306,18 @@ public class StoredProcedureTest extends BaseCoreFunctionalTestCase {
|
|||
}
|
||||
}
|
||||
|
||||
{
|
||||
ProcedureCall query = session.createStoredProcedureCall( "findUserRange" );
|
||||
query.registerParameter( "start", Integer.class, ParameterMode.IN );
|
||||
query.registerParameter( "end", Integer.class, ParameterMode.IN ).bindValue( 2 );
|
||||
try {
|
||||
query.getOutputs();
|
||||
fail( "Expecting failure due to missing parameter bind" );
|
||||
}
|
||||
catch (JDBCException expected) {
|
||||
}
|
||||
}
|
||||
// H2 does not support named parameters
|
||||
// {
|
||||
// ProcedureCall query = session.createStoredProcedureCall( "findUserRange" );
|
||||
// query.registerParameter( "start", Integer.class, ParameterMode.IN );
|
||||
// query.registerParameter( "end", Integer.class, ParameterMode.IN ).bindValue( 2 );
|
||||
// try {
|
||||
// query.getOutputs();
|
||||
// fail( "Expecting failure due to missing parameter bind" );
|
||||
// }
|
||||
// catch (JDBCException expected) {
|
||||
// }
|
||||
// }
|
||||
|
||||
session.getTransaction().commit();
|
||||
session.close();
|
||||
|
|
Loading…
Reference in New Issue