use of org.hibernate.testing.TestForIssue in project hibernate-orm by hibernate.
the class PluralAttributeExpressionsTest method testEntityMapIsEmptyCriteria.
@Test
@TestForIssue(jiraKey = "HHH-11225")
public void testEntityMapIsEmptyCriteria() {
doInJPA(this::entityManagerFactory, entityManager -> {
final HibernateCriteriaBuilder cb = (HibernateCriteriaBuilder) entityManager.getCriteriaBuilder();
final CriteriaQuery<Article> criteria = cb.createQuery(Article.class);
final Root<Article> root = criteria.from(Article.class);
criteria.select(root).where(cb.isEmpty(root.get(Article_.translations)));
entityManager.createQuery(criteria).getResultList();
});
}
use of org.hibernate.testing.TestForIssue in project hibernate-orm by hibernate.
the class PluralAttributeExpressionsTest method testEntityMapSizeCriteria.
@Test
@TestForIssue(jiraKey = "HHH-11225")
public void testEntityMapSizeCriteria() {
doInJPA(this::entityManagerFactory, entityManager -> {
final HibernateCriteriaBuilder cb = (HibernateCriteriaBuilder) entityManager.getCriteriaBuilder();
final CriteriaQuery<Article> criteria = cb.createQuery(Article.class);
final Root<Article> root = criteria.from(Article.class);
criteria.select(root).where(cb.gt(cb.mapSize(root.get(Article_.translations)), 1));
entityManager.createQuery(criteria).getResultList();
});
}
use of org.hibernate.testing.TestForIssue in project hibernate-orm by hibernate.
the class BasicSimpleCaseTest method testCaseStringResult.
@Test
@TestForIssue(jiraKey = "HHH-9343")
public void testCaseStringResult() {
EntityManager em = getOrCreateEntityManager();
CriteriaBuilder builder = em.getCriteriaBuilder();
CriteriaQuery<Tuple> query = builder.createTupleQuery();
Root<Customer> root = query.from(Customer.class);
Path<String> emailPath = root.get("email");
CriteriaBuilder.Case<String> selectCase = builder.selectCase();
selectCase.when(builder.greaterThan(builder.length(emailPath), 13), "Long");
selectCase.when(builder.greaterThan(builder.length(emailPath), 12), "Normal");
Expression<String> emailType = selectCase.otherwise("Unknown");
query.multiselect(emailPath, emailType);
em.createQuery(query).getResultList();
}
use of org.hibernate.testing.TestForIssue in project hibernate-orm by hibernate.
the class BasicSimpleCaseTest method testCaseLiteralResult.
@Test
@TestForIssue(jiraKey = "HHH-9343")
public void testCaseLiteralResult() {
EntityManager em = getOrCreateEntityManager();
em.getTransaction().begin();
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<Boolean> cq = cb.createQuery(Boolean.class);
Root<Customer> expense_ = cq.from(Customer.class);
em.createQuery(cq.distinct(true).where(cb.equal(expense_.get("email"), "@hibernate.com")).multiselect(cb.selectCase().when(cb.gt(cb.count(expense_), cb.literal(0L)), cb.literal(true)).otherwise(cb.literal(false)))).getSingleResult();
}
use of org.hibernate.testing.TestForIssue in project hibernate-orm by hibernate.
the class BasicSimpleCaseTest method testCaseLiteralResult2.
@Test
@TestForIssue(jiraKey = "HHH-9343")
public void testCaseLiteralResult2() {
EntityManager em = getOrCreateEntityManager();
em.getTransaction().begin();
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<Boolean> cq = cb.createQuery(Boolean.class);
Root<Customer> expense_ = cq.from(Customer.class);
em.createQuery(cq.distinct(true).where(cb.equal(expense_.get("email"), "@hibernate.com")).multiselect(cb.selectCase().when(cb.gt(cb.count(expense_), cb.literal(0L)), true).otherwise(false))).getSingleResult();
}
Aggregations