use of org.hibernate.procedure.ProcedureOutputs in project hibernate-orm by hibernate.
the class StoredProcedureTest method testGetResultListTuple.
@Test
public void testGetResultListTuple() {
Session session = openSession();
session.beginTransaction();
ProcedureCall query = session.createStoredProcedureCall("findUsers");
ProcedureOutputs procedureResult = query.getOutputs();
Output currentOutput = procedureResult.getCurrent();
assertNotNull(currentOutput);
ResultSetOutput resultSetReturn = assertTyping(ResultSetOutput.class, currentOutput);
List results = resultSetReturn.getResultList();
assertEquals(3, results.size());
for (Object result : results) {
assertTyping(Object[].class, result);
Integer id = (Integer) ((Object[]) result)[0];
String name = (String) ((Object[]) result)[1];
if (id.equals(1)) {
assertEquals("Steve", name);
} else if (id.equals(2)) {
assertEquals("John", name);
} else if (id.equals(3)) {
assertEquals("Jane", name);
} else {
fail("Unexpected id value found [" + id + "]");
}
}
session.getTransaction().commit();
session.close();
}
Aggregations