Mybatis中select语句引入变量报错空指针异常
在mapper.xml中
<select id="getStationCount1" parameterType="String" resultType="com.ciic.common.pojo.entity.StationAmount">
select new_station_amount,back_station_amount,key_station_amount
from STATION_AMOUNT
where year_id =#{year_id} and month_id =#{month_id} and branch_id = '1001'
</select>
对应的dao层接口:
StationAmount getStationCount1(String branchId);
对应的Service层:
@Override
public Map<String, Object> getStationCount1(){
Map<String, Object> sa = new HashMap<>();
StationAmount saResult = ithemeDao.getStationCount1("1");
sa.put("NewStationAmount", saResult.getNewStationAmount());
sa.put("BackStationAmount", saResult.getBackStationAmount());
sa.put("KeyStationAmount", saResult.getKeyStationAmount());
System.out.println(sa);
return sa;
}
将mapper.xml中year_id =#{year_id} and month_id =#{month_id}写成变量就报控制珍异常

刚开始接触,求大神帮忙
<select id="getStationCount1" parameterType="String" resultType="com.ciic.common.pojo.entity.StationAmount">
select new_station_amount,back_station_amount,key_station_amount
from STATION_AMOUNT
where year_id =#{year_id} and month_id =#{month_id} and branch_id = '1001'
</select>
对应的dao层接口:
StationAmount getStationCount1(String branchId);
对应的Service层:
@Override
public Map<String, Object> getStationCount1(){
Map<String, Object> sa = new HashMap<>();
StationAmount saResult = ithemeDao.getStationCount1("1");
sa.put("NewStationAmount", saResult.getNewStationAmount());
sa.put("BackStationAmount", saResult.getBackStationAmount());
sa.put("KeyStationAmount", saResult.getKeyStationAmount());
System.out.println(sa);
return sa;
}
将mapper.xml中year_id =#{year_id} and month_id =#{month_id}写成变量就报控制珍异常

刚开始接触,求大神帮忙

...全文
相关推荐
Mybatis中select、insert、update、delete用法总结
一、select用法示例 SELECT ST.STUDENT_ID, ST.STUDENT_NAME, ST.STUDENT_SEX, ST.STUDENT_BIRTHDAY, ST.CLASS_ID FROM STUDENT_TBL ST WHERE ST.STUDENT_ID = #{studentID} 这条语句就叫做‘getStudent,有一个String参数,并返回一个StudentEntity类型的对象。
Oracle+Mybatis的foreach insert批量插入报错的快速解决办法
本文给大家介绍Oracle+Mybatis的foreach insert批量插入报错的快速解决办法,非常不错,具有参考借鉴价值,感兴趣的朋友参考下吧
Mybatis返回int或者Integer类型报错的解决办法
主要介绍了Mybatis返回int或者Integer类型报错的解决办法,非常不错,具有参考借鉴价值,需要的朋友可以参考下
MyBatis 执行动态 SQL语句详解
大家对mybatis执行任意sql语句都了解,那么MyBatis执行动态SQL语句呢?下面脚本之家小编给大家解答下mybatis执行动态sql语句的方法,非常不错,感兴趣的朋友参考下吧
mybatis 报空值异常
mybatis 报空值异常及其解决办法


