Questions tagged [jpa-criteria]

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

Docs

117 questions
1
vote
1 answer

java hibernate 5 subselect query with CriteriaBuilder and CriteriaSelect

I have a dropwizard application with Hibernate and want to use Hibernate 5's CriteriaQuery to implement a function in a DAO (DataAccessObject). More precisely, I want to query a table with objects that are all equipped with an 'id' column and a…
Sispeks
  • 11
  • 6
1
vote
1 answer

Spring Data Specifications - how can I filter objects by mulitple attributes

I'm trying to implement searching of users by mulitple attributes. Let's say, my Person has Name and Lastname. I want to type 'Michael Doe' and list all persons with this name and lastname. When I type only 'Michael', I want all Michaels and so…
Adam De
  • 131
  • 1
  • 2
  • 8
1
vote
1 answer

jpa metamodel how to get table name

Entity: @Entity public class MyAccount { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Integer id; private String userId; private String password; private String email; public Integer getId() { …
Sam YC
  • 10,725
  • 19
  • 102
  • 158
1
vote
0 answers

Unable to locate Attribute with JPA

I need to validate if the attribute acronym of binUse is equal to BinUseAcronym.FPAN.toString(). I need access binUse.acronym ProductBin @Id @Column(name = "ID") private Long id; @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "BIN_USE_ID",…
Daniela Morais
  • 2,125
  • 7
  • 28
  • 49
1
vote
2 answers

How to pass variable number of parameters to Spring Data/Hibernate/JPQL query

I need to pass in a variable number of parameters to a spring/JPA repo to mimick something like this. select * from myTable where name like '%SOME_VALUE%' or name like '%SOME_OTHER_VALUE%' or name like '%SOME_OTHER_VALUE2%' or an unknown number of…
Zipper
  • 7,034
  • 8
  • 49
  • 66
1
vote
1 answer

UserType api methods are not called from Criteria Builder query in hibernate

I have a scenario where i use a custom user type for a entity field in hibernate using the org.hibernate.usertype.UserType. It's a date conversion to UTC import org.hibernate.usertype.ParameterizedType; import…
Gowrav
  • 289
  • 1
  • 4
  • 20
0
votes
1 answer

How to concat or sum the fields of objects collection referenced as @OneToMany in JPA Entity with CriteriaBuilder?

I have two JPA Entities: @Entity @Table(name = "registry_group") public class RegistryGroupEntity { @Id @SequenceGenerator(name="registry_groups_gen", sequenceName="registry_groups_id_seq", allocationSize = 1) …
Eljah
  • 4,188
  • 4
  • 41
  • 85
0
votes
0 answers

JPA criteria projection with dynamic number of joins

I have a query with Criteria which consists of multiple joins of same entity. The amount of joins is dynamic, the code as following: @Entity public class Member { @Id Long id; String name; @OneToMany(...) private…
Nemo
  • 145
  • 1
  • 7
0
votes
2 answers

Are Restrictions and Projections deprecated from Hibernate 5.2 onwards?

Are Restrictions and Projections deprecate from Hibernate 5.2 onwards? If so what are the JPA Criteria API equivalents. Other Related Q's - Does the Hibernate Criteria Extensions API (which supports deprecated api have the Restriction an…
0
votes
0 answers

Execute two queries with JPA Criteria API with the same where clauses but different output types

I want to load data and count(data) via Criteria API. Just loading data and then checking the result list won't work, because I'm limiting my results with a maxResults parameter, while count(data) is supposed to check the amount of data without any…
Noel93
  • 135
  • 11
0
votes
1 answer

How to build JPA Predicate for checking point belongs to given polygon

I'm trying to build javax.persistence.criteria.Predicate which determines is point belongs to a given polygon. That predicate I want to use to build the query. I want to use Criteria API to dynamically build queries on given params from a…
Woland
  • 623
  • 2
  • 13
  • 31
0
votes
2 answers

How check exist element in postgresql jsonb column with jpa criteria?

I have an entity as follow: @Entity @Data @AllArgsConstructor @NoArgsConstructor @TypeDef(name = "JsonbType", typeClass = JsonBinaryType.class) public class Message { @Id @GeneratedValue private Long id; private String content; …
Morteza Malvandi
  • 1,656
  • 7
  • 30
  • 73
0
votes
1 answer

JPA criteria: order by child field gives error

I have 3 entities. Customer, Process and Document. A Customer has many processes and a process has many documents. I want to sort customers by document's updateDate. My entities are like below; Customer- @Entity public class Customer { @Id …
Sam
  • 105
  • 2
  • 9
0
votes
0 answers

@RepositoryRestResource changes url every time the application is restarted

I have a repository interface that extends JpaRepository and a NameRepositoryCustom. My repository is annotated with @RepositoryRestRessource(collectionResourceRel="pathname", path="pathname"). The problem I have is that every second restart of my…
0
votes
1 answer

JPA Criteria for MAX id GROUP BY FOREIGN KEY in a ManyToMany relationship

I'm developing an application using Spring Boot and Spring Data JPA. The following are the relevant entities: @Entity public class Certification { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; …
Julez
  • 1,010
  • 22
  • 44