jpql « Query « JPA Q&A





1. JPA QL, How to NOT select something    stackoverflow.com

I have a pretty simple sql I need to perform. I have a ProcessUser, Role and a ProcessUserRole table. A straight forward many-to-many I want to select all ProcessUser's that does also have ...

2. Finding users whose birtday is today with JPA    stackoverflow.com

I have a table with users and are trying to get a list with the people who have birthday today so the app can send an email. The User is defined as ...

3. How do I write this JPQL query?    stackoverflow.com

Say I have 5 tables,

tblBlogs     tblBlogPosts     tblBlogPostComment    tblUser    tblBlogMember
BlogId        BlogPostsId ...

4. JPA : Many to Many query help needed    stackoverflow.com

I have four entities that are involved in a query that I'm having a little trouble with. The relationship is as follows : Exchange----*Contract*----*Combo----*Trade and the (simplified) entities are as ...

5. Doing an "IN" query with Hibernate    stackoverflow.com

I have a list of IDs in a String, and want to use Hibernate to get the rows with these IDs. TrackedItem is a Hibernate/JPA entity (sorry if I'm getting the ...

6. how to write JPA query    stackoverflow.com


Learning how to write JPA query. Please advise me whether it possible to write the below queries more efficiently, may be in a single select statement. May be a ...

7. How to Assign a JPQL query to a simple Java object?    stackoverflow.com

I need to assign the result of a jpql result to a simple class java object I have something like this

class myObject() {
@id
private Long id;
private String Name;
private String description;
...
//getters and setters
}
I need ...

8. Ordering by varying columns in JPQL/Hibernate    stackoverflow.com

I have a table of Sessions. Each session has "session_start_time" and "session_end_time". While the session is open, the end time is empty. I want to fetch the list of sessions, and ...

9. Doing a query for each day in a period, turning it into one query    stackoverflow.com

I have this:

public Map<Day,Integer> getUniqueLogins(long fromTime, long toTime) {

  EntityManager em = emf.createEntityManager();
  try {
   Map<Day,Integer> resultMap = new ...;
   for (Day day : daysInPeriod(fromTime, ...





10. JPQL Order By Average from a second table    stackoverflow.com

Background I have two objects persisted using Hibernate. Product and Vote. The Product object contains a list of votes, such as

public class Product {
    @javax.persistence.Id
    @javax.persistence.GeneratedValue
  ...

11. What is wrong with this jpql query?(JPA)    stackoverflow.com

Can you help me find the error in my JPQL query of the login method in my application please?

// Login
public boolean saveUserState(String email, String password) {
    // 1-Send ...

12. Can i use clause IN in JPQL for selecting both items?    stackoverflow.com

I have softwares which related to tags - many-to-many. I want to create a query which would select all softwares which are related to all tags that i put as parameters. I write: public ...

13. Ordering a join fetched collection in JPA using JPQL/HQL    stackoverflow.com

Given the below JPQL statement, how do I modify it so that the kittens in the resulting list are ordered by their age property?

SELECT c FROM Cat c left join fetch ...

14. JPQL query not using "NOT IN" command    stackoverflow.com

I'm trying to exclude a bunch of results from a database SELECT using the "NOT IN" keywords, but the exclusion list is still being returned. Using JPQL (JPA2.0) my query ...

15. JPA Select latest instance for each item    stackoverflow.com

Let's say I have a Meeting entity. Each meeting has a single attendee and a meeting date. Within my meeting table I may have multiple meetings for each attendee, ...

16. New Object in JPQL and selects    stackoverflow.com

Why would a JPQL query

Select new Foo(X,Y) from X join X.y as Y Where ...
produces more than one sql? 1 for main select and 1 each for X and Y? ...





17. Is Select EXISTS() possible in JPQL?    stackoverflow.com

So, I am trying to run a query that checks if some conditions are true and returns a simple boolean result as output. What makes it slightly tricky is that ...

18. JPQL Querying Bit Flags    stackoverflow.com

I Have in my msql table column of type Long, this column represent bit falgs. I need to select objects for which all of several flags are set : columnValue & flags = ...

19. JQPL: Create new Object within the Query from multiple tables    stackoverflow.com

I'm currently trying to fetch data with JQPL. My Query looks like

SELECT NEW com.test.CustomObject(t1.name, CASE WHEN(t2 IS NOT NULL) THEN true ELSE false END) FROM table1 t1, table2 t2 WHERE t1.id ...

20. JPA Query For Exists In    stackoverflow.com

I have the following Entities (reduced and renamed for this example)

@Entity
public class Case {

@Id
private Long id;


@ManyToOne(optional=false)
private CourtConfiguration courtConfiguration;

@ElementCollection(fetch=FetchType.EAGER)
private List<String> caseNumbers;

}
Second Entity
@Entity
public class CourtConfiguration {

@Id
private Long id;

String countyId;

String referenceId;

.... 

}
I am trying ...

21. Problem with JPQL SELECT query    forums.netbeans.org

Hi, I cannot make this query to work. I need to do a LEFT OUTER JOIN but also include registers that has null values in the relation field. The following query ...

22. "exists" Clause on JPQL    coderanch.com

23. JPA JPQL - How to Order the Joins    coderanch.com

Hi all, I'm having trouble ordering the joins in JPQL (with Hibernate 3). I have a database with about 20 tables and they're arranged in a sort of circle with two parts branching out, eg. "-->" = "is joined to" T1 --> T2 --> T3 --> T4 --> T5 --> T6 --> T7 --> T8 --> T1 and T3 --> T3B ...

24. Jpql - order by sum?    coderanch.com

MYSQL JAVA EE 6 JPA 2 Hello, i want get a list of "Video Objects" from DB order by Desc how much (good) they are rated. VideoRatingEntity @ManyToOne() @JoinColumn(name = "VIDEO_ID") videoEntity ID | VIDEO_ID| USER_ID| RATING -------------------------------- Video Entity @OneToMany videoRatingEntities ID | ... | ... | ------------- My Try: "SELECT v, sum(vrr) " + " FROM VideoEntity AS v" ...

25. [JPQL] IN clause    coderanch.com

Hi! I've got a problem with my "IN" clause. If i do "select DISTINCT a from A a, IN(a.errors) ae where ae.errorCode IN (:errorCode)" And if I have one value in errorCode (setErrorCode("xxx") it works but if I have more than one value (setErrorCode("xxx, yyy")) it doesn't work! In fact, when i have more than one value, I use a method ...

26. JPQL: SELECT and CONCAT    coderanch.com

Hi, hope somebody can help me. I want to use a query with JPA 2.0. But it dosn't work and I don't know why. The query: select distinct v from Partnersuche v where v.partnerIndex in (SELECT concat(p.pk.nebenPartnerNr, max(p.pk.paLfdAdressNr)) from PartnersucheV p where p.psPartnerartKey = 1 group by p.pk.nebenPartnerNr) and here the error: java.lang.IllegalArgumentException: An exception occurred while creating a query in ...

27. how to write the jpql to query against the one to many table    coderanch.com

I asked the question in my last post but not sure why no reply. So I post it again as an standalone question. I have 2 tables Customer and Contact. One customer can have multiple contacts. So the relationship is one to many. Part of Customer Entity: @OneToMany(cascade = CascadeType.REFRESH, mappedBy="customer", fetch = FetchType.EAGER) private Set contacts; Part of Contact Entity: ...

28. Jpql - order by sum ???    forum.hibernate.org

MYSQL JAVA EE 6 JPA 2 Hello, i want get a list of "Video Objects" from DB order by Desc how much(good) they are rated. VideoRatingEntity @ManyToOne() @JoinColumn(name = "VIDEO_ID") videoEntity ID | VIDEO_ID| USER_ID| RATING -------------------------------- Video Entity @OneToMany videoRatingEntities ID | ... | ... | ------------- My Try: "SELECT v, sum(vrr) " + " FROM VideoEntity AS v" + ...

29. how to write the hql/jpql to query against the collection    forum.hibernate.org

I asked the question in my last post but not sure why no reply. So I post it again as an standalone question. I have 2 tables Customer and Contact. One customer can have multiple contacts. So the relationship is one to many. Part of Customer Entity: @OneToMany(cascade = CascadeType.REFRESH, mappedBy="customer", fetch = FetchType.EAGER) private Set contacts; Part of Contact Entity: ...

30. JPA JPQL - How to Order the Joins    forum.hibernate.org

31. JPA JPQL - How to Order the Joins    forum.hibernate.org

Hi all, I'm having trouble ordering the joins in JPQL (with Hibernate 3). I have a database with about 20 tables and they're arranged in a sort of circle with two parts branching out, eg. "-->" = "is joined to" T1 --> T2 --> T3 --> T4 --> T5 --> T6 --> T7 --> T8 --> T1 and T3 --> T3B ...

32. Problem with JPQL query using a view    forum.hibernate.org

Login Register FAQ Search View unanswered posts | View active topics Board index Hibernate & Java Persistence Hibernate Users All times are UTC - 5 hours [ DST ] Problem with JPQL query using a view Page 1 of 1 [ 4 posts ] Previous ...