如果我将存储过程的 sql 调用放在Grails GORM中withTransaction
,是否会使用相同的连接?例如:groovy.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')
}
}
}