我遇到问题。如果可以,请你帮助我。从多个域中查询Grails
我称3个领域:
class DomainA {
long id
String propA1
String propA2
static hasMany = [domaniBs:DomainB]
}
class DomainB {
long id
String propB1
String propB2
static belongsTo = [forgeinKeyToDomainA:DomainA]
static hasMany = [domaniCs:DomainC]
}
class DomainC {
long id
String propC1
String propC2
static belongsTo = [forgeinKeyToDomainB:DomainB]
}
想从DomainC得到所有记录中propA1 = “值1”
成像SQL代码:
Select DomainC.*
from DomainA,DomainB,DomainC
where DomainA.id=DomainB.forgeinKeyToDomainA
and DomainB.id=DomainC.forgeinKeyToDomainB
and DomainA.propA1="value1"
可以执行SQL代码在Grails中,但希望使用Hibernate查询。
你是什么意思 “可以在Grails的执行,并希望使用Hibernate的” 是什么意思?希望在HQL中使用?或者是别的什么? – acdcjunior 2013-04-27 03:03:02
我在grails中安装了hibernate插件,并且我希望Hibernate方法可以完成这些工作。 DEF instantAlerts = Alert.where {频繁==(Frequently.findByID( “即时”))}。列表() instantAlerts.each {instantAlert-> \t \t \t DEF resultsInstantAlerts = KetQuaThongBaoEmail.where {sendStatus == 0 } .LIST() \t \t \t resultsInstantAlerts.each {result-> \t \t \t \t emailService.sendInstantNotification(result.alert.user.email,result.food) \t result.sendStatus = 1个//更新被发送 \t result.save(flush:true) \t} } – 2013-04-27 04:08:31
我完成了我的任务,但我搜索其他方式(搜索更好的方式) – 2013-04-27 04:22:51