Grails GORMwithTransaction
でgroovy.sql.Sql
、ストアドプロシージャのSQL呼び出しを内部に配置すると、同じ接続が使用されますwithTransaction
か?例えば:
私がコマンドを持っているとしましょう:
@Validateable
class MyCommand {
List<MyModel> listOfModel
}
そして、私はこのコマンドを処理するサービスを持っています
class MyService {
def dataSource
def handleCommand( MyCommand command ) {
MyModel.withTransaction { status ->
for( MyModel m : command.listOfModel ) {
if( !m.save() ) {
status.setRollbackOnly()
throw new MyException(m.errors)
}
}
//now I need to call a stored proc. This will use the same connection?
//withTransaction will commit the call?
Sql s = new Sql(dataSource)
s.call('my_stored_proc')
}
}
}