我有一個域名爲:的Grails /休眠:與給定的標識符的行存在
class Author {
String id
static hasMany = [accounts: Account]
static belongsTo = Account
static mapping = {
accounts joinTable: [name: "SOMETABLE", key: 'SOMEFIELD'],
ignoreNotFound: true
}
static constraints = {}
}
我收到以下錯誤,當沒有記錄被發現。我嘗試了ignoreNotFound,它不工作。
error message: accounts=org.hibernate.ObjectNotFoundException:
No row with the given identifier exists:
[com.myapplication.Account#123465489785]
它試圖選擇連接2記錄,你沒有訪問插入數據庫時發生。 請問有沒有解決辦法?
我知道這意味着Author表中沒有行存在。但是有沒有辦法讓Grails忽略它?我們可以告訴Grails只返回一個空列表嗎? – user2679352
你想做什麼?保存作者? –
這是一個遺留數據庫。我正在閱讀記錄。我們不會更新任何記錄。有一個多對多的關係,這就是爲什麼我必須指定joinTable。 – user2679352