Questions tagged [criteriaquery]

245 questions
0
votes
0 answers

How to add filter on second table parameter while doing left join using criteriaquery

I am stuck in a situation where I am not able to create a filter on left join between two table. My query is something like this. select count(*) from orders o left join payments p on o.id = p.o_id where o.uid_id = 1 and p.name…
Geek_To_Learn
  • 1,816
  • 5
  • 28
  • 48
0
votes
1 answer

Left Outer join JPA using Java

I am stuck in a problem where I am not able to find out how to generate a left outer join on two tables using criteriaQuery. I have two table A_1 and A_2 @Entity() @Table(name = "A_1") public class A1 { private long id_1; private long name; …
Geek_To_Learn
  • 1,816
  • 5
  • 28
  • 48
0
votes
1 answer

JPA Criteria Query for Left joins

I am new to JPA and I have a Left Join scenario. I have my native sql query as below and I am using left join to fetch the complete records from V_MONITORING table for st.id = 10001. I have some null values for id_legislature which also needs to be…
0
votes
2 answers

JPA count(*) using CriteriaBuilder. How to use CriteriaBuilder to retrive the count(*) column

I have a question about CriteriaBuilder API: I would like to count the results of a column with returning back the result of that counting and the list of the distinct values of that column. | Table_fruit | count(Table_fruit) …
Ahmed Aziz
  • 380
  • 1
  • 5
  • 17
0
votes
0 answers

how to join two tables using hibernate createQuery or criteriaQuery how to map using annotation

package com.employee; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; import…
BeSmart
  • 1
  • 3
0
votes
1 answer

How to do a "select from" in more than two table using hibernate CriteriaQuery

I'm a beginner at Hibernate and I would like to do a select from in more than two tables using CriteriaQuery. I have 3 tables: Cellphone, CellphoneIamges and CellphoneRangedPrices and I would like to get the data from these three tables. One…
Joh
  • 171
  • 3
  • 17
0
votes
0 answers

CriteriaQuery entity.list has value

I have an entity that has a list of enitities connected to it. Customer.roles = List() Now I get roleId as input and I'd like to know if customer has the role connected to it. I've tried several Ways using CriteriaQuery but haven't yet found…
Mihkel L.
  • 1,543
  • 1
  • 27
  • 42
0
votes
0 answers

Hibernate CriteriaQuery, fetch based on timestamp

I have an entity with two column marked as java.util.Date, but the same columns are provided as timestamp in the table (oracle db). @Column(name = "STD_DATT") private Date stdDatt; @Column(name = "ETA_DATT") private Date etaDatt; I am trying to…
Mujahid
  • 127
  • 1
  • 2
  • 10
0
votes
0 answers

JPA Criteria "IS NULL OR NOT IN"

I am trying to build the CriteriaQuery equivalent of the following SQL where clause, using OpenJPA 2.4.0: where employee_status is null or employee_status not in ('Inactive','Terminated') I have created a list of employeeStatuses, and this is how I…
D.E.
  • 1
0
votes
1 answer

Difficulty converting this hibernate Criteria to JPA Criteria, issues with multiple associated entities

The hibernate criteria query I'm trying to change looks like this Criteria crit = session.createCriteria(device.class) .createCriteria("deviceConfigurationTemplate") .createCriteria("deviceModel"); I want to simply change this to use JPA…
macmeyers50
  • 309
  • 2
  • 15
0
votes
1 answer

How to apply distinct to perticular column and fetch all values from table in JPA(Criteria Builder)

I have written JPA query in that I want to apply distinct to only one column but here it is applying to all columns in table. CriteriaBuilder cb = entityManager_gbl.getCriteriaBuilder(); CriteriaQuery cq =…
sp21 p
  • 63
  • 1
  • 3
  • 7
0
votes
2 answers

How to represent Postgresql bool_and and bool_or aggregate functions in JPA 2 using CriteriaQuery?

I am trying to write a Select statement using JPA 2 provided CriteriaQuery for the following scenario: Group items and if at least one of the columns is 'true', return true Group items and if all columns are 'true', return true I noticed there is…
Yogesh Ghimire
  • 432
  • 1
  • 8
  • 21
0
votes
1 answer

How can I access to joined column in multiselect criteria tuple query?

table class: private static final long serialVersionUID = 1L; @Audited(targetAuditMode = RelationTargetAuditMode.NOT_AUDITED) @JoinColumn(name = "SUBSYSTEM_ID", referencedColumnName = "ID") @ManyToOne private Subsystem subsystem; @Transient private…
0
votes
1 answer

Can I use an object as a predicate for criteriaquery in JPA when some fields can be NULL?

I have an object, we will call it Person: @Entity @Table(name = "PERSON") public class Person extends PersistentObject { @Id @Column(name = "NAME") private String name; @Column(name = "AGE") private String age; …
0
votes
1 answer

JPA CriteriaQuery join only entities which match the Criteria

I have been working on a code to build a Criteria Query to do a conditional join. But its not quit correct. Please consider following example: I have 2 Entities Owner and Car. Owner has OneToMany relation with Car. On code Owner entity has List of…
Kishor Prakash
  • 8,011
  • 12
  • 61
  • 92