user903772
user903772

Reputation: 1562

Grails Join Table column name

My Alert has many Location objects, and I have the join table alert_locations.

The generated columns are:

alerts_locations_id (I want this to be alert_id)

location_id

Here's my domain object:

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)
    }
}

Upvotes: 0

Views: 3677

Answers (1)

doelleri
doelleri

Reputation: 19702

static mapping = {
    locations joinTable:[column:"location_id", key:"alert_id"]

Upvotes: 3

Related Questions