Creating criteria based queries with GORM, Hibernate or Grails
Questions tagged [createcriteria]
105 questions
1
vote
0 answers
Hibenate create criteria for Joins on Secondary keys
Is it possible to do something like this with hibernate criteria.
select * from A inner join
B on A.customer_id = B.id left outer join
C on A.customer_id = C.customer_id;
Table A and C have a attribute customer_id,
Table B primary key is id which…

Shivam Tandon
- 11
- 1
1
vote
1 answer
session.getCurrentSession().createCriteria(MyClass.class) deprecated how to use .addOrder() now
I have been developing with:
public List getAllDepartmentTypes() {
return session.getCurrentSession()
.createCriteria(DepartmentType.class)
.addOrder(Order.asc("department_type_name"))
…

Gourav Verma
- 13
- 3
1
vote
1 answer
Override join 'ON' primary column in Criteria
I am using Criteria and I want to explicitly tell hibernate to join on specific columns rather than the primary and foreign key columns. My code is
CreateCriteria("Application")
.CreateCriteria("Application.Address", "Address",…

Jack
- 57
- 7
1
vote
1 answer
NHibernate CreateCriteria not working correctly with association and dates
I am trying to create an association to load a list of parent objects based on a child objects date field. I only want parent objects where the date is >= a given date.
The problem is, when I use either today's date or the day before, it returns the…

chipman
- 11
- 1
1
vote
1 answer
Why doesn't session.CreateCriteria(typeof(...)) fail for an unmapped type?
For every entity that I create I write a unit test that just loads one record from the database to see if the query works and the data can be set on the entity correctly. You could see this as a unit test for the basic mapping. This should also…

Koen
- 3,626
- 1
- 34
- 55
1
vote
1 answer
Hibernate criteriaQuery createAlias equivalent
I am looking at upgrading my hibernate to use JPA criteriaQuery :-( and need to find a way to implement an alias in JPA eg:
@Entity
public class MyClass {
....
@ManyToOne(..)
public MyDetail getMyDetail() {
return myDetail;
}
}
Criteria criteria…

gregh
- 171
- 2
- 8
1
vote
4 answers
How to Solve : org.hibernate.HibernateException: createCriteria is not valid without active transaction
I'm learning Spring 4.0 + Hibernate 4.3 integration and I'm very new to both technologies. I'm getting errors after solving previous. Anyone please guide me to complete this successfully.
applicationContext.xml

Ravi
- 30,829
- 42
- 119
- 173
1
vote
0 answers
grails createCriteria() on hasMany with different conditions
I want to query for all InvItems, which has multiple Attributes key/values pairs, that should fullfill my where condition.
class InvItem{
static hasMany = [ attributes : InvAttributes ]
}
class invAttributes{
String key
String valueShort
…

physi
- 151
- 8
1
vote
0 answers
createCriteria Lock Fails Unit Test
I have a query in a service method of a unit test that I'm calling lock true on, but every time I run the unit test with the lock true in, the unit test fails and gives the following error.
groovy.lang.MissingMethodException: No signature of method:…

RobStemen
- 367
- 1
- 13
1
vote
1 answer
Case-insensitive order on nested properties
Say, I have two domain classes:
class Foo {
Bar bar
Long baz
}
class Bar {
String name
}
And I have a call coming into a createCriteria that wants to sort by the Bar's name (or any other valid property that the client wants to sort by),…

Igor
- 33,276
- 14
- 79
- 112
1
vote
1 answer
Convert SQL Statement in Criteria query
I need some help so that I can convert My sql in grails criteria query:
String query = """select * from personal_detail as pd
where pd.id in (
select u.personal_detail_id from user u where u.id in
(
SELECT ur.user_id FROM…

ABC
- 4,263
- 10
- 45
- 72
1
vote
2 answers
CreateCriteria inside Expression.Disjunction() fluent nhibernate
criteriaCount.CreateCriteria(AdvertisementsProperties.City.ToString())
.Add(Expression.Like(CitiesProperties.Name.ToString(), query, MatchMode.Anywhere))
.Add(Expression.Like(CitiesProperties.SlovenianName.ToString(),…

senzacionale
- 20,448
- 67
- 204
- 316
1
vote
1 answer
How to distinct list from createCriteria?
I have a problem ..to distinct my list..this is my code..
domain :
class City {
String city
static constraints = {
city(blank:false,unique:false)
}
}
class Financial {
String financial
String description
static…
user2809386
1
vote
1 answer
Grails Create Critera and Listing single or specified column/s value only?
I grails i m trying to fetch a lookup value from the database and i want to list a list of single column value that is "Value" column .
private Static Final String Custom = "Custom" //lie in class Constants
LookUp.createCriteria.list() {…

Develop4Life
- 7,581
- 8
- 58
- 76
1
vote
0 answers
Turn SQL String into Grails CreateCriteria
Hi everyone i have this Grails Code:
free_search = ReportFree.createCriteria().list {
or {
report{
ilike("description", "%${params.search}%")
ilike("type", "%${params.search}%")
…

Max Jando
- 11
- 3