use of org.hibernate.jpa.test.metamodel.MapEntity in project hibernate-orm by hibernate.
the class MapJoinTest method allEntities.
@Test
public void allEntities() {
EntityManager em = getOrCreateEntityManager();
em.getTransaction().begin();
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<MapEntity> query = cb.createQuery(MapEntity.class);
Root<MapEntity> entity = query.from(MapEntity.class);
MapJoin<MapEntity, String, MapEntityLocal> cname = entity.join(MapEntity_.localized);
query = query.select(entity).where(cb.equal(cname.key(), "en")).orderBy(cb.asc(cb.upper(cname.value().get(MapEntityLocal_.shortName))));
em.createQuery(query).getResultList();
em.getTransaction().commit();
em.close();
}
use of org.hibernate.jpa.test.metamodel.MapEntity in project hibernate-orm by hibernate.
the class PluralAttributeExpressionsTest method testElementMapSizeCriteria.
@Test
@TestForIssue(jiraKey = "HHH-11225")
public void testElementMapSizeCriteria() {
doInJPA(this::entityManagerFactory, entityManager -> {
final HibernateCriteriaBuilder cb = (HibernateCriteriaBuilder) entityManager.getCriteriaBuilder();
final CriteriaQuery<MapEntity> criteria = cb.createQuery(MapEntity.class);
final Root<MapEntity> root = criteria.from(MapEntity.class);
criteria.select(root).where(cb.gt(cb.mapSize(root.get(MapEntity_.localized)), 1));
entityManager.createQuery(criteria).getResultList();
});
}
use of org.hibernate.jpa.test.metamodel.MapEntity in project hibernate-orm by hibernate.
the class PluralAttributeExpressionsTest method testElementMapIsEmptyCriteria.
@Test
@TestForIssue(jiraKey = "HHH-11225")
@FailureExpected(jiraKey = "HHH-6686")
public void testElementMapIsEmptyCriteria() {
doInJPA(this::entityManagerFactory, entityManager -> {
final HibernateCriteriaBuilder cb = (HibernateCriteriaBuilder) entityManager.getCriteriaBuilder();
final CriteriaQuery<MapEntity> criteria = cb.createQuery(MapEntity.class);
final Root<MapEntity> root = criteria.from(MapEntity.class);
criteria.select(root).where(cb.isMapEmpty(root.get(MapEntity_.localized)));
entityManager.createQuery(criteria).getResultList();
});
}
Aggregations