You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This documentation seems to show that the column should be the ID of the other class, but it appears that it is the ID of the current class. I created a test to demonstrate this.
classA {
Long id
String value
static hasMany = [
b: B,
]
static mapping = {
id generator: 'assigned'
b column: 'B_ID', joinTable: 'A_B'
}
staticdefallJoins() {
def result
withSession { session->def q = session.createSQLQuery("SELECT A_ID, B_ID FROM A_B")
result = q.list()
}
return result
}
}
classB {
Long id
String value
static belongsTo = A
static hasMany = [
a: A,
]
static mapping = {
id generator: 'assigned'
a column: 'A_ID', joinTable: 'A_B'
}
}
The documentation at http://gorm.grails.org/latest/hibernate/manual/index.html#_many_to_many_mapping shows how to change the column name & join table for a many-to-many relationship by creating a mapping in both classes:
This documentation seems to show that the
column
should be the ID of the other class, but it appears that it is the ID of the current class. I created a test to demonstrate this.This test fails with the IDs in the incorrect order (the result is
[[201,101]]
)The text was updated successfully, but these errors were encountered: