use of org.hibernate.result.ResultSetOutput in project hibernate-orm by hibernate.
the class PostgresRefCursorSupportTest method testExplicitClassReturn.
@Test
public void testExplicitClassReturn() {
Session session = sf.openSession();
session.beginTransaction();
ProcedureCall call = session.createStoredProcedureCall("all_items", Item.class);
call.registerParameter(1, void.class, ParameterMode.REF_CURSOR);
ProcedureOutputs outputs = call.getOutputs();
ResultSetOutput results = assertTyping(ResultSetOutput.class, outputs.getCurrent());
session.getTransaction().commit();
session.close();
}
use of org.hibernate.result.ResultSetOutput in project hibernate-orm by hibernate.
the class StoredProcedureTest method testGetSingleResultTuple.
@Test
public void testGetSingleResultTuple() {
Session session = openSession();
session.beginTransaction();
ProcedureCall query = session.createStoredProcedureCall("findOneUser");
ProcedureOutputs procedureResult = query.getOutputs();
Output currentOutput = procedureResult.getCurrent();
assertNotNull(currentOutput);
ResultSetOutput resultSetReturn = assertTyping(ResultSetOutput.class, currentOutput);
Object result = resultSetReturn.getSingleResult();
assertTyping(Object[].class, result);
String name = (String) ((Object[]) result)[1];
assertEquals("Steve", name);
session.getTransaction().commit();
session.close();
}
use of org.hibernate.result.ResultSetOutput in project hibernate-orm by hibernate.
the class StoredProcedureTest method baseTest.
@Test
public void baseTest() {
Session session = openSession();
session.beginTransaction();
ProcedureCall procedureCall = session.createStoredProcedureCall("user");
ProcedureOutputs procedureOutputs = procedureCall.getOutputs();
Output currentOutput = procedureOutputs.getCurrent();
assertNotNull(currentOutput);
ResultSetOutput resultSetReturn = assertTyping(ResultSetOutput.class, currentOutput);
String name = (String) resultSetReturn.getSingleResult();
assertEquals("SA", name);
session.getTransaction().commit();
session.close();
}
use of org.hibernate.result.ResultSetOutput in project hibernate-orm by hibernate.
the class OracleStoredProcedureTest method testHibernateProcedureCallRefCursor.
@Test
public void testHibernateProcedureCallRefCursor() {
doInJPA(this::entityManagerFactory, entityManager -> {
Session session = entityManager.unwrap(Session.class);
ProcedureCall call = session.createStoredProcedureCall("sp_person_phones");
call.registerParameter(1, Long.class, ParameterMode.IN).bindValue(1L);
call.registerParameter(2, Class.class, ParameterMode.REF_CURSOR);
Output output = call.getOutputs().getCurrent();
List<Object[]> postComments = ((ResultSetOutput) output).getResultList();
assertEquals(2, postComments.size());
});
}
use of org.hibernate.result.ResultSetOutput in project hibernate-orm by hibernate.
the class OracleStoredProcedureTest method testHibernateProcedureCallRefCursor.
@Test
public void testHibernateProcedureCallRefCursor() {
EntityManager entityManager = createEntityManager();
entityManager.getTransaction().begin();
try {
Session session = entityManager.unwrap(Session.class);
ProcedureCall call = session.createStoredProcedureCall("sp_person_phones");
call.registerParameter(1, Long.class, ParameterMode.IN).bindValue(1L);
call.registerParameter(2, Class.class, ParameterMode.REF_CURSOR);
Output output = call.getOutputs().getCurrent();
List<Object[]> postComments = ((ResultSetOutput) output).getResultList();
assertEquals(2, postComments.size());
} finally {
entityManager.getTransaction().rollback();
entityManager.close();
}
}
Aggregations