use of javax.persistence.criteria.Path in project hibernate-orm by hibernate.
the class AbstractPathImplTest method testIllegalDereference.
@Test
public void testIllegalDereference() {
EntityManager em = getOrCreateEntityManager();
try {
CriteriaBuilder criteriaBuilder = em.getCriteriaBuilder();
CriteriaQuery<Order> criteria = criteriaBuilder.createQuery(Order.class);
Root<Order> orderRoot = criteria.from(Order.class);
Path simplePath = orderRoot.get("totalPrice");
// this should cause an ISE...
try {
simplePath.get("yabbadabbado");
fail("Attempt to dereference basic path should throw IllegalStateException");
} catch (IllegalStateException expected) {
}
} finally {
em.close();
}
}
use of javax.persistence.criteria.Path in project hibernate-orm by hibernate.
the class SingularAttributeJoinTest method testEntityModeMapJoinCriteriaQuery.
@Test
public void testEntityModeMapJoinCriteriaQuery() throws Exception {
final EntityManager entityManager = entityManagerFactory().createEntityManager();
CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();
CriteriaQuery criteriaQuery = criteriaBuilder.createQuery();
javax.persistence.metamodel.EntityType distributionEntity = getEntityType("Distribution");
From distributionFrom = criteriaQuery.from(distributionEntity);
From policyJoin = distributionFrom.join("policy");
Path policyId = policyJoin.get("policyId");
criteriaQuery.select(policyId);
TypedQuery typedQuery = entityManager.createQuery(criteriaQuery);
// typedQuery.getResultList();
}
use of javax.persistence.criteria.Path in project hibernate-orm by hibernate.
the class CriteriaUpdateImpl method set.
@Override
@SuppressWarnings("unchecked")
public CriteriaUpdate<T> set(String attributeName, Object value) {
final Path attributePath = getRoot().get(attributeName);
final Expression valueExpression = value == null ? criteriaBuilder().nullLiteral(attributePath.getJavaType()) : criteriaBuilder().literal(value);
addAssignment(attributePath, valueExpression);
return this;
}
Aggregations