Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

在一个service中调mapper查多次导致方言代理为空 #834

Open
1 task
youglu opened this issue Aug 30, 2024 · 1 comment
Open
1 task

在一个service中调mapper查多次导致方言代理为空 #834

youglu opened this issue Aug 30, 2024 · 1 comment

Comments

@youglu
Copy link

youglu commented Aug 30, 2024

  • 我已在 issues 搜索类似问题,并且不存在相同的问题.

异常模板

使用环境

  • PageHelper 版本: 5.3.1
  • 数据库类型和版本: mysql5.7
  • JDBC_URL: xxx

分页报空指错误

分页参数

public List<Map> statistic(final Map<String,Object> paramMap) {
        // 按同步状态统计
       // final Map<String,Object> paramMap = new HashMap<>();
        paramMap.put("statusStatistic","1");
        paramMap.put("status",1);
        List<Map> result = formSyncTaskMapper.statistic(paramMap);
        paramMap.put("status","0");
        List<Map> inRunResult = formSyncTaskMapper.statistic(paramMap);
        result.addAll(inRunResult);

        paramMap.clear();
        paramMap.put("platformStatistic","1");
        List<Map> platFormResult = formSyncTaskMapper.statistic(paramMap);
        result.addAll(platFormResult);
        return result;
    }

原 SQL

    <select id="statistic" parameterType="java.util.Map" resultType="java.util.Map">
        <if test="statusStatistic != null and status != ''">
            SELECT count(0) taskInfo FROM form_sync_task formTask LEFT JOIN sys_job sysjob ON task_id = job_id
            where sysjob.status = 1
        </if>
        <if test="platformStatistic != null">
            SELECT sync_platform ,count(sync_platform) platformInfo  FROM form_sync_task formTask
            group by sync_platform
        </if>
    </select>

期望的结果:

 

完整异常信息

Caused by: org.apache.ibatis.exceptions.PersistenceException: 
### Error querying database.  Cause: java.lang.NullPointerException
### Cause: java.lang.NullPointerException
	at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:30)
	at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:153)
	at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:145)
	at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:140)
	at sun.reflect.GeneratedMethodAccessor125.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:427)
	... 127 common frames omitted
Caused by: java.lang.NullPointerException: null
	at com.github.pagehelper.PageHelper.beforeCount(PageHelper.java:58)
	at com.github.pagehelper.PageInterceptor.intercept(PageInterceptor.java:119)
	at org.apache.ibatis.plugin.Plugin.invoke(Plugin.java:62)
	at com.sun.proxy.$Proxy221.query(Unknown Source)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.apache.ibatis.plugin.Invocation.proceed(Invocation.java:49)
	at com.union.framework.interceptor.PageDialectInterceptor.intercept(PageDialectInterceptor.java:65)
	at org.apache.ibatis.plugin.Plugin.invoke(Plugin.java:62)
	at com.sun.proxy.$Proxy221.query(Unknown Source)
	at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:151)
	... 133 common frames omitted

其他类型的错误

功能建议

目前发现此情况下会导致分页中方言代事会丢失,导致空指异常。

@abel533
Copy link
Collaborator

abel533 commented Sep 2, 2024

在哪儿调用了分页方法?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants