Creating criteria based queries with GORM, Hibernate or Grails
Questions tagged [createcriteria]
105 questions
0
votes
1 answer
Null value while doing createcriteria
def c = Employee.createCriteria()
return c.list {
} as Set;
The above code is returning me all the objects of the table.
But when I am trying to filter it like, I am getting null values :
def c = Employee.createCriteria()
return c.list {
…

Asish
- 409
- 2
- 4
- 17
0
votes
1 answer
Missing methods trying to create a criteria
My Employee domain has an associated division, department, and position, which are all domains themselves. This relationship is coded as
class Employee
{
...
String firstName
String lastName
Position position
Division division
…

mjswartz
- 715
- 1
- 6
- 19
0
votes
2 answers
Grails - createCriteria returns javassist instances instead of specific domain
I'm using the following criteria to retrieve all Person objects that have certain roles granted (in the PersonService):
@Transactional(readOnly = true)
List findAllByRoles(authorities) {
Person.createCriteria().list {
personRoles {
…

gabriel
- 347
- 3
- 18
0
votes
1 answer
Grails 2.4.4: createCriteria: how to use the sum of a date and integer in order?
Domain Class:
class Record {
Date date
Integer days
}
Code:
def record.createCriteria().list {
order( "DATE_ADD( date, INTERVAL days DAY )", "asc" )
}
Question:
Obviously this doesn't work, but I need to know if there is a way to order…

havoc74
- 33
- 5
0
votes
1 answer
Grails/CreateCriteria - compare two lists
By using the CreateCriteria, I want to compare two lists and check if there are at least one element in groups present in users.
Is there something like eq to perform that?
Domain
class User {
String login
static hasMany = [groups =…

Jils
- 783
- 5
- 12
- 32
0
votes
1 answer
CreateCriteria - Use logical OR in hasMany association
I want to get instances who contain in their lists (firstsList or SecondsList) a specific user.
In my solution, the create criteria takes into account only the first list of users.
It seems to be a bad usage of the logical OR
Domain
class ClassA {
…

Jils
- 783
- 5
- 12
- 32
0
votes
1 answer
Use create criteria on multiple associations
What is the most efficient solution to get the status attribut value from a ClassD instance by having its name attribut value and starting from the ClassA instance?
I can use on loop in each list, but I think there is a better solution by using a…

Jils
- 783
- 5
- 12
- 32
0
votes
2 answers
What is the equivalent mysql statement of criteria code shown below
Im tryingto understand the code shown below
Criteria criteria = session.createCriteria(Payables.class);
criteria.add(Restrictions.eq("companyId", companyId));
criteria.createAlias("makePayment", "makePayment");
if…

user3714598
- 1,733
- 5
- 28
- 45
0
votes
1 answer
Dynamicly Displaying Users in Grails App
So I have the ability to list all users in from a database in a view, but I would like to list them alphabetically and by tab. For example, I'll have a tab for "All", "A", "B", "C", etc. What I would like to happen is that when the user clicks the…

mjswartz
- 715
- 1
- 6
- 19
0
votes
1 answer
grails criteria eq not working
I have problem with criteria in grails
I have a domain User and another domain Conversation
Conversation has Many Participants(domain)
When I do like this:
def c = Conversation.createCriteria();
c.get{
createAlias('participants',…

Shiv Kumar
- 1
- 1
0
votes
1 answer
Grails hibernate create criteria multiple AND OR Conditions
I was able to do 3 conditions query using grails/Hibernate create Criteria as follows
def c = Domain.createCriteria()
c.list(max: map.max ?: 10, offset: map.offset ?: 0) {
and {
"colStatus" in status
…

MaSu
- 23
- 2
- 4
0
votes
1 answer
Grails - Use logical OR in CreateCriteria
Starting with the following Domains:
class Person {
String login
String name
}
class MyDomain {
Person creator
static hasMany = [userlist:Person]
}
I wrote a critera to retreive all MyDomainIntances where I'm as creator OR where…

Jils
- 783
- 5
- 12
- 32
0
votes
1 answer
Grails withCriteria And/Or cases?
I have the following Grails withCriteria structure:
allInfo = Scholarship.withCriteria {
between('gpa', '0', gpa)
grades {
idEq year
}
scholarshipCounties {
eq('county.id', county)
}
majors {
idEq major
…

connor moore
- 611
- 1
- 8
- 18
0
votes
1 answer
Grails - createCriteria: associations + not + ilike
some how a Criteria: associations + not + ilike does not give a good result.
I still get cases with actions that have the status I don't want in the result.
Any clue or suggestion for other approaches?
I have this in controller:
def pgp =…

BioBier
- 84
- 1
- 11
0
votes
2 answers
Sort by property in one-to-many association
I have the following scenario (Domain classes)
class Request {
String title
List statusUpdates
static hasMany = [statusUpdates: StatusUpdate]
}
and
class StatusUpdate {
Date dateCreated
String statusFrom
…

Danilo
- 2,676
- 7
- 32
- 36