diff --git a/src/main/java/com/github/pagehelper/PageInterceptor.java b/src/main/java/com/github/pagehelper/PageInterceptor.java index 2f645801..b268636c 100644 --- a/src/main/java/com/github/pagehelper/PageInterceptor.java +++ b/src/main/java/com/github/pagehelper/PageInterceptor.java @@ -248,7 +248,9 @@ private Long count(Executor executor, MappedStatement ms, Object parameter, @Override public Object plugin(Object target) { - return Plugin.wrap(target, this); + Object wrapObjet = Plugin.wrap(target, this); + PageMethod.isAddToInterceptors = true; + return wrapObjet; } @Override diff --git a/src/main/java/com/github/pagehelper/page/PageMethod.java b/src/main/java/com/github/pagehelper/page/PageMethod.java index cfc48b12..ddbecdae 100644 --- a/src/main/java/com/github/pagehelper/page/PageMethod.java +++ b/src/main/java/com/github/pagehelper/page/PageMethod.java @@ -26,6 +26,7 @@ import com.github.pagehelper.ISelect; import com.github.pagehelper.Page; +import com.github.pagehelper.PageException; import com.github.pagehelper.util.PageObjectUtil; import java.util.Properties; @@ -36,6 +37,7 @@ * @author liuzh */ public abstract class PageMethod { + public static volatile boolean isAddToInterceptors = false; protected static final ThreadLocal LOCAL_PAGE = new ThreadLocal(); protected static boolean DEFAULT_COUNT = true; @@ -45,6 +47,9 @@ public abstract class PageMethod { * @param page */ public static void setLocalPage(Page page) { + if(!isAddToInterceptors){ + throw new PageException("page helper not added to interceptors!"); + } LOCAL_PAGE.set(page); }