工作中bug總結
1 常見傳入引數strTime 格式問題 2018-08-09 而資料庫要求的是20180809 資料庫中資料型別有可能是int
2 DefraudingEffect et = new DefraudingEffect();
displayList.add(et); list中只存的是對物件的引用,
displayList.add(et);
displayList.get(4).setTelno("15220092297");
displayList.get(4).setEventTime("2018-08-13 20:03:00");
displayList.get(4).setMeasureType("電話外呼");
displayList.get(3).setTelno("15220092342");
displayList.get(3).setEventTime("2018-08-13 20:03:00");
displayList.get(3).setMeasureType("電話外呼11111111");
最後加入list的值是最後設定的資料,之前的資料會被覆蓋
3 Exception in thread “main” java.lang.UnsupportedClassVersionError: javaee/appTest : Unsupported major.minor version 52.0
原因分析:高版本編譯器編譯後不能在低版本的JVM上執行,而本機上安裝了多個跨版本的JDK
解決方案:將IDE編譯器與JVM虛擬機器版本改為相同。
4 mybatis中的return型別 ,sql,引數為一個的時候<if test="_parameter !=null">
當有序列的時候: 要使用 nextval('序列名稱')
<select id="selectSeq" resultType="java.lang.Long">
select nextval('gis2_msg_info_id_seq') as seqid
</select>
<select id="selectTotalInfo" parameterType="map" resultType="com.asiainfo.idsp.gaj.orm.MsgCountInfo">
<!-- 批量新增簡訊標籤 -->
<insert id="batchInsert" parameterType="java.util.ArrayList">
insert into
gis2_msg_info_ext(msg_id, tag_name, tag_value)
values
<foreach item="sms" collection="list" separator="," >
(#{sms.msgId,jdbcType=BIGINT}, #{sms.tagName,jdbcType=VARCHAR}, #{sms.tagValue,jdbcType=VARCHAR})
</foreach>
</insert>
5 select
a.custtitle,
(select count(*) from gis2_sms_response msgrep
where msgrep.taskid=a.id) as replayCount // 巢狀查詢
from
gis2_msg_info a
left JOIN channel_info b
on a.channel_id=CAST(b.id as varchar) // 強制轉換成字元
left join system_user c
on a.edit_user_id=c.user_id
where
<if test="editDate!=null and editDate!=''">
and to_date(to_char(a.edit_time, 'YYYY-MM-DD'),'YYYY-MM-DD') = to_date(#{editDate},'YYYY-MM-DD')
</if>
<if test="startDate!=null and startDate!=''">
and a.edit_time >=to_date(#{startDate},'YYYY-MM-DD HH24:MI:SS')
</if>
<if test="endDate!=null and endDate!=''">
and a.edit_time <= to_date(#{endDate},'YYYY-MM-DD HH24:MI:SS') // 轉換時間
</if>
<if test="msgContent!=null and msgContent!=''">
and a.msg_content like CONCAT(CONCAT('%', #{msgContent}), '%') // 字元拼接
</if>
<if test="countyId!=null and countyId!=0 ">
and county_id = #{countyId}::numeric // 將countyId轉換成數字
</if>
<if test="status!=null and status.size>0">
and a.status in
<foreach collection="status" index="index" item="state" separator="," open="(" close=")">
#{state}
</foreach>
</if>
order by a.id desc
limit #{pageSize} offset #{pageNo}
select (
select
sum(CAST(sendcount as numeric(16))) as todayCount
from
gis2_msg_info
where start_time like CONCAT(CONCAT(#{strTime}), '%')
) as todayCount
,
(
select count(*) from gis2_sms_response where taskid in
(
select id
from gis2_msg_info
where start_time like CONCAT(CONCAT(#{strTime}), '%')
)
) as todayReply