[size=medium]如果要让java来管理事务,那么在存储过程里不能写提交(commit work)和回滚(rollback)的代码,否则,存储过程会在一个单独的事务里提交。
[b]Spring的TransactionTemplate和Sybase存储过程共享同一事务要点:[/b]
1)确保存储过程里不能写提交(commit work)和回滚(rollback)的代码
2)确保存储过程的事务模式是chained
--change transaction mode to chained since application is forced to use chained transaction mode due to support transaction
--check all stored procedures' transaction mode
sp_procxmode
--change specified stored procedure's transaction mode
sp_procxmode mystoreProcedureXXX, 'chained'
3)在java方法里要用spring的类来调用存储过程
new SimpleJdbcCall(getJdbcTemplate()).withProcedureName("procedureName").execute(inParamMap);
[/size]
[b]Spring的TransactionTemplate和Sybase存储过程共享同一事务要点:[/b]
1)确保存储过程里不能写提交(commit work)和回滚(rollback)的代码
2)确保存储过程的事务模式是chained
--change transaction mode to chained since application is forced to use chained transaction mode due to support transaction
--check all stored procedures' transaction mode
sp_procxmode
--change specified stored procedure's transaction mode
sp_procxmode mystoreProcedureXXX, 'chained'
3)在java方法里要用spring的类来调用存储过程
new SimpleJdbcCall(getJdbcTemplate()).withProcedureName("procedureName").execute(inParamMap);
[/size]