我的Alert
有很多Location
个对象,我有联接表alert_locations
。
生成的列为:
alerts_locations_id
(我希望这是alert_id
)
location_id
这是我的域名对象:
class Alerts {
static hasMany = [locations:Locations,notifications:Notifications]
Date alertDateTime
String pest
String crop
static constraints = {
alertDateTime (blank:false)
pest (blank:false)
crop (blank:false)
}
}
答案 0 :(得分:3)
static mapping = {
locations joinTable:[column:"location_id", key:"alert_id"]