use of org.hibernate.query.criteria.HibernateCriteriaBuilder in project hibernate-orm by hibernate.
the class PluralAttributeExpressionsTest method testCollectionSizeCriteria.
@Test
public void testCollectionSizeCriteria() {
doInJPA(this::entityManagerFactory, entityManager -> {
final HibernateCriteriaBuilder cb = (HibernateCriteriaBuilder) entityManager.getCriteriaBuilder();
final CriteriaQuery<Address> criteria = cb.createQuery(Address.class);
final Root<Address> root = criteria.from(Address.class);
criteria.select(root).where(cb.gt(cb.size(root.get(Address_.phones)), 1));
entityManager.createQuery(criteria).getResultList();
});
}
Aggregations