AutoIncrement列带ID插入数据时没有Commit
业务场景中,需要预留(1 ~ 100)的ID给系统规则使用。所以会先使用插入将AutoIncrement列的id偏移到一个特定的值(如:100),然后“带ID调用Insert插入系统规则”。 当带ID插入时,由于没有commit,会被rollback掉。
This commit is contained in:
parent
23be940bad
commit
95356ac403
|
@ -353,6 +353,7 @@ func (session *Session) insertStruct(bean interface{}) (int64, error) {
|
|||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
}
|
||||
if needCommit {
|
||||
if err := session.Commit(); err != nil {
|
||||
return 0, err
|
||||
|
@ -361,7 +362,6 @@ func (session *Session) insertStruct(bean interface{}) (int64, error) {
|
|||
if id == 0 {
|
||||
return 0, errors.New("insert successfully but not returned id")
|
||||
}
|
||||
}
|
||||
|
||||
defer handleAfterInsertProcessorFunc(bean)
|
||||
|
||||
|
|
Loading…
Reference in New Issue