Questions tagged [criteriabuilder]

36 questions
0
votes
0 answers

How to build query with CriteriaBuilder for a query with a subquery that returns dynamic number of columns?

I have the following query (it finds the row with the most similar name and selects it plus the value and rating): SELECT DISTINCT FIRST_VALUE(value) over (partition by name order by distance asc) value, rating, name FROM ( SELECT …
yaserso
  • 2,638
  • 5
  • 41
  • 73
0
votes
0 answers

Cannot filter on UUID with CriteriaBuilder in Java using Postgresql

I have an entity import jakarta.persistence.Entity I'm using CriteriaBuilder import jakarta.persistence.criteria.CriteriaBuilder Using this line gives 1 result, as expected. all.where(criteriaBuilder.equal(root.get("code"),…
0
votes
0 answers

Sort and aggregation result in CriteriaBuilder JPA

in the following CriteriaBuilder query, I can sort all the entries except the sums of majorFindings / minorFindings. But I need to sort them too. Is it possible? Because to sort in db level all the properties must be in the given entities. public…
bullgr
  • 21
  • 1
  • 3
0
votes
0 answers

Criteria builder and collate

I use spring boot 3 I have some query I use collate binary_ai of oracle. like select * from olym_athletes where athlete_name like :name collate binary_ai I can use that in a @Query, I search how to do it in a criteria builder
robert trudel
  • 5,283
  • 17
  • 72
  • 124
0
votes
0 answers

CriteriaBuilder, specification and subquery

I use spring boot 3 School have a one to many relation with Teacher I created 2 specfication public Page advanceSearch(SchoolSearch search, Pageable page) { Specification hasCityName = (Root mainRoot, CriteriaQuery
robert trudel
  • 5,283
  • 17
  • 72
  • 124
0
votes
0 answers

jakarta.persistence.criteria.CriteriaBuilder how to add If the Coordinate is a part of Envelope

I'm using CriteriaBuilder to add Search filters in Postgres. I need also add an additional filter entries that have Location that is a part of a Map window. final Envelope envelope = new…
Kitty
  • 11
  • 1
  • 4
0
votes
0 answers

Is it possible to achieve regular expression search (~) in PostgreSQL using CriteriaBuilder?

I am currently attempting to search by regular expression using CriteriaBuilder. Here is the query I want to generate select * from table where column ~ '.*'; Then I tried using 'criteriaBuilder.function()'. Expression expression =…
0
votes
0 answers

JPA CriteriaBuilder build with different table name

I have following code CriteriaBuilder criteriaBuilder = em.getCriteriaBuilder(); CriteriaQuery criteriaQuery = criteriaBuilder.createQuery(User.class); Root itemRoot = criteriaQuery.from(User.class); User entity class has…
xibrian
  • 85
  • 2
  • 12
0
votes
0 answers

How to filter entities dynamically on Spring boot where clauses will be defined by frontend

I have an entity with the following properties public class DistributorMasterData implements Serializable { @Id @Column(updatable = false, nullable = false) private Long id; private String distributorName; private String…
0
votes
0 answers

Spring Jpa Specification with list of long where in query

I want to run a where in query with Spring JPA Specification and criteria builder. I am having issue where I will receive a List ids from request and run specification query but could't find any way to do so. This is what I have done so far. …
0
votes
0 answers

Querying JPA Specification CriteriaBuilder with join column

This is my Deal entity : @Data @NoArgsConstructor @Entity @Table(name = "tbl_deal") public class Deal { @Id @GeneratedValue(strategy = SEQUENCE, generator = "sequenceGenerator") @SequenceGenerator(name = "sequenceGenerator") …
0
votes
0 answers

How to resolve duplicity with JPA and join query?

I am new with JPA and Im having many problems with the data returning: Problems: The LoansRequest should be able to filter the query by each of its fields and always return just one loan, but it is returning data twice when I filter by the…
Sftc
  • 1
  • 1
0
votes
0 answers

JPA criteria query builder date diff in oracle

How to implement date diff to find out days between two dates using JPA criteria builder for Oracle? Expression fromDate= root.get("fromDate"); Expression toDate= root.get("toDate"); builder.greaterThanOrEqualTo(builder.diff(toDate,…
Javee
  • 71
  • 1
  • 1
  • 8
0
votes
0 answers

CriteriaBuilder - Subquery returns more than one result, when the expected result is only one

I am basically converting this query snippet: I have a table A, and a table B (fk a.id), with a relationship where A can have many Bs. I want to find A that is present in table B, which has values between X and Y. Basically this query: SELECT *…
Elizama Melo
  • 103
  • 2
  • 10
0
votes
0 answers

how to create criteriaBuilder to predicate in Specification when there is a manyToMany relationchip?

I am coding a searching so I am using Specification to do it. I have a relationchip beetwin tow tables (ManytoMany) like this: public class Productos implements Serializable { . . . @JoinTable(name = "PRODUCTOS_CATEGORIAS", joinColumns = { …