Creating criteria based queries with GORM, Hibernate or Grails
Questions tagged [createcriteria]
105 questions
0
votes
1 answer
Load collections eagerly in NHibernate using Criteria API
I have an entity A which HasMany entities B and entities C. All entities A, B and C have some references x,y and z which should be loaded eagerly.
I want to read from the database all entities A, and load the collections of B and C eagerly using…

Zuber
- 577
- 1
- 11
- 29
0
votes
1 answer
Criteria - searching against two columns concatenated
I am in need of a way to search against two concatenated columns with a Criteria in a grails project that I've been brought onto. The two columns make up a subject code for a University; a three-alpha-character code and a three-digit number. e.g.…

Cyntech
- 5,362
- 6
- 33
- 47
0
votes
1 answer
Grails filter criteria, criteria queries, only explicit items, special scenario
I already searched a lot but I didn't found a solution yet. I guess I really need your help. My problem is about filtering with a "special" goal. Let's say we have got a few Persons, who have got many skills. I am able to filter this Persons by name…

waywayway
- 53
- 4
0
votes
1 answer
Criteria on domain which does not have reference of another domain
I have domain like
class Book {
Author author
String title
}
and another
class ListingTracking {
Book book
String oldVal
String newVal
Date modDate
static constraints = {
}
}
and now I need all those…

ABC
- 4,263
- 10
- 45
- 72
0
votes
1 answer
Grails Detached Criteria with Composite key
Domain Setup
.
Study {
Long id
String name
Site site
USState state
...
}
.
Site {
Long id
String name
...
}
.
Resource {
Long id
String name
Boolean active
USState state
...
}
.
SiteResource {
…

Vaesive
- 105
- 1
- 11
0
votes
4 answers
NHibernate query CreateCriteria
Is it possible to chose what columns I want in return from Session.CreateCriteria() ?
egz.:
var x = session.CreateCriteria();
x.CreateAlias("EmployeePosition", "employeePosition");
x.Add(Restrictions.Eq("employeePosition.Name",…

Jacob
- 914
- 2
- 10
- 30
0
votes
1 answer
Grails createCrieteria on super class with conditions on subclasses
I have been trying for this. But don't know it is possible or not. I need to list records by writing a crieria query on super class with conditions on subclass.
Say, Cats, Dogs extends Animal class. I need to list all animals but dogs with black…

CSR
- 770
- 1
- 14
- 30
0
votes
2 answers
Grails - Perform WHERE IN subquery using CreateCriteria
I have a domain class like the following:
class Blog {
String name
Set tags = []
static constraints = {}
static hasMany = [tags: String]
}
I have a search routine, where I would like to be able to filter based on both the name…

cweston
- 11,297
- 19
- 82
- 107
0
votes
1 answer
List of instances with minimal date of their group
I'm working on a Java project, using Hibernate to administrate data on a SQL database.
I try to fetch a list of instances from the Database, that have a minimal timestamp of the group they share. The group is modeled by a container.
Here is a…
user3824685
0
votes
3 answers
JPA createQuery working but createCriteria not working session is closed error
I am trying to use Criteria API from Hibernate by getting hibernate session from EntityManager as following
public org.hibernate.Criteria getCriteria() {
HibernateEntityManager hem = em.unwrap(HibernateEntityManager.class);
…

Niraj Patel
- 33
- 1
- 9
0
votes
1 answer
Grails - how to use "OR" in CreateCriteria
I have this Criteria:
def myList = BAS.createCriteria().list () {
projections { distinct ( "id" )
property("date")
property("id")
}
carList{
eq("login",login)
}
ccList{
eq("cmd",false)
}
…

Jils
- 783
- 5
- 12
- 32
0
votes
1 answer
How to make a "deep" transformation in Grails withCriteria contains projection?
I am using Grails 2.2.4 to build a web application, and now I am having a complex problem with Grails withCriteria operation. I have 3 classes as below:
class Person {
int id
String name
Set cars = [] // One-to-many relationship
…

Đinh Hồng Châu
- 5,300
- 15
- 53
- 90
0
votes
0 answers
querying hasMany relationships with criteria in unit tests grails- mockDomain
I Have this method in my ProyectoInvestigacionController.groovy
def filtrar(){
def consulta="%"+params.consulta.trim()+"%"
if(consulta.isEmpty()==false){
def proyectoInvestigacionInstance=ProyectoInvestigacion.createCriteria().list{
…
0
votes
0 answers
Hibernate DetachedCriteria for this JOIN with 'OR' filters across two tables
For SQL
SELECT PP.m, PP.f, PP.l, PP.c, RP.n as 'RPn' FROM P as PP
INNER JOIN RPP AS RP ON PP.id = RP.id
WHERE PP.m LIKE '%0%' OR PP.f LIKE '%0%' OR PP.l LIKE '%0%' OR RPP.n LIKE '%0%'
I have tried to create this DetatchedCriteria:
…

foamroll
- 752
- 7
- 23
0
votes
1 answer
Join 2 tables with ID using createCriteria()
I have 2 tables p, q I am trying to join it with ID. using createAlias inside createCriteria.list()
Please show me right syntax for the join.

monal86
- 433
- 2
- 11
- 26