0
所以我有2個類具有多對多關聯。當數據庫生成時,我得到2個連接表:user_link_sections和link_section_users。第一個我期待的,但不知道爲什麼第二個連接表生成。 Grails只使用第一個。我是groovy/grails的noobie,但試着按照文檔來設置它。任何幫助表示讚賞!Groovy Grails多對多關聯創建2個連接表
這裏是我的領域類的聲明...
class User {
transient springSecurityService
// Custom Attributes
String firstName
String lastName
String email
String company
String phone
Date dateCreated
Date lastUpdated
static hasMany = [linkSections: LinkSection]
String username
String password
boolean enabled
boolean accountExpired
boolean accountLocked
boolean passwordExpired
}
和
class LinkSection {
String name
String description
Date dateCreated
Date lastUpdated
List links = new ArrayList()
static belongsTo = User
static hasMany = [links: Link, users: User]
static constraints = {
name blank: false
description(maxSize: 10000)
}
static mapping = {
links cascade: "all,delete-orphan"
}
}
感謝德米特里的迴應。我在上面的代碼中有belongsTo ...我現在允許它在啓動時刪除/重新創建表(我仍然處於繁重的開發模式)。任何其他想法? – matmer
我知道現在我相信什麼。這是你的第二點 - 我認爲使用drop/recreate設置會刪除所有表,但它顯然只會刪除它應該存在的表。我清除了額外的表格,並且在運行時沒有重新生成表格。問題解決了! – matmer