criteria-api Questions

7

Solved

I use JPA criteria API to fetch records from the datebase. I have entity Record with field dateTime which can be null. I would code: public List<Record> find(RecordFilter recordFilter, int p...
Sherburne asked 7/1, 2017 at 11:35

5

Solved

I have a very complicated model. Entity has a lot relationship and so on. I try to use Spring Data JPA and I prepared a repository. but when I invoke a method findAll() with specification for the o...
Uncomfortable asked 19/5, 2015 at 17:0

2

Solved

I'm trying to allow users from a web front end to search for some attributes in a database. The attribute names may include the special SQL characters % and _ used in like. Is there a way to escape...
Nickelson asked 23/8, 2019 at 14:18

3

I am trying to write the following SQL query using the JPA Criteria API SELECT * FROM Table1 a WHERE (a.category, a.priority) IN ( SELECT a1.category, max(a1.priority) FROM Table1 a1 GROUP BY a1.c...
Zhukov asked 12/5, 2016 at 14:58

4

Solved

I want the query not to return any values. I can't just not query database, so I'd like to add some unreachable condition to predicates, something like 'where 1 <> 1'. But the CriteriaBuilder.eq...
Stale asked 8/8, 2011 at 10:54

4

Solved

I'm building my first Java EE web application using Glassfish and JSF. I'm fairly new to the criteria query and I have a query I need to perform but the javaee6 tutorial seems a little thin on exam...
Humdrum asked 6/1, 2012 at 20:40

6

Two database tables have a foreign key relationship. They are mapped to two entities A and B by JPA, but the join columns are manually removed from the entities, so in JPA world classes A and B ar...
Annecy asked 14/6, 2013 at 10:29

4

Solved

Suppose I have two entities as: @Entity public class A { @Id private int id; @ManyToOne private B b; //more attributes } @Entity public class B { @Id private int id; } So, the table...
Grania asked 17/2, 2016 at 7:8

3

Solved

I am trying to perform a summation SQL query like the following: select group_ID, sum(case when user_type = 'Exec' then 1000 when user_type = 'Office' then 10 else 0 end) from subscription gr...
Buy asked 12/7, 2012 at 23:48

1

Solved

I have 4 different tables on which Joins are applied and this is working fine with SQL Query SELECT donor.title, SUM(donation.donated_amount) + SUM(donation.gift_aid), SUM(donation.donated_amoun...
Rotative asked 13/6, 2022 at 12:0

7

Solved

I don't know how to perform a JPA criteria query that returns with a boolean output. The goal is to have a criteria query that looks like this when rendered on Oracle: select 1 from dual where ex...
Advised asked 18/7, 2011 at 5:12

3

Solved

I want to write this SQL query SELECT * FROM A LEFT OUTER JOIN B ON A.IDRESOURCE=B.IDRESOURCE AND B.IDLANGUAGE=22; with the JPA Criteria Builder. I wrote the first part of the join simply with...
Causeuse asked 4/4, 2016 at 15:9

2

Solved

How to invoke order by on a joined entity? I am trying to achieve the following with: select * from person p inner join telephone t on p.id=t.person_id join sim s on s.id=t.sim_id order by s.name ...
Brittneybrittni asked 16/12, 2016 at 20:55

3

I am trying to fetch all users for a folder where the user was created after a certain date. the relationship between the user and the folder lives in a separate table. This is the query I came up ...
Israelite asked 18/4, 2011 at 13:24

2

I have a following problem. In application, which I am developing, we use Hibernate and every query is written with Criteria API. Now, in some places, we want to add possibility for user to write s...
Jennefer asked 13/4, 2015 at 11:57

4

Solved

I'm trying to find all entities that have some nested elements and nested elemens have collections of elements, and I need to find it by property of those collections. It would be something like t...
Bruges asked 7/11, 2016 at 9:15

2

Solved

I have two entities Customer and Order in a one-to-many relation. For each customer I need to count the number of associated orders and sort the results by this number. In a native postgres query...
Livvi asked 20/1, 2013 at 14:49

1

Solved

I use Spring Boot 1.5.3.RELEASE and for me it's unclear how to sort by properties of nested objects with distinct and Specifications because of: Caused by: org.postgresql.util.PSQLException: ERROR...
Sigismondo asked 6/4, 2021 at 19:58

3

I have a question about Subquery class in jpa. I need to create subquery with two custom field, but subquery doesn't have multiselect method and select method has Expression input parameter(In quer...
Engagement asked 26/2, 2014 at 7:29

3

Solved

I want to do something like this: select count(*) from (select ...) (As it would be in SQL), but in JPA. Any ideas on how I would do it?
Durtschi asked 24/3, 2011 at 18:44

4

Solved

Having a situation where my java code is symbolic to query - SELECT CUSTOMER_ID, CUSTOMER_NAME, CASE WHEN COUNT (DISTINCT CARD_ID) > 1 THEN 'MULTIPLE' ELSE MAX(CARD_NUM) END AS CARD_NUM F...
Postpone asked 25/7, 2020 at 0:13

3

Solved

I am using JPA2 with it's Criteria API to select my entities from the database. The implementation is OpenJPA on WebSphere Application Server. All my entities are modeled with Fetchtype=Lazy. I se...
Forzando asked 9/1, 2012 at 15:33

4

Solved

Using JPA 2 with EclipseLink implementation. I'm trying to build a dynamic query which should bring me some records persisted after a given date. CriteriaBuilder builder = em.getCriteriaBuilder()...
Custodian asked 25/2, 2012 at 23:17

2

Solved

I have the following statement to concatenate two columns which works well Expression<String> stringConcat = cb.concat(cb.concat(root.get(Employee_.userId), " # "), joinDept.get(Employe...
Spacetime asked 25/11, 2015 at 12:3

3

Given the query example here: http://www.hibernatespatial.org/tutorial-hs4.html Query query = em.createQuery("select e from Event e where within(e.location, :filter) = true", Event.class); query....
Wessel asked 16/9, 2013 at 7:3

© 2022 - 2025 — McMap. All rights reserved.