重用session的问题 #1013
Labels
No Label
backport/done
backport/v1
blocked
db
oracle
db
sqlserver
duplicate
feature
cache
frontport/done
frontport/main
invalid
kind
breaking
kind
bug
kind
build
kind
dependencies
kind
docs
kind
driver
kind
enhancement
kind
feature
kind
performance
kind
proposal
kind
question
kind
refactor
kind
testing
need
feedback
need
test
proposal:accepted
RaspBerry Pi
regression
skip-changelog
upstream
wip
wontfix
No Milestone
No Assignees
1 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: xorm/xorm#1013
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
当前遇到的问题:session完成以后,就已经提交了,但是还想用到这个ssion的话,就不能再用了.因为现在我们的项目中,session是在model中传递的,但是事务提交以后,session就结束了,想再次使用这个session的话,就执行不了了,数据库会报Transaction has already been committed or rolled back 这样的错
分析的原因是:发现xorm源码中,Commit()和Rollback()方法里面发现没有把isAutoCommit设置为true,因此会出现事务提交或回滚后事务已经关闭了
https://github.com/go-xorm/xorm/blob/master/session_tx.go#L23
https://github.com/go-xorm/xorm/blob/master/session_tx.go#L33
解决方案如图所示,能否在session_tx.go文件中的Commit()和Rollback()方法里加上session.isAutoCommit = true这一段代码
与 #1008 重复