criteriaquery « Query « JPA Q&A

1. HQL to CriteriaQuery conversion

Class is defined as this:

class User {
     public int ID { get; set; }
     public string OpenID { get; set; }

2. In JPA 2, using a CriteriaQuery, how to count results

I am rather new to JPA 2 and it's CriteriaBuilder / CriteriaQuery API: CriteriaQuery javadoc CriteriaQuery in the Java EE 6 tutorial I would like to count the results of ...

3. CriteriaQuery with JPA 1.0

Is it possible to use CriteriaQuery with JPA 1.0. I guess JPA 2.0 not available with Java Se ( version -- Java(TM) SE Runtime Environment (build 1.6.0_16-b01)) . I ...

4. JPA 2.0: count for arbitrary CriteriaQuery?

I am trying to implement the following convenience method:

 * Counts the number of results of a search.
 * @param criteria The criteria for the query.
 * @return The number of ...

5. JPA Criteria Query on a local collection

I have been told that it should be possible to execute a CriteriaQuery on a local collection of results, however I cannot find any references on how to do this. We ...

6. JPA 2 CriteriaQuery Question

I am just starting out with JPA 2 criteria query API and finding it tough to learn. Looked around the net a bit, but haven't found good examples/tutorials yet. Can someone ...

7. Hibernate Criteria Query to outer join sub-queries results

I have a requirement to convert the below SQL query into a criteria query. There is just one table and note that it is not a case for self join.

SELECT atable.c1 AS ...

8. How to discover Implicit multiple root

here's my show case code:

CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<Tuple> q = cb.createTupleQuery();
Root<AA> aa = q.from(AA.class);


System.out.println("RootCount: "+q.getRoots().size());

Query query = em.createQuery(q);
List<Tuple> list = query.getResultList();
Where AA is a mapped Table and c is a CC ...

9. Mixing JPQL and CriteriaQuery

Is it possible to mix JPQL and CriteriaQuery? I have a String that contains a where condition in JPQL and a CriteriaQuery that is already built and got from somewhere else. I ...

10. JPA/Hibernate typesafe DELETE queries

The only CriteriaQuery examples I've seen are for SELECT queries. Is there a way to construct typesafe DELETE queries, either with JPA 2 or Hibernate APIs?

11. How to rewrite this query using JPA Criteria Query?

public class Entity {
private boolean suspended;

private String code;

@Type(type = "org.jadira.usertype.dateandtime.joda.PersistentDateTime")
@DateTimeFormat(style = "S-")
private DateTime validFrom;

@Type(type = "org.jadira.usertype.dateandtime.joda.PersistentDateTime")
@DateTimeFormat(style = "S-")
private DateTime validTill;
Meaning of query: "Is the code unique in given time validity?" How to ...

12. How do I dynamically create CriteriaQuery

I want to create equivalent CriteriaQuery to this query : select u from User u where = "John" and u.surname = "Black" and u.middlename = "Small"; but I have problem with "where" ...

13. JPA query builder: claims listAttribute is not a valid path

Error message is:

09:55:53,947 INFO  [STDOUT] ERROR [PARSER]  Invalid path: 'k.publishedImages'
Relevant class excerpt:
public class PATPublishedImageKeywords {

    private String keyword;


14. Getting a count of results from an arbitrary JPA CriteriaQuery

I have an issue where the code at the layer I am working in receives a CriteriaQuery object. I have virtually no other information about the query (though I can ...

15. Need help coding a CriteriaQuery "in" predicate

I have a query that I have been trying to turn into a CriteraQuery, but I don't get how to code the "IN" term of the query. The JPA Query that works ...

16. Criteria query, find all groups that I'm not member of

I have two entities, Group and GroupMember. Group is like it sounds a group that has name and some other properties. Members of the group are mapped with GroupMember entity, which ...

17. Bayes Rating using JPA CriteriaBuilder and CriteriaQuery

I'm want to compute the Ranking based on Bayesian way,

 br = ( (avg_num_votes * avg_rating) + (this_num_votes * this_rating) ) / (avg_num_votes         ...

18. JPA - CriteriaQuery with "WHERE" clause

I know this can be a very simple question to some of u, but I'm having a hard time trying to find out how to build a simple Select * From ...

19. JPA 2 CriteriaQuery Using ID columns throws Null Pointer EX

public class AePPstCPK { ... @Column(name = "status_code") public String getStatusCode() { return (String)attributes[0].getValue(); } ...} ------------------- @Entity @Table(name = "ae_p_pst_c") @IdClass(AePPstCPK.class) public class AePPstCDTO { ... @Id @Column(name = "status_code", nullable = false , length = 20) public String getStatusCode() { return (String) getAttribute(AePPstCAttributeName.STATUS_CODE).getValue(); } ...

20. CriteriaQuery/count/idClass error

21. Is CriteriaQuery reusable and thread-safe?

Using the JPA2 CriteriaQuery API I'd like to just build the CriteriaQuery objects once for my DAO in an initialization method and then call EntityManager.createQuery(CriteriaQuery) each time I need to actually execute the query. From my testing this appears to work just fine but the docs and spec say nothing about CriteriaQuery's re-usability or thread safety. Any thoughts here? Also is ...

22. "select a from null as a" with CriteriaQuery

Hi, I'm working on a JPA/Hibernate/Spring application connected to a MySQL database and I test my code using Unitils hibernate-core and entitymanager 3.6.2.Final hibernate-jpa-2.0-api 1.0.0.Final spring 3.0.5.RELEASE unitils 3.1 MySQL 5.1 Mapping Code: ...

23. how to get CriteriaQuery ?

25. CriteriaQuery - HELP

26. CriteriaQuery how ?