Questions tagged [criteriaquery]
245 questions
0
votes
0 answers
Criteria query equivalent for native query
how to create criteria query for this native query?
SELECT u FROM Users u WHERE u.userStatus = 0 AND u.firstName LIKE " + "'" + username + "%" + "'"
Am I doing right?
CriteriaBuilder criteriaBuilder =…

Rajasekar Sambandam
- 169
- 4
- 19
0
votes
1 answer
Reference properties of null referenced object in HQL
Here I have two Entity class.
@Table(name = "AC_ACCOUNT_MASTER")
public abstract class Account implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
@Column(name = "a_name")
private…

Mr. Mak
- 837
- 1
- 11
- 25
0
votes
1 answer
CriteriaQuery subquery with max
I have three classes like these:
Class A {
Long id;
Date d;
String e;
}
Class B {
Long id;
}
Class AB {
Long aId;
Long bId;
}
And I havet o build a CriteriaQuery to achieve the following:
select distinct(b.id) from b…

diminuta
- 1,545
- 8
- 32
- 55
0
votes
0 answers
Write a criteria query on elements of a Set
how I can write a criteria query if a parameter is a Set?
In the class Libro autore is a Set, in my criteria query I want to check on author first name and author last name.
If I wirte this method surely don't work because autores is a Set and…

Dennis A. Boanini
- 477
- 1
- 5
- 19
0
votes
1 answer
Hibernate CriteriaQuery check for null join
I am converting to hibernate 5.2.4 and to use CriteriaQuery. Have a slight issue in testing for a null join on a file. This is what I was doing before which worked.
@Entity
public class MyClass {
....
@ManyToOne(..)
public MyDetail…

gregh
- 171
- 2
- 8
0
votes
1 answer
JPA Criteria query double joins and hibernate error with-clause
Based on this answer https://stackoverflow.com/a/2111420/3989524 I first created a working SQL:
SELECT d.*
FROM device d
LEFT OUTER JOIN installation_record ir1 ON (d.id = ir1.device)
LEFT OUTER JOIN installation_record ir2 ON (d.id = ir2.device AND…

Miha Vitorovič
- 11
- 3
0
votes
1 answer
Add in sql comment to CriteriaQuery so it is visible in mysql slow log
I would like to add a human readable string to a query in CriteriaQuery (jpa with Hibernate 4.3.7 Final)
Something that would appear like
select count(id)
from my_table
where
'My Description Of Query Origin Name' is not null
and .....
To…

Simon B
- 1,784
- 3
- 21
- 26
0
votes
2 answers
how do size JPA to Criteriaquery
I have this Java code:
CriteriaBuilder qb = entityManager.getCriteriaBuilder();
CriteriaQuery cq = qb.createQuery(Long.class);
cq.select(qb.count(cq.from(MyEntity.class)));
cq.where(/*your stuff*/);
return…

Michel Lammens
- 591
- 1
- 4
- 11
0
votes
0 answers
How to implement join or relation using JPA CriteriaQuery
I have three tables in my database as below :
mysql> desc employee;
+--------------+------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra…

Dnyaneshwar
- 101
- 16
0
votes
2 answers
CriteriaQuery multiselect - Runtime constructor error
I am using CriteriaQuery to create TypedQuery with specific class type.
And I need just several columns from the class type.
I am selecting those columns trough multiselect method but I am struggling with RuntimeException below.
It is saying that…

Sujeong Yeom
- 9
- 1
- 5
0
votes
1 answer
criteria query is not getting data when adding or condition
I have a Java file that query data and I'm trying to add a filtering function. By using criteria builder and criteria query, I manage to get data that I want to filter.
As starter, this is the column to display my data:
Name Host
Fikrie…

Mohd Fikrie
- 197
- 4
- 21
0
votes
1 answer
How can I make a Hibernate Criteria Query with Restriction Greater than Period based on a integer field in hours
Suppose that I have the following entity:
@Entity
@Table(name="ORDER_ITEM")
public class Order {
@Id
@Column(name = "ORDER_ID")
private Long id;
@Column(name = "ORDER_VALUE")
private BigDecimal value;
…

Eduardo Fabricio
- 2,151
- 2
- 25
- 32
0
votes
1 answer
jpa 2 CriteriaQuery do not discriminate child entities
I have an entity which have a relation of one to many with another entity. say
1A -> 1.*B
i wrote this query.
CriteriaBuilder cb = super.getEntityManager().getCriteriaBuilder();
CriteriaQuery select = cb.createQuery(A.class);
Root from =…

OJVM
- 1,403
- 1
- 25
- 37
0
votes
1 answer
In JPA: counting results of query with where clause using CriteriaQuery
I am rather new to JPA and it's CriteriaBuilder / CriteriaQuery API:
I want to query an extract of a set of Objects(as you can see below, i only select element n to m of the results)
The query itsself works well and I get the results i expect.
But…

user3664966
- 41
- 6
0
votes
2 answers
JPA Metamodel generation missing attributes
I'm using JPA metamodel generation
http://relation.to/Bloggers/HibernateStaticMetamodelGeneratorAnnotationProcessor
to be able to execute criteria queries with names of the attributes.
I'm generating the metamodel classes trough ANT and…

Gaetano Piazzolla
- 1,388
- 1
- 16
- 31