Search in sources :

Example 1 with From

use of jakarta.persistence.criteria.From in project hibernate-orm by hibernate.

the class SingularAttributeJoinTest method testEntityModeMapJoinCriteriaQuery.

@Test
public void testEntityModeMapJoinCriteriaQuery(EntityManagerFactoryScope scope) {
    scope.inEntityManager(entityManager -> {
        CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();
        CriteriaQuery criteriaQuery = criteriaBuilder.createQuery();
        jakarta.persistence.metamodel.EntityType distributionEntity = getEntityType(scope, "Distribution");
        From distributionFrom = criteriaQuery.from(distributionEntity);
        From policyJoin = distributionFrom.join("policy");
        Path policyId = policyJoin.get("policyId");
        criteriaQuery.select(policyId);
        TypedQuery typedQuery = entityManager.createQuery(criteriaQuery);
    });
}
Also used : CriteriaBuilder(jakarta.persistence.criteria.CriteriaBuilder) Path(jakarta.persistence.criteria.Path) TypedQuery(jakarta.persistence.TypedQuery) CriteriaQuery(jakarta.persistence.criteria.CriteriaQuery) From(jakarta.persistence.criteria.From) Test(org.junit.jupiter.api.Test)

Aggregations

TypedQuery (jakarta.persistence.TypedQuery)1 CriteriaBuilder (jakarta.persistence.criteria.CriteriaBuilder)1 CriteriaQuery (jakarta.persistence.criteria.CriteriaQuery)1 From (jakarta.persistence.criteria.From)1 Path (jakarta.persistence.criteria.Path)1 Test (org.junit.jupiter.api.Test)1