mybatis-myBatis中的莫名其妙的java.lang.NullPointerException,求指教

问题描述

myBatis中的莫名其妙的java.lang.NullPointerException,求指教

xml:

<!-- ognl访问静态方法的表达式 为@class@method(args),以下为调用Ognl.isNotEmpty()方法,还有其它方法如isNotBlank()可以使用,具体请查看Ognl类 -->

AND SRLNO = '${h_srlno}'

AND URGEDATE = '${h_date}'

    </where>
</sql>
<select id="findBySrlnoDate" parameterType="java.util.HashMap" resultType="com.mf.cntrtmng.entity.BsnsOverdueUrge">
    SELECT
        <include refid="selectId" />
        FROM bsns_overdue_urge
        <include refid="querywheresrlnodate"/>
</select>

DAO:
public BsnsOverdueUrge findBySrlnoDate(Map params) throws DataAccessException;

Serviceimpl:
public boolean exist(Map params) {
System.out.println("=====搜索出来的");
System.out.println(params);
if(bsnsOverdueUrgeDao.findBySrlnoDate(params)==null)
return true;
else
return false;
}

错误日志:
=====搜索出来的
{h_srlno=JH201505281535107052, h_date=20150601}
2015-06-01 15:19:42,922 DEBUG http-bio-8080-exec-3 - Creating a new SqlSession
2015-06-01 15:19:42,922 DEBUG http-bio-8080-exec-3 - Registering transaction synchronization for SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@6d41567b]
2015-06-01 15:19:42,924 DEBUG http-bio-8080-exec-3 - JDBC Connection [jdbc:mysql://localhost:3306/microfinance?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&autoReconnect=true, UserName=root@localhost, MySQL-AB JDBC Driver] will be managed by Spring
2015-06-01 15:19:42,925 DEBUG http-bio-8080-exec-3 - ooo Using Connection [jdbc:mysql://localhost:3306/microfinance?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&autoReconnect=true, UserName=root@localhost, MySQL-AB JDBC Driver]
2015-06-01 15:19:42,928 DEBUG http-bio-8080-exec-3 - ==> Preparing: select count(1) from (SELECT NO, SRLNO, CLNTNO, URGEID, URGENAME, URGEDATE FROM bsns_overdue_urge WHERE SRLNO = 'JH201505281535107052' AND URGEDATE = '20150601') tmp_count
2015-06-01 15:19:42,929 DEBUG http-bio-8080-exec-3 - ==> Parameters:
2015-06-01 15:19:42,930 DEBUG http-bio-8080-exec-3 - Releasing transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@6d41567b]
2015-06-01 15:19:42,930 DEBUG http-bio-8080-exec-3 - Initiating transaction rollback
2015-06-01 15:19:42,931 DEBUG http-bio-8080-exec-3 - Rolling back JDBC transaction on Connection [jdbc:mysql://localhost:3306/microfinance?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&autoReconnect=true, UserName=root@localhost, MySQL-AB JDBC Driver]
2015-06-01 15:19:42,932 DEBUG http-bio-8080-exec-3 - Transaction synchronization rolling back SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@6d41567b]
2015-06-01 15:19:42,932 DEBUG http-bio-8080-exec-3 - Transaction synchronization closing SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@6d41567b]
2015-06-01 15:19:42,933 DEBUG http-bio-8080-exec-3 - Releasing JDBC Connection [jdbc:mysql://localhost:3306/microfinance?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&autoReconnect=true, UserName=root@localhost, MySQL-AB JDBC Driver] after transaction
org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException:

Error querying database. Cause: java.lang.NullPointerException

The error may exist in file [E:SpringSource.metadata.pluginsorg.eclipse.wst.server.coretmp0wtpwebappsmicrofinance20150203WEB-INFclassescommfcntrtmngentitymapperbsnsoverdueurge-mapper.xml]

The error may involve com.mf.cntrtmng.dao.BsnsOverdueUrgeDao.findBySrlnoDate-Inline

The error occurred while setting parameters

Cause: java.lang.NullPointerException

2015-06-01 15:19:42,933 DEBUG http-bio-8080-exec-3 - Returning JDBC Connection to DataSource
at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:73)
at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:365)
at com.sun.proxy.$Proxy11.selectOne(Unknown Source)
at org.mybatis.spring.SqlSessionTemplate.selectOne(SqlSessionTemplate.java:160)
at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:63)
at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:43)
at com.sun.proxy.$Proxy114.findBySrlnoDate(Unknown Source)
at com.mf.cntrtmng.service.impl.BsnsOverdueUrgeServiceImpl.exist(BsnsOverdueUrgeServiceImpl.java:128)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:319)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
at com.sun.proxy.$Proxy115.exist(Unknown Source)
at com.mf.aftrmng.controller.LoanWarnController.showUrgeInfo(LoanWarnController.java:310)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:213)
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:126)
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:96)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:617)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:578)
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:80)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:923)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:852)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:882)
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:778)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:620)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at com.mf.interceptor.HeadInterceptor.doFilter(HeadInterceptor.java:43)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:501)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1040)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:607)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:315)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
at java.lang.Thread.run(Thread.java:662)

从日志里面打印的SQL,可以在数据库中搜索,怎么返回值变成了count(),我不是在xml中配置的返回值类型为一个对象类型么“resultType="com.mf.cntrtmng.entity.BsnsOverdueUrge"?”然后包了莫名其妙的空指针错误,求大神帮忙看看,小弟感激不尽~~

解决方案

FROM bsns_overdue_urge
这两个引用的sql也贴下

解决方案二:

sql里的字段与实体类里要对应,大小写也要注意

时间: 2024-10-30 11:59:28

mybatis-myBatis中的莫名其妙的java.lang.NullPointerException,求指教的相关文章

java.lang.NullPointerException 求帮忙 。。。。。

问题描述 java.lang.NullPointerException 求帮忙 ..... 大神们给我看看为啥空指针吧 2015-05-25 16:20:32,830 ERROR [500.jsp] 72 - <> java.lang.NullPointerException at org.hibernate.hql.ast.util.SessionFactoryHelper.findSQLFunction(SessionFactoryHelper.java:365) at org.hiber

JSP页面中出现的一个异常:org.apache.jasper.JasperException: java.lang.NullPointerException

先把出现的异常情况贴出来吧: type Exception report messagejava.lang.NullPointerException descriptionThe server encountered an internal error that prevented it from fulfilling this request. exception org.apache.jasper.JasperException: java.lang.NullPointerException

HashMap中java.lang.NullPointerException异常问题

问题描述 //添加根结点Iterator<String>Iter=resultMap.keySet().iterator();inti=0;while(Iter.hasNext()){i++;System.out.println(i);StringscCode=Iter.next();if(resultMap.get(Iter.next())!=null){StringscParent=resultMap.get(Iter.next()).toString();System.out.print

hashmap-Java中遇到的一个异常Exception in thread &amp;amp;quot;main&amp;amp;quot; java.lang.NullPointerException

问题描述 Java中遇到的一个异常Exception in thread "main" java.lang.NullPointerException import java.util.*; public class NewHashTest{ public static void main(String[] args) { HashMap hash = new HashMap(); Emp emp1 = new Emp(""laoda""111&q

android-在fragment转换中出现java.lang.NullPointerException

问题描述 在fragment转换中出现java.lang.NullPointerException 最近学校让做个android音乐播放器,我跟着论坛的教学做到这里时会出现闪退的问题,不知道怎么解决,求助(我是小白,如果可以请说详细些,谢谢啦) 解决方案 http://bbs.csdn.net/topics/390509766 解决方案二: 这是出错的代码 package com.example.test_01; import android.app.Fragment;import androi

JsonMappingException: (was java.lang.NullPointerException)

使用jackson 序列化Java对象的时候报异常: Java代码   com.fasterxml.jackson.databind.JsonMappingException: (was java.lang.NullPointerException) (through reference chain: com.chanjet.gov.Student["age"])       at com.fasterxml.jackson.databind.JsonMappingException.

异常-java.lang.NullPointerException

问题描述 java.lang.NullPointerException 请问下这种异常怎么解决呢 解决方案 空指针错误.这种错误一般是由于: 1.使用的类对象为null 2.指针越界 3.配置文件配置路径有错,无法找到路径 解决方案二: SDK和ADT为22.6.2版本 工程为4.4.2 新建了一个工程 ,代码编写好后并没有报错,在安装支持后报出如下错误: java.lang.RuntimeException: Unable to start activity ComponentInfo{com

sharepreferences-安卓:java.lang.NullPointerException:

问题描述 安卓:java.lang.NullPointerException: logcat显示错误: FATAL EXCEPTION: main Process: org.droidplanner, PID: 21924 java.lang.RuntimeException: Unable to resume activity {org.droidplanner/org.droidplanner.android.activities.FlightActivity}: java.lang.Nul

servlet-关于java.lang.NullPointerException的问题

问题描述 关于java.lang.NullPointerException的问题 提示的错误是:严重: Servlet.service() for servlet Shopping threw exceptionjava.lang.NullPointerException at cn.itcast.Shopping.doGet(Shopping.java:45) at javax.servlet.http.HttpServlet.service(HttpServlet.java:617) at