private Integer id;
public int getId() {
return id;
}
在类中,id属性类型为Integer,getid返回值为int时,会报如下错误,将返回值修改为Integer就能解决。
Caused by: 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 [D:\STSWorkSpace\chbwSystem\target\classes\mapping\PurchaseDetailMapper.xml]
### The error may involve com.server.chbw.purchase.mapper.PurchaseDetailMapper.list_COUNT
### The error occurred while handling results
### SQL: SELECT count(0) FROM (SELECT pd.id, pd.orderid, pd.partid, pd.code, pd.number, pd.summoney, pd.price, date_format(pd.production, '%Y-%m-%d') production, pd.note FROM purchase_detail_info pd LEFT JOIN part_info pi ON pd.partid = pi.id AND pi.isvalidate = "1" LEFT JOIN firm_info fi ON fi.id = pi.firmid AND fi.isvalidate = "1" WHERE pd.isvalidate = "1" AND pd.orderid = ?) table_count
### Cause: java.lang.NullPointerException
at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:92)
at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:440)
at com.sun.proxy.$Proxy63.selectList(Unknown Source)
at org.mybatis.spring.SqlSessionTemplate.selectList(SqlSessionTemplate.java:223)
at org.apache.ibatis.binding.MapperMethod.executeForMany(MapperMethod.java:147)
at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:80)
at org.apache.ibatis.binding.MapperProxy$PlainMethodInvoker.invoke(MapperProxy.java:144)
at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:85)
at com.sun.proxy.$Proxy68.list(Unknown Source)
... 79 more