-
-
Notifications
You must be signed in to change notification settings - Fork 98
/
Copy pathSessionFactorySession.go
81 lines (74 loc) · 2.39 KB
/
SessionFactorySession.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
package GoMybatis
import (
"github.com/zhuxiujia/GoMybatis/stmt"
"github.com/zhuxiujia/GoMybatis/tx"
"github.com/zhuxiujia/GoMybatis/utils"
)
type SessionFactorySession struct {
Session Session
Factory *SessionFactory
}
func (it *SessionFactorySession) Id() string {
if it.Session == nil {
return ""
}
return it.Session.Id()
}
func (it *SessionFactorySession) Query(sqlorArgs string) ([]map[string][]byte, error) {
if it.Session == nil {
return nil, utils.NewError("SessionFactorySession", " can not run Id(),it.Session == nil")
}
return it.Session.Query(sqlorArgs)
}
func (it *SessionFactorySession) Exec(sqlorArgs string) (*Result, error) {
if it.Session == nil {
return nil, utils.NewError("SessionFactorySession", " can not run Exec(),it.Session == nil")
}
return it.Session.Exec(sqlorArgs)
}
func (it *SessionFactorySession) QueryPrepare(sqlorArgs string, args ...interface{}) ([]map[string][]byte, error) {
if it.Session == nil {
return nil, utils.NewError("SessionFactorySession", " can not run Id(),it.Session == nil")
}
return it.Session.QueryPrepare(sqlorArgs, args...)
}
func (it *SessionFactorySession) ExecPrepare(sqlorArgs string, args ...interface{}) (*Result, error) {
if it.Session == nil {
return nil, utils.NewError("SessionFactorySession", " can not run Exec(),it.Session == nil")
}
return it.Session.ExecPrepare(sqlorArgs, args...)
}
func (it *SessionFactorySession) Rollback() error {
if it.Session == nil {
return utils.NewError("SessionFactorySession", " can not run Rollback(),it.Session == nil")
}
return it.Session.Rollback()
}
func (it *SessionFactorySession) Commit() error {
if it.Session == nil {
return utils.NewError("SessionFactorySession", " can not run Commit(),it.Session == nil")
}
return it.Session.Commit()
}
func (it *SessionFactorySession) Begin(p *tx.Propagation) error {
if it.Session == nil {
return utils.NewError("SessionFactorySession", " can not run Begin(),it.Session == nil")
}
return it.Session.Begin(p)
}
func (it *SessionFactorySession) Close() {
var id = it.Id()
var s, _ = it.Factory.SessionMap.Load(id)
if s != nil {
if it.Session != nil {
it.Session.Close()
}
it.Factory.SessionMap.Delete(id)
}
}
func (it *SessionFactorySession) LastPROPAGATION() *tx.Propagation {
return it.Session.LastPROPAGATION()
}
func (it *SessionFactorySession) StmtConvert() (stmt.StmtIndexConvert, error) {
return it.Session.StmtConvert()
}