Reputation: 757
Kindly, Convert this below hql query to GORM either using criteria or using some API. I am new to grails and I searched enough but I did't get any positive solution for this forgive me if it is simple.
MappingDetail.executeQuery("select map.id from MappingMaster as map where map.id = (select mapdetail.id from MappingDetail as mapdetail where mapdetail.rawdata_template.id=(select rawdata.id from RawDataMasterTemplate as rawdata where rawdata.name like :name))",[name:'%Rick%'])
Upvotes: 0
Views: 468
Reputation: 4606
Test this:
MappingMaster.withCriteria {
createAlias 'mappingDetail', 'mp'
createAlias 'mp.rawDtaMasterTemplate', 'rd'
projections {
property 'id'
}
ilike 'rd.name', '%Rick%'
}
Upvotes: 1
Reputation: 577
Why do you have to use criteria here? I think this is the select where you use HQL instead.
def raw = RawDataMasterTemplate.findByNameLike('%Rick%')
def detail = MappingDetail.findByRawdata_template(raw)
def master = MappingMaster.get(detail?.id)
Upvotes: 1