From 9681be3e4d1f13e2b4ba2bec4d312131eb11e87c Mon Sep 17 00:00:00 2001
From: Lunny Xiao <xiaolunwen@gmail.com>
Date: Tue, 30 Jul 2019 16:35:36 +0800
Subject: [PATCH] fix bugs (#1375)

---
 session_find.go | 2 ++
 session_get.go  | 4 ++++
 2 files changed, 6 insertions(+)

diff --git a/session_find.go b/session_find.go
index d3fc0d30d..6b8aa469d 100644
--- a/session_find.go
+++ b/session_find.go
@@ -63,6 +63,8 @@ func (session *Session) FindAndCount(rowsSlicePtr interface{}, condiBean ...inte
 }
 
 func (session *Session) find(rowsSlicePtr interface{}, condiBean ...interface{}) error {
+	defer session.resetStatement()
+
 	if session.statement.lastError != nil {
 		return session.statement.lastError
 	}
diff --git a/session_get.go b/session_get.go
index ad2627f4b..8901357e2 100644
--- a/session_get.go
+++ b/session_get.go
@@ -24,6 +24,8 @@ func (session *Session) Get(bean interface{}) (bool, error) {
 }
 
 func (session *Session) get(bean interface{}) (bool, error) {
+	defer session.resetStatement()
+
 	if session.statement.lastError != nil {
 		return false, session.statement.lastError
 	}
@@ -75,6 +77,8 @@ func (session *Session) get(bean interface{}) (bool, error) {
 	if context != nil {
 		res := context.Get(fmt.Sprintf("%v-%v", sqlStr, args))
 		if res != nil {
+			session.engine.logger.Debug("hit context cache", sqlStr)
+
 			structValue := reflect.Indirect(reflect.ValueOf(bean))
 			structValue.Set(reflect.Indirect(reflect.ValueOf(res)))
 			session.lastSQL = ""