# 嵌套事务相关API * BeginTrans(transactionDefinition ...int) 创建一个事务 ~~~ session.BeginTrans() //默认创建事务类型为 PROPAGATION_REQUIRED session.BeginTrans(xorm.PROPAGATION_SUPPORTS) //创建事务类型为 PROPAGATION_SUPPORTS ~~~ * CommitTrans() 提交事务 ~~~ tx.CommitTrans() ~~~ * RollbackTrans() 回滚事务 ~~~ tx.RollbackTrans() ~~~ * SavePoint(savePointID string) 设置SavePoint ~~~ tx.SavePoint("xorm_save") ~~~ * RollbackToSavePoint(savePointID string) 回滚至SavePoint ~~~ tx.RollbackToSavePoint("xorm_save") ~~~ * Session() 获得当前事务所在Session,以便进行后续数据库操作,当PROPAGATION_REQUIRES_NEW或PROPAGATION_NOT_SUPPORTED类型事务时候,都有可能创建新Session进行后续操作,该函数可以获得这个新Session。建议事务中都使用本函数获取Session进行后续操作。 ~~~ tx.Session() ~~~