use of org.hibernate.testing.orm.junit.JiraKey in project hibernate-orm by hibernate.
the class HANAStoredProcedureTest method testStoredProcedureOutParameter.
@Test
@JiraKey("HHH-12138")
public void testStoredProcedureOutParameter(SessionFactoryScope scope) {
scope.inTransaction((session) -> {
StoredProcedureQuery query = session.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);
});
}
use of org.hibernate.testing.orm.junit.JiraKey in project hibernate-orm by hibernate.
the class HANAStoredProcedureTest method testSysRefCursorAsOutParameter.
@Test
@JiraKey("HHH-12138")
public void testSysRefCursorAsOutParameter(SessionFactoryScope scope) {
scope.inTransaction((session) -> {
StoredProcedureQuery function = session.createNamedStoredProcedureQuery("singleRefCursor");
function.execute();
Integer value = (Integer) function.getSingleResult();
Assertions.assertFalse(function.hasMoreResults());
assertEquals(Integer.valueOf(1), value);
});
}
use of org.hibernate.testing.orm.junit.JiraKey in project hibernate-orm by hibernate.
the class HANAStoredProcedureTest method testStoredProcedureRefCursor.
@Test
@JiraKey("HHH-12138")
public void testStoredProcedureRefCursor(SessionFactoryScope scope) {
scope.inTransaction((session) -> {
StoredProcedureQuery query = session.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();
// noinspection unchecked
List<Object[]> postComments = query.getResultList();
Assertions.assertNotNull(postComments);
});
}
use of org.hibernate.testing.orm.junit.JiraKey in project hibernate-orm by hibernate.
the class ResultTransformerTest method testResultTransformerIsAppliedToScrollableResults.
@Test
@JiraKey("HHH-3694")
public void testResultTransformerIsAppliedToScrollableResults(SessionFactoryScope scope) {
scope.inTransaction((session) -> {
final PartnerA a = new PartnerA();
a.setName("Partner A");
final PartnerB b = new PartnerB();
b.setName("Partner B");
final Contract obj1 = new Contract();
obj1.setName("Contract");
obj1.setA(a);
obj1.setB(b);
session.persist(a);
session.persist(b);
session.persist(obj1);
});
scope.inSession((session) -> {
Query q = session.getNamedQuery(Contract.class.getName() + ".testQuery");
q.setFetchSize(100);
q.setResultTransformer((ResultTransformer) (arg0, arg1) -> {
// return only the PartnerA object from the query
return ((Contract) arg0[0]).getA();
});
ScrollableResults sr = q.scroll();
// does not support java.sql.ResultSet.first()
if (scope.getSessionFactory().getJdbcServices().getDialect() instanceof AbstractHANADialect) {
sr.next();
} else {
sr.first();
}
Object obj = sr.get();
assertTrue(obj instanceof PartnerA);
PartnerA obj2 = (PartnerA) obj;
assertEquals("Partner A", obj2.getName());
});
}
use of org.hibernate.testing.orm.junit.JiraKey in project hibernate-orm by hibernate.
the class ContributedUserTypeTest method test.
@Test
@JiraKey("HHH-14408")
public void test(SessionFactoryScope scope) {
Type type = scope.getSessionFactory().getMappingMetamodel().getEntityDescriptor(StringWrapperTestEntity.class).getPropertyType("stringWrapper");
Assertions.assertTrue(type instanceof CustomType, "Type was initialized too early i.e. before type-contributors were run");
}
Aggregations