diff --git a/hasaki-gen-crud/template.go b/hasaki-gen-crud/template.go index 804e541..0dc7087 100644 --- a/hasaki-gen-crud/template.go +++ b/hasaki-gen-crud/template.go @@ -102,16 +102,20 @@ func (TempLowHead3A60 *Temp3A60) Load() (err error) { func (TempLowHead3A60 *Temp3A60) Data() (data []Temp3A60) { q, args := TempLowHead3A60.whereData() _xorm := TempLowHead3A60.getXorm() + session := _xorm.NewSession() + defer func() { + session.Close() + }() if q != "" { - _xorm.Where(q, args...) + session = session.Where(q, args...) } order := TempLowHead3A60.orderData() if order != "" { - _xorm.OrderBy(order) + session = session.OrderBy(order) } - _xorm.Find(&data) + session.Find(&data) for i := range data { data[i].init() } @@ -122,16 +126,20 @@ func (TempLowHead3A60 *Temp3A60) Data() (data []Temp3A60) { func (TempLowHead3A60 *Temp3A60) PageData(page, pageSize int) (data []Temp3A60, count int64) { q, args := TempLowHead3A60.whereData() _xorm := TempLowHead3A60.getXorm() + session := _xorm.NewSession() + defer func() { + session.Close() + }() if q != "" { - _xorm.Where(q, args...) + session = session.Where(q, args...) } order := TempLowHead3A60.orderData() if order != "" { - _xorm.OrderBy(order) + session = session.OrderBy(order) } - count, _ = _xorm.Limit(pageSize, page*pageSize).FindAndCount(&data) + count, _ = session.Limit(pageSize, page*pageSize).FindAndCount(&data) for i := range data { data[i].init() }