Search in sources :

Example 1 with MapEntityLocal

use of org.hibernate.jpa.test.metamodel.MapEntityLocal 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();
}
Also used : CriteriaBuilder(javax.persistence.criteria.CriteriaBuilder) EntityManager(javax.persistence.EntityManager) MapEntityLocal(org.hibernate.jpa.test.metamodel.MapEntityLocal) MapEntity(org.hibernate.jpa.test.metamodel.MapEntity) Test(org.junit.Test) AbstractMetamodelSpecificTest(org.hibernate.jpa.test.metamodel.AbstractMetamodelSpecificTest)

Aggregations

EntityManager (javax.persistence.EntityManager)1 CriteriaBuilder (javax.persistence.criteria.CriteriaBuilder)1 AbstractMetamodelSpecificTest (org.hibernate.jpa.test.metamodel.AbstractMetamodelSpecificTest)1 MapEntity (org.hibernate.jpa.test.metamodel.MapEntity)1 MapEntityLocal (org.hibernate.jpa.test.metamodel.MapEntityLocal)1 Test (org.junit.Test)1