Top "Criteria-api" questions

This tag is for questions related to the Java Persistence Criteria API (from JPA 2.0) which is used to define queries through the construction of object-based query definition objects, rather than use of the string-based approach of the Java Persistence query language.

How to query for entities by their collection value

I'm using jpa and I have the following entity: @Entity @Table(name="favorites_folders") public class FavoritesFolder { private static final …

jpa collections criteria-api
CriteriaBuilder.and & CriteriaBuilder.or, how-to?

I'm trying to change the following HQL to use JPA Criteria: select distinct d from Department d left join fetch …

jpa-2.0 criteria-api
How to properly determine whether an "exists" JPA Criteria Query clause returned true or false?

I don't know how to perform a JPA criteria query that returns with a boolean output. The goal is to …

java hibernate jpa criteria-api
JPA Criteria API: LEFT JOIN for optional relationships

I'm using the Criteria API basically the first time. It's about abstracting queries for a generic builder: public TypedQuery<…

java sql jpa criteria-api metamodel
How do I count the number of rows returned by subquery?

I want to do something like this: select count(*) from (select ...) (As it would be in SQL), but in JPA. …

jpa jpa-2.0 jpql criteria-api
get max value of column using jpa criteria query

I want to get the maximum value of column relationId from table ElementRelationType I have written code but its giving …

jpa criteria-api
JpaSpecificationExecutor JOIN + ORDER BY in Specification

I have a query using a JOIN and ORDER BY and want to use it within my repository using the …

java mysql jpa spring-data-jpa criteria-api
What to use: JPQL or Criteria API?

My Java application is using JPA for object persistence. The business domain is very simple (just three classes are persistent, …

java jpa jpa-2.0 jpql criteria-api
spring-data subquery within a Specification

Spring-data, Oliver Gierke's excellent library, has something called a Specification (org.springframework.data.jpa.domain.Specification). With it you can …

spring subquery criteria-api spring-data
Conditional where clause in JPA criteria query

I am facing an issue for JPA criteria query. How can I add multiple where clause in my Criteria Query …

jpa where-clause predicate criteria-api conditional-statements