- mybatis xml中大于等于的写法
1、用了转义字符把>和<替换掉
如:WHERE 1 = 1 AND start_date <= CURRENT_DATE AND
< | < | 小于号 |
> | > | 大于号 |
& | & | 和 |
' | ’ | 单引号 |
" | " | 双引号 |
2、使用
<![CDATA[ ]]>
<![CDATA[o.lft >= 1 and o.rgt <= 9 ]]>
- 运行时报参数错误
MyBites:Parameter 'stationId' not found. Available parameters are [2, 1, 0, param1, param2, param3]
在dao中是这样写的:
List<LaneEtcCount> getList( Long stationId, int begin, int end);
在xml配置文件中是这样写的:
<select id="getList" resultType="LaneEtcCount">
SELECT * FROM LANE_ETC_COUNTWHERE STATIONID = #{stationId}AND RECORDING_DATE BETWEEN #{begin} and #{end}ORDER BY STATIONID,LANECODE,RECORDING_DATE
</select>
3、dao层代码的参数加上@param
List<LaneEtcCount> getList(@Param("stationId") Long stationId,@Param("begin")intbegin,@Param("end")intend);
4、插入数据的时候,使用selectkey返回主键值
在Oracle主键自增的环境下:
<insert id="add" parameterType="com">
<selectKey resultType="java.lang.Long" order="AFTER" keyProperty="id">
SELECT SEQ_SYS_.currval FROM sys.DUAL
</selectKey>
INSERT INTO SYS_ (....)
VALUES (....)
</insert>
注意:这是使用sequence和触发器的方式,在这种方式下一定要使用AFTER,不然ID会自增两次,返回的id不正确。
第二种方式就是不用触发器,使用before获取nextval,然后insert id字段