多表事务
session := torm.GetDbInstance("default", "writer").GetSession()
defer session.Close()
session.Begin()
dao := NewDbtestDao(session)
param := torm.CastToParamIn([]int{1})
data, err := dao.Get(param)
row := data[0]
row.Param1 = 100
row.Param2 = "update1"
dao.Update(&row)
daoAnother := NewDbtestAnotherDao(session)
param = torm.CastToParamIn([]int{2})
data, err = daoAnother.Get(param)
row = data[0]
daoAnother.Delete(&row)
e := session.Commit()
if e != nil {
session.Rollback()
}
- 多表事务,需在同一实例上