Questions tagged [criteriaquery]

245 questions
1
vote
1 answer

Spring boot Specification to filter on two child entities

There is entity by name Transaction which has two mapped(@OneToOne) child entities by name ServiceTransaction and OtherFeeTransaction. Able to filter using Specification for all the fields but for the child entity fields at the same…
1
vote
1 answer

HQL query returns different results comparing to same logic criteria query

I need some HQL guru to help me with a complicated query. My mappings are AccountingDocument: AccountingDocument extends Document @ManyToOne @JoinColumn(name = "gestiune_id", nullable = false) private Gestiune gestiune; @OneToMany(fetch =…
1
vote
1 answer

CriteriaQuery returning wrong result

My CriteriaQuery returns only one record and should two for dateFrom = '2019-12-10' and dateTo = '2019-12-20' And i don't know why. This is my screenshot from database. And this is my query: CriteriaBuilder criteriaBuilder =…
PrzemekC
  • 21
  • 1
  • 3
1
vote
0 answers

Get selected columns of foreign key table using Criteria Query API

I have 3 tables ONE, TWO and THREE. In table ONE I have 2 foreign keys, 'ONE_foreignKey1' and 'ONE_foreignKey2'. 'ONE_foreignKey2' is foreign key of table TWO and table TWO have foreign key of table THREE. I want some selected columns from table…
chiranjiv
  • 81
  • 7
1
vote
1 answer

How to join multiple columns using Specification in JPA?

I'm trying to convert a query into a JPA Specification, the query contains JOIN operation with OR condition. Here is the Query : select u from User u inner join Operation o on (u.id = o.verificateur1 or u.id = o.verificateur2) where o.id not in…
Noureddine
  • 103
  • 1
  • 4
  • 16
1
vote
0 answers

CriteriaBuilder collection values

I have a scenario where I have to get the list of all masters who have no students (set is empty) and also students whose status is cancelled @Entity @Table(name="Masters") public class Master { @Id private String id; …
1
vote
1 answer

NullPointerException when using EntityManager and Criteria in Java

I've created a class which does a query based by some filters that are filled in the frontend application. Basically there are 3 filters: "Title", "startDate" and "endDate". Here are the problems that I'm facing: When I send the title alone without…
1
vote
1 answer

JPA Eclipselink Subquery in where clause with between, CriteriaBuilder and metamodel

I want to do this query with metamodel but I can't!! I dont know how to do this. MYSQL QUERY (with this query I want to get all the rows from the Clases table that are teaching in this moment): SELECT * FROM clases cl WHERE CURRENT_TIME()…
maxtorzito
  • 308
  • 7
  • 14
1
vote
1 answer

JPA CriteriaQuery order by with two criteria

I need to build a criteriaQuery with this statement in the orderBy clause: ORDER BY COL.NOMCOL ASC, CASE COL.TDN_ECO WHEN TO_CHAR(5381) THEN 1 WHEN TO_CHAR(5380) THEN 2 WHEN TO_CHAR(5383) THEN 3 WHEN TO_CHAR(5382) THEN 4 WHEN…
Julia
  • 538
  • 2
  • 7
  • 17
1
vote
0 answers

JPQL/Criteria Query How sort string col as number

I have in sql this query: SELECT SUBSTR(report_number, STRPOS(report_number, '/SW/')), SUBSTR(report_number,STRPOS(report_number, ''), STRPOS(report_number, '/')-1) FROM do_study ORDER BY SUBSTR(report_number, STRPOS(report_number,…
Mateusz
  • 83
  • 9
1
vote
2 answers

JPA CriteriaQuery multiselect from several entities

Right now, I am using the method multiselect of CriteriaQuery to put some values from entity Termine in entity Task like this: CriteriaBuilder builder = getEm().getCriteriaBuilder(); CriteriaQuery taskCriteria =…
user3218708
  • 55
  • 1
  • 1
  • 8
1
vote
1 answer

how to use concat function in case statement using jpa criteria query

Iam concatenating string and expression in case statement when the condition is satisfied as below mentioned code. CriteriaBuilder builder = em.getCriteriaBuilder(); CriteriaQuery cq =…
1
vote
0 answers

hibernate CriteriaQuery multi select and spring data Specification

mysql is select e,h from Equipment e,EquipmentHistory h where e.id = h.equipmentId and h.id in (select h2.id from EquipmentHistory h2 where criteria how convert to hibernate CriteriaQuery multi select and spring data Specification ?
wilson
  • 281
  • 6
  • 22
1
vote
3 answers

JPA One-To-Many join table give incorrect child records

I'm using Spring framework. I have two tables Package & Item and the relationship is one Package has many Items. The tables design is something like: Packages @Entity @Table(name = "TB_PACKAGE") public class Packages implements…
Javatar
  • 623
  • 3
  • 8
  • 20
1
vote
1 answer

Jpa CriteriaQuery , how to add many join clause?

I want to run a sql: select b.* from A a inner join B b on a.c = b.c where b.status = 1 ; now I have to do this use Jpa CriteriaQuery, and I hava got ( Root root ), A and B has no PK & FK, columu c is the FK of A and B, so how to do? …