ドキュメントhttp://grails.org/doc/latest/guide/GORM.html#lockingに示されているように、クレテリアに悲観的ロックを追加しようとしました が、例外がありました:
「エラー util.JDBCExceptionReporter - 機能がサポートされていません: "FOR UPDATE && JOIN"; SQL ステートメント: ... org.hibernate.exception.GenericJDBCException: クエリを実行できませんでした」
次の 2 か所にロックを追加しようとしました。
def ParentInstance = Parent.createCriteria().get {
Childs {
idEq(ChildInstance.id)
lock true
}
と
def ParentInstance = Parent.createCriteria().get {
Childs {
idEq(ChildInstance.id)
}
lock true
}
追加の質問: アソシエーションを悲観的にロックするのは正しい方法ですか?
ありがとうございました
ドメイン
class Parent{
static hasMany = [Childs:Child]
}
class Child{
}
データソース.groovy
dataSource {
pooled = true
driverClassName = "org.h2.Driver"
username = "sa"
password = ""
}
hibernate {
cache.use_second_level_cache = true
cache.use_query_cache = false
cache.region.factory_class = 'net.sf.ehcache.hibernate.EhCacheRegionFactory'
}
// environment specific settings
environments {
development {
dataSource {
dbCreate = "update" // one of 'create', 'create-drop', 'update', 'validate', ''
url = "jdbc:h2:myApp_prodDb;MVCC=TRUE"
}
}
test {
dataSource {
dbCreate = "update"
url = "jdbc:h2:mem:myApp_testDb;MVCC=TRUE"
}
}
production {
dataSource {
dbCreate = "update"
url = "jdbc:h2:myApp_prodDb;MVCC=TRUE"
pooled = true
properties {
maxActive = -1
minEvictableIdleTimeMillis=1800000
timeBetweenEvictionRunsMillis=1800000
numTestsPerEvictionRun=3
testOnBorrow=true
testWhileIdle=true
testOnReturn=true
validationQuery="SELECT 1"
}
}
}
}