Questions tagged [detachedcriteria]
The detachedcriteria tag has no usage guidance.
detachedcriteria
186
questions
0
votes
0
answers
37
views
Workaround for using DetachedCriteria with JPA & Hibernate-6?
In my org, many applications heavily depend on the DetachedCriteria of Hibernate.
The application sends DetachedCriteria to the library which internally uses hibernate sessions and sends the result ...
1
vote
0
answers
38
views
Grails How to set resultTransformer on DetachedCriteria?
In Grails 3.1 I have this code:
def criteria = new DetachedCriteria(SampleObject).build {}
criteria.projections {
property('id')
}
criteria.list()
That returns a list of ids (Long). But I want a ...
1
vote
0
answers
203
views
Get only one column from DetachedCriteria with multiple Projections
I have the following code to get the object which has the "Andamento" with the latest date (I have called date -> data).
DetachedCriteria criteriaAndamento = DetachedCriteria.forClass(...
0
votes
1
answer
62
views
DetachedCriteria list methor with order param in nested property
I want to use the DetachedCriteria's list method with a domain with nested properties and order by one of the attributes in one of those properties.
I'm trying creating an alias criteria.createAlias(&...
0
votes
1
answer
406
views
Hibernate Criteria to take the first record
I am trying to resolve a bug in my system, related to pagination. When a user selects a record, we retrieve all the associated records back to the user using pagination.
With the page maxResults set, ...
0
votes
1
answer
1k
views
GORM fetch and update in batches
I need to update a single property on a large set of data in Oracle database with grails 2.5
Right now my code looks similarly to this:
List booksToUpdate = []
boolean moreBooks = true
...
0
votes
1
answer
175
views
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 ...
0
votes
1
answer
165
views
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 ...
1
vote
0
answers
130
views
Hibernate selecting data for spesific column with detached criteria
I have a simple service method to get customer from db when the customer name is 'John'.But customer name is not primary key so i cannot use getbyid kind of stuff.
My dao class name is customerDao ...
0
votes
0
answers
441
views
Hibernate Criteria DetachedCriteria and Subquery
DetachedCriteria cr = DetachedCriteria.forClass(DealerSales.class).setProjection(Property.forName("dealerCode"));
cr.add(Restrictions.eq("countryCode",01));
Criteria cr1 = session.createCriteria(...
0
votes
0
answers
252
views
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
...
1
vote
1
answer
2k
views
Hibernate java Criteria query for instances with multiple collection members like tag
Please help me write a Java Criteria-object query to find all items with collections that have all desired members. Basically, I need to "and" the condition, not "or" it. This is exactly like SO ...
4
votes
0
answers
835
views
grails 3.3 gorm where query with projection count() different than list().size()
According to the Gorm 6 documentation section 7.4 the Where Query returns a DetachedCriteria, which provides a method count() that is supposed to return the number of records returned by the query. ...
1
vote
0
answers
1k
views
java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Long (Hibernate)
I am trying to run a subquery in hibernate like this:-
DetachedCriteria cartProductIds = DetachedCriteria.forClass(UserCart.class,"usercart")
.add(Restrictions....
0
votes
0
answers
53
views
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 ...