Questions tagged [jpa-criteria]

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

Docs

117 questions
0
votes
1 answer

Jpa get parent by field child

How to get parent entity by child's field? I use Specification I have repository ParentRepository extends JpaRepository, JpaSpecificationExecutor{ } And two clases: class Parent{ @Id long id; @OneToOne(cascade =…
Joe
  • 11
  • 1
  • 5
0
votes
1 answer

REST Query Language with Spring and JPA Criteria Date type

I am using the following code to make a dynamic search by Criteria API public List findAllByParam(List params) { CriteriaBuilder builder = entityManager.getCriteriaBuilder(); CriteriaQuery query =…
0
votes
1 answer

Criteria join query for composite primary key in hibernate

Need criteria join query for a composite primary key. Entities: ArtWork @Entity @Table(name = "artwork") public class ArtWork implements io.malevich.web.entity.Entity { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Long…
0
votes
2 answers

JPA CriteryQuery inner join - IllegalStateException

I have the following qriteria query in JPA: CriteriaBuilder cb2 = entityMager.getCriteriaBuilder(); CriteriaQuery cqInnerJoin = cb2.createQuery(DemoUser.class); Root root = cqInnerJoin.from(DemoUser.class); …
Ztrew
  • 48
  • 1
  • 7
0
votes
0 answers

Spring Specification left join for sort purposes

I have the below entities and wondering how I can create the below query using JPA specifications. SELECT p.* FROM property p INNER JOIN ad ON ad.id = p.ad_id LEFT JOIN featured_ad fad ON fad.id = ad.id …
zoro74
  • 171
  • 15
0
votes
1 answer

How to use specification to make two "OR" condition with multiple "AND" condition in mysql query

I want to make a following query with help of Specification select * from table where (order_quantity > 0 or product_verified = false) and sku = "12345"; following is my code but i got a wrong result set Specification specification =…
Devratna
  • 938
  • 1
  • 7
  • 26
0
votes
1 answer

What is the difference Jpa Criteria Api isFalse and isTrue?

I have this examples ,but I can't solved difference between them. Both of them are creating same query. public static Specification hasDestinationPartyNumber(List values) { if…
Rhmn61
  • 200
  • 2
  • 12
0
votes
2 answers

JPA No property findAll found for type Product

My repository: @Repository public interface ProductDao extends JpaRepository,JpaSpecificationExecutor { Page findAll(Specification specification,Pageable pageable); } My service: ... @Autowired …
0
votes
1 answer

Spring Data Specifiction + JPA Criteria. If root.join(ListAttribute) is null, query doesn't work

I have an entity with a List<> field in it. I'm trying to search entries in the database by a search string. Almost everything works fine, except the case when my entity's hardwareCharacteristicValueList field is null. When it happens the query…
Nikolay
  • 1
  • 2
0
votes
2 answers

Criteria Query, JPA 2 - build query with IN clause using predicates

Im using the below code for PostgresDB with JPA Criteria Query public static Specification findEventRecords(final String id, final Boolean status, final Date createdTime, final Date updatedTime, final String userId, …
user2340345
  • 793
  • 4
  • 16
  • 38
0
votes
1 answer

Spring data repository query to retrieve values containing null

I have following User table and repository. User: id;name;job;age 1;steve;nurse;33 2;steve;programmer;null 3;steve;programmer;null Repository method: @Query("SELECT u FROM User u WHERE (" + "LOWER(u.name) = LOWER(:name) AND " +…
0
votes
1 answer

JPA Criteria API - Subquery with join

How can I write this JPQL query in JPA Criteria API ? SELECT t FROM TvShow t WHERE ( SELECT COUNT(g) FROM Genre g WHERE t MEMBER OF g.tvShows ) <= 2
0
votes
0 answers

CriteriaBuilder Cast Date to Long

I have the following table: CREATE TABLE "pre_vendas" ( "id_prev_venda" BIGINT NOT NULL, "data_prev_venda" DATE NOT NULL, "data_real_venda" DATE NOT NULL, "valor_real_venda" NUMERIC(10,2) NULL DEFAULT NULL, PRIMARY KEY…
Mauro
  • 13
  • 1
  • 4
0
votes
1 answer

JPAQuery to JPASubQuery and vice versa

Is there any way I can get a JPASubQuery from a JPAQueryand vice versa? I have a JPAQuery and I want to reuse it as a subquery but seems like there's not any kind of common interface between the two so that I can perform this transition. The query…
Niko
  • 616
  • 4
  • 20
0
votes
2 answers

How to strip accents in JPA Criteria API

I'm using JPA Criteria API, and I want to select occurrences where I have a column data like a given string, this is how I do it in SQL : lower(CONVERT(myTable.lib, 'US7ASCII')) like lower('%'+myString+'%') For example I have a row where…
Renaud is Not Bill Gates
  • 1,684
  • 34
  • 105
  • 191