use of javax.persistence.StoredProcedureQuery in project hibernate-orm by hibernate.
the class PostgreSQLStoredProcedureTest method testStoredProcedureRefCursor.
@Test
public void testStoredProcedureRefCursor() {
doInJPA(this::entityManagerFactory, entityManager -> {
StoredProcedureQuery query = entityManager.createStoredProcedureQuery("fn_phones");
query.registerStoredProcedureParameter(1, void.class, ParameterMode.REF_CURSOR);
query.registerStoredProcedureParameter(2, Long.class, ParameterMode.IN);
query.setParameter(2, 1L);
List<Object[]> phones = query.getResultList();
assertEquals(2, phones.size());
});
}
use of javax.persistence.StoredProcedureQuery in project hibernate-orm by hibernate.
the class HANAStoredProcedureTest method testStoredProcedureRefCursor.
@Test
@TestForIssue(jiraKey = "HHH-12138")
public void testStoredProcedureRefCursor() {
EntityManager entityManager = createEntityManager();
entityManager.getTransaction().begin();
try {
StoredProcedureQuery query = entityManager.createStoredProcedureQuery("sp_person_phones");
query.registerStoredProcedureParameter(1, Long.class, ParameterMode.IN);
query.registerStoredProcedureParameter(2, Class.class, ParameterMode.REF_CURSOR);
query.setParameter(1, 1L);
query.execute();
List<Object[]> postComments = query.getResultList();
assertNotNull(postComments);
} finally {
entityManager.getTransaction().rollback();
entityManager.close();
}
}
use of javax.persistence.StoredProcedureQuery in project hibernate-orm by hibernate.
the class HANAStoredProcedureTest method testStoredProcedureOutParameter.
@Test
@TestForIssue(jiraKey = "HHH-12138")
public void testStoredProcedureOutParameter() {
EntityManager entityManager = createEntityManager();
entityManager.getTransaction().begin();
try {
StoredProcedureQuery query = entityManager.createStoredProcedureQuery("sp_count_phones");
query.registerStoredProcedureParameter(1, Long.class, ParameterMode.IN);
query.registerStoredProcedureParameter(2, Long.class, ParameterMode.OUT);
query.setParameter(1, 1L);
query.execute();
Long phoneCount = (Long) query.getOutputParameterValue(2);
assertEquals(Long.valueOf(2), phoneCount);
} finally {
entityManager.getTransaction().rollback();
entityManager.close();
}
}
use of javax.persistence.StoredProcedureQuery in project hibernate-orm by hibernate.
the class HANAStoredProcedureTest method testSysRefCursorAsOutParameter.
@Test
@TestForIssue(jiraKey = "HHH-12138")
public void testSysRefCursorAsOutParameter() {
doInJPA(this::entityManagerFactory, entityManager -> {
StoredProcedureQuery function = entityManager.createNamedStoredProcedureQuery("singleRefCursor");
function.execute();
Integer value = (Integer) function.getSingleResult();
assertFalse(function.hasMoreResults());
assertEquals(Integer.valueOf(1), value);
});
}
use of javax.persistence.StoredProcedureQuery in project hibernate-orm by hibernate.
the class OracleStoredProcedureTest method testStoredProcedureOutParameter.
@Test
public void testStoredProcedureOutParameter() {
EntityManager entityManager = createEntityManager();
entityManager.getTransaction().begin();
try {
StoredProcedureQuery query = entityManager.createStoredProcedureQuery("sp_count_phones");
query.registerStoredProcedureParameter(1, Long.class, ParameterMode.IN);
query.registerStoredProcedureParameter(2, Long.class, ParameterMode.OUT);
query.setParameter(1, 1L);
query.execute();
Long phoneCount = (Long) query.getOutputParameterValue(2);
assertEquals(Long.valueOf(2), phoneCount);
} finally {
entityManager.getTransaction().rollback();
entityManager.close();
}
}
Aggregations