Questions tagged [jpa-criteria]

A type-safe, portable API for defining queries for entities - similar to JPQL

Docs

117 questions
0
votes
1 answer

Spring Data JPA 'AND' Query combinations

My Entity class has four instance variables: Ref Id, billing ID, customer ID and profile ID. All of them are String variables. I need atleast one of them to be mandatory. I will then be doing a select query. If more than one values is filled then I…
0
votes
1 answer

How can I make a sort with filtering using JPA Criteria API?

I have entities mapping db described by the following classes: @Entity(name = "myitem") public class MyItem { @Id private Long id; private String type; } @Entity(name = "mycontainer") public class MyContainer { @Id private Long id; …
0
votes
1 answer

How to display data from multiple tables using Spring data JPA - many to many relation

I am trying to get data from multiple tables in Spring Data JPA. I have: Professor.java @Entity public class Professor { @Id @GeneratedValue(strategy = GenerationType.TABLE) private Long id; private String username; private…
user8421021
0
votes
1 answer

Spring data jpa Criteria like

public static Specification listSpec(Query query) { return (root, query, cb) -> { List predicates = new ArrayList<>(); if (null != query.getKeyWord()) { predicates.add(cb.like(root.get("title"),…
Salt
  • 13
  • 5
0
votes
0 answers

Union in Spring JPA Or Specification

Trying to create criteria builder for below query. However seems UNION is not supported by JPA. Any thoughts ? SELECT * FROM firsttable i1 WHERE EXISTS (SELECT 1 FROM secondtable WHERE id = i1.fid …
0
votes
3 answers

How to avoid NPE when no values is specified for Spring JPA criteria

I have a Spring JPA search criteria like below. Where area is an Integer. cb.between(root.get(Property_.area), searchConstraint.getAreaMin(), searchConstraint.getAreaMax()) The question is, when the user does not specify an upper bound or lower…
Imran
  • 71
  • 8
0
votes
0 answers

Write subquery to compare list in JPA Criteria

I have the following entity structure: class A { int aId; B b; } class B { int bId; C c; } class C { List bs; int cId; } I have to write the following part of SQL code using spring-data-jpa specifications: SELECT * FROM…
Squeez
  • 919
  • 2
  • 12
  • 30
0
votes
1 answer

EclipseLink composite PK with FK

I am using eclipselink 2.5.1. Let's say I have these two class. JAVA @Entity public class Car implements Serializable { @EmbeddedId protected CarPK carPK; private String color; @ManyToOne(fetch = FetchType.LAZY) private…
Nordine
  • 824
  • 7
  • 25
0
votes
1 answer

JPA-equivalent to Hibernate's Criteria

As far as I know, there's no JPA-equivalent to Hibernate's criteria. The advantage of Hibernate's criteria is that they can be constructed without having an active Persistence Context (Restrictions.XYZ, see Hibernate JavaDoc). Is there anything…
PeteSabacker
  • 176
  • 8
0
votes
1 answer

Criteria count + sub query

I am trying to implement something like: Select thread from Thread where(Select Sum(thread.emails) from Thread) is equals to ? How could I implement it with Criteria + JPA?
Blanca Hdez
  • 3,513
  • 19
  • 71
  • 93
-1
votes
1 answer

Spring Data Specification: notEquals() in relationship

I have several entitites: TranslationUnit TranslationValue Locale TranslationUnit has relationship ManyToMany with TranslationValue. TranslationValue has 1-1 with Locale. Locale has meaningful field - jhi_value; What I need to do is: Select those…
EugeneSalmin
  • 65
  • 1
  • 6
-1
votes
1 answer

why my criteriaQuery.select method is wrong in spring data jpa

I am writing spring data jpa using Specification. but the IDEA give me a error(red line): 'select(javax.persistence.criteria.Selection>)' in 'javax.persistence.criteria.CriteriaQuery' cannot be applied to…
usrmqj xv
  • 79
  • 1
  • 7
1 2 3 4 5 6 7
8