Questions tagged [detachedcriteria]
189 questions
0
votes
1 answer
Hibernate Criteria, Select order according to newest events
I have classes in hibernate like this:
@Entity
class Order{
private MyPattern pat;
@Id
private int id;
@OneToMany(cascade = CascadeType.ALL)
@JoinColumn(name = "order_id")
private List events;
public…

Seth
- 1
- 1
0
votes
1 answer
How to compare only the MM/dd/yyyy part of two dates with a detached criteria?
I have to dates in my query: ExpectedEnd and TerminationDate.
I need to find a query that returns records whenever the ExpectedEnd is at the same day as TerminationDate.
How can it be done using detached criteria?
I'm assuming some kind of…

the_drow
- 18,571
- 25
- 126
- 193
0
votes
1 answer
Subselect, Group by and Having Count with criteria in hibernate
I have a query like this:
SELECT ap.person_id FROM
(SELECT distinct ac.person_id person_id,ac.user_id
FROM zrm_actor ac WHERE ac.deleted != 1) ap
WHERE person_id IS NOT NULL
GROUP BY person_id HAVING COUNT(*) > 1;
How can I write…

sajjad jafari
- 176
- 1
- 2
- 13
0
votes
1 answer
Hibernate - Add orderBy() to DetachedCriteria if none is present?
I'm trying to build a query on the fly from a custom query object.
At one point in the code, the orderBy may be added to a DetachedCriteria. Later down the line, I'd like to add an orderBy should none already exist in the DetachedCriteria. Looking…

gwcoderguy
- 392
- 1
- 13
0
votes
0 answers
Hibernate Criteria DetachedCriteria and Subquery
DetachedCriteria cr = DetachedCriteria.forClass(DealerSales.class).setProjection(Property.forName("dealerCode"));
cr.add(Restrictions.eq("countryCode",01));
Criteria cr1 =…

Sumit Singh
- 111
- 1
- 5
0
votes
0 answers
Use DetachedCriteria in JOIN Clause in Gorm/Grails
Imagine I have this native SQL query:
SELECT
# .. other properties
model.id 'Model Id', mappedCountSubQ.mapcount 'Mapped Count'
FROM
# .. other join
model_content_revision modelCts
JOIN model model ON modelCts.model_id =…

Ichroman Raditya Duwila
- 101
- 2
- 12
0
votes
0 answers
grails 3.3 detachedcriteria appears to give incorrect result
I have a self-referencing Grails 3.3.5 domain class of the form (simplified version)
class Animal {
String name
String dateOfBirth
Animal sire
Animal dam
}
I am using DetachedCriteria to build up a back-end query controlled by a…

MonetsChemist
- 165
- 10
0
votes
1 answer
DetachedCriteria isNotEmpty for Oracle
I discovered following problem today.
As I am using detached criteria, like detachedCriteria.add(Restrictions.ne(field, value)); to check if a String is empty. I found out that this is not working for oracle.
As a "IS NOT NULL"-Check is not enough…

Pwnstar
- 2,333
- 2
- 29
- 52
0
votes
0 answers
Hibernate Criteria -If MAX is null return null otherwise return Max Value-CASE WHEN
I have a sql query
select * from user_projects where endDate is not null and startDate is not null and soft_delete=? and startDate<=? and
endDate>=? and endDate<=? and (endDate,user_id) in (select MAX(endDate),user_id from user_projects …

Tanvi Jain
- 113
- 1
- 14
0
votes
1 answer
Hibernate multiple subqueries with DetachedCriteria
I would like write this query into HQL :
select DISTINCT * from transportation transp
inner join price p on p.transportationId = transp.transportationId
where p.sectionId = ( select sec.sectionId from section sec where sec.lineId = (…

Zozo Zozo
- 141
- 4
- 4
- 12
0
votes
0 answers
Grails 3 where query with dynamic class name
Wondering why the "where" query bails out in the last example of the following. There is no "where" clause to the where query in case #5 - all Assignments are listed instead of just one. I am executing this in the Grails console, Grails…

Jay
- 173
- 10
0
votes
1 answer
Error in DetachedCriteria using 'between'
The error only happens when I use the 'between' inside of an association in a DetachedCriteria:
Error:
org.hibernate.QueryException: could not resolve property: execution_alias1 of: ExecutionService
Criteria:
new DetachedCriteria(Service).build {
…

Victor Soares
- 757
- 1
- 8
- 34
0
votes
1 answer
hibernate: Problem running queries / detached criterias on embedded object
I'm encountering a problem running a query or detached criteria on an embedded object. I've tried both approached from this related question, neither seem to work.
The error I'm getting is:
org.hibernate.QueryException: could not resolve property:…

ripper234
- 222,824
- 274
- 634
- 905
0
votes
1 answer
Spring hibernate criteria nested object
I have problem with correct query for my data.
@Id
@GeneratedValue
private Integer id;
@Size(min = 1, message = "")
@Column(unique = true)
@UniqueUserName(message = "")
private String name;
@Size(min = 1, message = "")
@Email
private String…

Lucas
- 48
- 9
0
votes
1 answer
Wrong result in DetachedCriteria
I have some entities as below
@Entity
public class Contact {
@OneToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL, orphanRemoval = true, mappedBy = "contact")
private Set details = new HashSet<>();
}
@Entity
public…

SRF
- 587
- 5
- 16