use of org.hibernate.procedure.ProcedureCall 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.procedure.ProcedureCall in project hibernate-orm by hibernate.
the class MySQLStoredProcedureTest method testHibernateProcedureCallOutParameter.
@Test
public void testHibernateProcedureCallOutParameter() {
EntityManager entityManager = createEntityManager();
entityManager.getTransaction().begin();
try {
Session session = entityManager.unwrap(Session.class);
ProcedureCall call = session.createStoredProcedureCall("sp_count_phones");
call.registerParameter("personId", Long.class, ParameterMode.IN).bindValue(1L);
call.registerParameter("phoneCount", Long.class, ParameterMode.OUT);
Long phoneCount = (Long) call.getOutputs().getOutputParameterValue("phoneCount");
assertEquals(Long.valueOf(2), phoneCount);
} finally {
entityManager.getTransaction().rollback();
entityManager.close();
}
}
use of org.hibernate.procedure.ProcedureCall 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();
}
}
use of org.hibernate.procedure.ProcedureCall in project hibernate-orm by hibernate.
the class AbstractSharedSessionContract method getNamedProcedureCall.
@Override
@SuppressWarnings("UnnecessaryLocalVariable")
public ProcedureCall getNamedProcedureCall(String name) {
checkOpen();
final ProcedureCallMemento memento = factory.getNamedQueryRepository().getNamedProcedureCallMemento(name);
if (memento == null) {
throw new IllegalArgumentException("Could not find named stored procedure call with that registration name : " + name);
}
final ProcedureCall procedureCall = memento.makeProcedureCall(this);
// procedureCall.setComment( "Named stored procedure call [" + name + "]" );
return procedureCall;
}
use of org.hibernate.procedure.ProcedureCall in project hibernate-orm by hibernate.
the class AbstractSharedSessionContract method createStoredProcedureCall.
@Override
@SuppressWarnings("UnnecessaryLocalVariable")
public ProcedureCall createStoredProcedureCall(String procedureName, String... resultSetMappings) {
checkOpen();
final ProcedureCall procedureCall = new ProcedureCallImpl(this, procedureName, resultSetMappings);
// call.setComment( "Dynamic stored procedure call" );
return procedureCall;
}
Aggregations