Questions tagged [criteriaquery]

245 questions
0
votes
1 answer

CriteriaBuilder call a select function

I have a query that i want to call a function without parsing a parameter to the function. Example.... CREATE OR REPLACE function demo_fn() RETURNS TABLE ( id bigint, somename varchar, something varchar) AS $$ BEGIN RETURN QUERY SELECT…
yormen
  • 188
  • 2
  • 11
0
votes
1 answer

Create query with JPA Criteria API for foreign key

This is the query I want to rewrite using criteria query: Query query = entityManager.createQuery( "Select a from UserDetails a where a.user.id = ?1") How can I achieve this? I know how to do select with criteria query when I know some of the…
TheBezwet
  • 33
  • 1
  • 10
0
votes
0 answers

JPA @JoinColumn with extra condition on Parent class

I spent almost all morning searching, but couldn't find any answer. I have scenario where I have to JOIN with ManyToMany relationship with an couple of extra conditions (on parent class) to limit the rows for joins. I'm looking for the association…
0
votes
2 answers

Spring Data JPA - How to implement LIKE search with multiple values on the same column

Lets say I've the following table, MOVIE_TITLE Batman Begins Batman Returns Return of the Jedi The Lord of the Rings: The Return of the King Shakespeare in Love Dead Poets Society Deadpool The Lord of the Rings: The Fellowship of the…
0
votes
0 answers

Spring criteria query on many to many relationship

I have a problem with my custom query made with criteria query, I need to make an In clause on a field that has a many to many relationship, what is the best way? here is the entity public class Book { private int idBook; //bi-directional…
0
votes
1 answer

entityManager.createQuery() taking lot of time to build query and bind the parameters. Performance affected

We are using Spring JPA criteria query ( javax.persistence.criteria.CriteriaQuery) to fetch data from database. We use the javax.persistence.criteria.Predicate to build the predicates. We have 1500 'OR' predicates in one query. And each predicate…
0
votes
1 answer

Spring Data Specification orderBy subquery

On my MySql project I got this particular model with 3 entities: Prodotto with many childs QuotaIngrediente, that in turn is Many-to-One child of Ingrediente too. All my relationships are bi-directional. All of them got an autogenerated integer Id…
4javier
  • 481
  • 2
  • 7
  • 22
0
votes
1 answer

Find min and max on the same date field column and count using jpa entity manager criteriabuilder

I am working on replacing below sql query and use entitymanager criteriabuilder. I checked other blogs and documentation but haven't been successful yet. SELECT MIN(creation_date),MAX(creation_date),COUNT(*), source FROM creation_tbl where…
Prashant Kumar
  • 308
  • 2
  • 3
  • 19
0
votes
0 answers

javax CriteriaBuilder attribute equal on specific position

I am using javax CriteriaBuilder with CriteriaQuery like this: CriteriaBuilder builder = getSession().getCriteriaBuilder(); CriteriaQuery criteria = builder.createQuery(MyClazz.class); Root root =…
Michael
  • 33
  • 5
0
votes
1 answer

Spring boot 2.1.9 - CriteriaBuilder javax.persistence.PersistenceException: org.hibernate.exception.GenericJDBCException: could not prepare statement

I use CriteriaQuery, Spring boot 2.1.9, java 11. My code is below: @Autowired private EntityManager entityManager; CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder(); CriteriaQuery criteriaQuery =…
0
votes
1 answer

Handling Null values in postgres for text array type column in org.hibernate.PropertyAccessException

we got a strange scenario in our Hibernate based web application. On the Database postgresql,there is a column field of text[] type and some of the values are Null. In my entity class I have mapped it to String[] and When I run a CriteriaBuilder…
0
votes
1 answer

How do I dynamically create CriteriaQuery

I want to create equivalent CriteriaQuery to this query : select u from User u where u.name = "John" and u.surname = "Black" and u.middlename = "Small"; but I have problem with "where" predicate. Thanks
Marian
  • 3
  • 1
0
votes
1 answer

Criteria Query for count

SELECT count(d.*) FROM ( SELECT s.id ,avg(e.marks) FROM Student s INNER JOIN Exam e ON s.id = e.student_id GROUP BY s.id ) d How to represent this for JPA Criteria query to get no of records
Mahendra
  • 3,647
  • 2
  • 16
  • 16
0
votes
1 answer

Unable to locate Attribute with the the given name [XXX] on this ManagedType [unknown]

I have this entity with its ID defined in Identifiable class. InventoryLoad has InventoryLoadID as its PK public class InventoryLoad extends AbstractIdentifiable implements Auditable {     @OneToMany(mappedBy =…
0
votes
1 answer

Crieria.Root class unable to get Local attribute which is a composite key attribute

I have Entity class UniversityBasicInformation.java and UniversityBasicInformation.hbm.xml files. I want to write a criteria query. I am getting error at root.get("surveyYear"), surveyYear) in my code. The error says that…