AND and OR Operators

1

I recently started using the Criteria API because I need to make queries that would be very complex with HQL.

How do I use the AND and OR operators in queries with the Criteria API?

    
asked by anonymous 29.10.2015 / 03:50

1 answer

1

Would this be the syntax example you are looking for?

CriteriaQuery<Pet> cq = cb.createQuery(Pet.class);
Root<Pet> pet = cq.from(Pet.class);
cq.where(cb.equal(pet.get(Pet_.name), "Fido")
    .and(cb.equal(pet.get(Pet_.color), "brown")));
    
29.10.2015 / 14:05