use of org.hibernate.testing.TestForIssue in project hibernate-orm by hibernate.
the class QueryTest method testCacheStoreAndRetrieveModeParameter.
@Test
@TestForIssue(jiraKey = "HHH_8949")
public void testCacheStoreAndRetrieveModeParameter() throws Exception {
EntityManager em = getOrCreateEntityManager();
em.getTransaction().begin();
try {
Query query = em.createQuery("select item from Item item");
query.getHints().clear();
query.setHint("javax.persistence.cache.retrieveMode", CacheRetrieveMode.USE);
query.setHint("javax.persistence.cache.storeMode", CacheStoreMode.REFRESH);
assertEquals(CacheRetrieveMode.USE, query.getHints().get("javax.persistence.cache.retrieveMode"));
assertEquals(CacheStoreMode.REFRESH, query.getHints().get("javax.persistence.cache.storeMode"));
query.getHints().clear();
query.setHint("javax.persistence.cache.retrieveMode", "USE");
query.setHint("javax.persistence.cache.storeMode", "REFRESH");
assertEquals(CacheRetrieveMode.USE, query.getHints().get("javax.persistence.cache.retrieveMode"));
assertEquals(CacheStoreMode.REFRESH, query.getHints().get("javax.persistence.cache.storeMode"));
em.getTransaction().commit();
} catch (Exception e) {
if (em.getTransaction() != null && em.getTransaction().isActive()) {
em.getTransaction().rollback();
}
throw e;
} finally {
em.close();
}
}
use of org.hibernate.testing.TestForIssue in project hibernate-orm by hibernate.
the class QueryTest method testGetSingleResultWithNoResultException.
@Test
@TestForIssue(jiraKey = "HHH-10833")
public void testGetSingleResultWithNoResultException() {
final EntityManager entityManager = getOrCreateEntityManager();
try {
entityManager.createQuery("FROM Item WHERE name = 'bozo'").getSingleResult();
fail("Expected NoResultException");
} catch (Exception e) {
assertTyping(NoResultException.class, e);
} finally {
entityManager.close();
}
}
use of org.hibernate.testing.TestForIssue in project hibernate-orm by hibernate.
the class NativeQueryOrdinalParametersTest method testConflictWithSessionNativeQuery.
@Test
@TestForIssue(jiraKey = "HHH-11121")
public void testConflictWithSessionNativeQuery() {
EntityManager em = getOrCreateEntityManager();
final String sqlString = "SELECT * FROM GAME g WHERE title = ?";
try {
NativeQuery sqlQuery = em.unwrap(Session.class).createSQLQuery(sqlString);
sqlQuery.setString(0, "Super Mario Brothers").setCacheable(true);
List results = sqlQuery.list();
assertEquals(1, results.size());
NativeQueryImplementor query = (NativeQueryImplementor) em.createNativeQuery(sqlString);
query.setString(1, "Super Mario Brothers");
List list = query.list();
assertEquals(1, list.size());
sqlQuery = em.unwrap(Session.class).createSQLQuery(sqlString);
sqlQuery.setString(0, "Super Mario Brothers").setCacheable(true);
results = sqlQuery.list();
assertEquals(1, results.size());
query.setString(1, "Super Mario Brothers");
} finally {
em.close();
}
}
use of org.hibernate.testing.TestForIssue in project hibernate-orm by hibernate.
the class NativeQueryOrdinalParametersTest method testNativeQueryOrdinalParameter.
@Test
@TestForIssue(jiraKey = "HHH-10885")
public void testNativeQueryOrdinalParameter() {
EntityManager em = getOrCreateEntityManager();
try {
Query query = em.createNativeQuery("SELECT * FROM GAME g WHERE title = ?");
query.setParameter(1, "Super Mario Brothers");
List list = query.getResultList();
assertEquals(1, list.size());
} finally {
em.close();
}
}
use of org.hibernate.testing.TestForIssue in project hibernate-orm by hibernate.
the class NativeQueryOrdinalParametersTest method testNativeQueryIndexedOrdinalParameter.
@Test
@TestForIssue(jiraKey = "HHH-10885")
public void testNativeQueryIndexedOrdinalParameter() {
EntityManager em = getOrCreateEntityManager();
try {
Query query = em.createNativeQuery("SELECT * FROM GAME g WHERE title = ?1");
query.setParameter(1, "Super Mario Brothers");
List list = query.getResultList();
assertEquals(1, list.size());
} finally {
em.close();
}
}
Aggregations