use of javax.persistence.StoredProcedureQuery in project hibernate-orm by hibernate.
the class JpaTckUsageTest method testResultClassHandling.
@Test
public void testResultClassHandling() {
EntityManager em = entityManagerFactory.createEntityManager();
em.getTransaction().begin();
try {
StoredProcedureQuery query = em.createStoredProcedureQuery("findOneUser", User.class);
boolean isResult = query.execute();
assertTrue(isResult);
int updateCount = query.getUpdateCount();
boolean results = false;
do {
List list = query.getResultList();
assertEquals(1, list.size());
assertTyping(User.class, list.get(0));
results = query.hasMoreResults();
// and it only sets the updateCount once lol
} while (results || updateCount != -1);
} finally {
em.getTransaction().commit();
em.close();
}
}
use of javax.persistence.StoredProcedureQuery in project hibernate-orm by hibernate.
the class JpaTckUsageTest method testHasMoreResultsHandlingTckChallenge.
@Test
@FailureExpected(jiraKey = "HHH-8416", message = "JPA TCK challenge")
public void testHasMoreResultsHandlingTckChallenge() {
EntityManager em = entityManagerFactory.createEntityManager();
em.getTransaction().begin();
try {
StoredProcedureQuery query = em.createStoredProcedureQuery("findOneUser", User.class);
assertTrue(query.execute());
assertTrue(query.hasMoreResults());
query.getResultList();
assertFalse(query.hasMoreResults());
} finally {
em.getTransaction().commit();
em.close();
}
}
use of javax.persistence.StoredProcedureQuery in project hibernate-orm by hibernate.
the class JpaTckUsageTest method testHasMoreResultsHandling.
@Test
public void testHasMoreResultsHandling() {
EntityManager em = entityManagerFactory.createEntityManager();
em.getTransaction().begin();
try {
StoredProcedureQuery query = em.createStoredProcedureQuery("findOneUser", User.class);
assertTrue(query.execute());
query.getResultList();
assertFalse(query.hasMoreResults());
} finally {
em.getTransaction().commit();
em.close();
}
}
use of javax.persistence.StoredProcedureQuery in project hibernate-orm by hibernate.
the class JpaTckUsageTest method testSettingInParamDefinedOnNamedStoredProcedureQuery.
@Test
public void testSettingInParamDefinedOnNamedStoredProcedureQuery() {
EntityManager em = entityManagerFactory.createEntityManager();
em.getTransaction().begin();
try {
StoredProcedureQuery query = em.createNamedStoredProcedureQuery("positional-param");
query.setParameter(1, 1);
} finally {
em.getTransaction().commit();
em.close();
}
}
use of javax.persistence.StoredProcedureQuery in project hibernate-orm by hibernate.
the class StoreProcedureOutParameterByNameTest method testOneBasicOutParameter.
@Test
public void testOneBasicOutParameter() {
EntityManager em = entityManagerFactory.createEntityManager();
em.getTransaction().begin();
User user = new User();
user.id = 1;
user.name = "aName";
em.persist(user);
em.getTransaction().commit();
em.clear();
try {
StoredProcedureQuery query = em.createNamedStoredProcedureQuery("User.findNameById");
query.setParameter("ID_PARAM", 1);
assertEquals("aName", query.getOutputParameterValue("NAME_PARAM"));
} finally {
em.close();
}
}
Aggregations