Query on domain object's property return null even though record exist in DB

10 views
Skip to first unread message

Shruti Agrawal

unread,
Sep 26, 2016, 11:48:10 AM9/26/16
to Grails User Group
I didn't had more meaningful way to highlight issue in subject but here is the explanation.

Suppose I have following domain object

Class Face{
static mapping = {
 cache true
}
 Nose nose

}

Class Nose{
static mapping = {
 cache true
}
 String type
 String externalId
}

Now, when I query on Face as follows

Face face = Face.find("from Face f where f.nose.externalId = :externalId", [externalId:"878781"])

Here suppose the all relevant record do exist in DB. So for the first time it return me the correct domain object but on subsequent query return me the null object. I totally get stumped with this behaviour. 

This query is in service.

Please help me to find out what is wrong from my end.

Thanks a lot.
Reply all
Reply to author
Forward
0 new messages