Questions tagged [criteriaquery]

245 questions
3
votes
1 answer

How to search with multiple filter using criteria builder

I would like to make a multiple filter in java, I use Spring Boot. And my query are written using criteria. SearchApp.java: @Entity @Table(name = "searchapp") public class SearchApp implements Serializable { @Column(name = "code") private String…
static
  • 197
  • 1
  • 3
  • 13
3
votes
1 answer

How to add distinct property to query with jpa specification

I am using jhipster criteria and jpa specification to implement an endpoint for making research. Well it is working, but keep sending me duplicates. There is prestations with this model public class Prestation extends AbstractAuditingEntity…
3
votes
0 answers

Creating jpa criteria query using jsonb function jsonb_array_elements_text() in postrges

I have a table member where party is one of the column of type jsonb. jsonb structure looks as below: { "PE": [ "fefe046d-774d-4e8b-a74c-99c89e98a96f", "720bfde7-a8c0-404f-b746-d6929c9b1109", …
3
votes
0 answers

Searching dates and longs with CriteriaQueries using wildcards

I've been wrapping my mind around this for a while, but still can't find a solution to it. I have a table, with a search input. My client desires to use this input mainly to search dates and a long type field. So basically I've been trying to make…
3
votes
0 answers

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 ac1, btable.c1 as bc1 FROM ( SELECT a.c1 FROM table_child a …
ksrini
  • 1,412
  • 2
  • 19
  • 33
3
votes
2 answers

CriteriaQuery set cacheable

I understand that we will be able to set hibernate caching for query by using query.setHint("org.hibernate.cacheable", true) like the example below. However, does anyone know of any way to do it for CriteriaQuery instead of Query? Query query =…
Sebastian
  • 63
  • 7
3
votes
2 answers

CLOB and CriteriaQuery

I have an entity that has a CLOB attribute: public class EntityS { ... @Lob private String description; } To retrieve certain EntityS from the DB we use a CriteriaQuery where we need the results to be unique, so we…
diminuta
  • 1,545
  • 8
  • 32
  • 55
3
votes
0 answers

How to get JPA CriteriaQuery to filter on an abstract classes sub-class property

I cannot get JPA query to cast an AbstractAddress entity to its subclass AddressStd using the builder .treat() method. builder.equal( builder.treat(contracts.get("address"), AddressStd.class …
DaveT
  • 31
  • 4
3
votes
1 answer

JPA Criteria API where subclass - Getting error : Unable to resolve attribute [lastName] against path [null]

I am facing the following issue while writing a criteria query I am using Hibernate JPA 2.0, I am trying to create a criteria query to get Debts DebtHolder is a Join table Debt(1)-->(N)DebtHolders(N)-->(1)Party Party has two subclasses Person and…
Moiz
  • 31
  • 1
  • 5
2
votes
1 answer

Converting a Hibernate Criteria Query to JPA 2 Criteria Query

I have the following Hibernate 3.x Criteria Query which I want to convert it to a Hibernate JPA 2.0 query: Calendar calLo = new GregorianCalendar(); calLo.set(Calendar.HOUR_OF_DAY, 00); calLo.set(Calendar.MINUTE, 00); calLo.set(Calendar.SECOND,…
Skyhan
  • 871
  • 3
  • 15
  • 26
2
votes
1 answer

JPA Specification equivalent of a raw SQL

I am trying to use Specification to build an SQL which "should" be very similar to this query below: select p1_0.* from plans p1_0 inner join plans_vehicle_models p2_0 on p2_0.plan_id = p1_0.plan_id where p2_0.vehicle_model_id in (select…
2
votes
2 answers

Complex Many-to-Many JPA CriteriaQuery

I have two entities, Ablum and Image, which are in many to many relationship. I wanna make a criteria query that to get all Albums and the counts on how many Images they have. I don't want to get all Albums first then loop the result to get the…
hzywind
  • 51
  • 6
2
votes
1 answer

CriteriaQuery DISTINCT values in an aggregation function

Introduction Consider a query like the following: SELECT building.name AS building_name, STRING_AGG(DISTINCT visit.visitor_name, ', ') AS visitors, COUNT(visit.id) AS…
Snackoverflow
  • 5,332
  • 7
  • 39
  • 69
2
votes
1 answer

How we query one to many relation in Spring JPA using Criteria Query

The scenario is: Entity Student ID Name List Courses Entity Course ID Name Student Now I need the list of students who are studying course 'Programming' How can I achieve this using Criteria Query.
Ateeq
  • 39
  • 7
2
votes
1 answer

How to create orderby on non-entity field in Criteria Query?

I want to order by on a field known at runtime. Following is the simplified SQL query which I'm trying to convert in Criteria Query: SELECT CASE WHEN o.col2 > 0 THEN "START" WHEN o.col2 < 0 THEN "STOP" END AS STATUS, o.* FROM orders o JOIN…
Diksha
  • 406
  • 5
  • 20
1 2
3
16 17