=和==的陷阱,我的坑

来源:互联网 发布:c语言字符串指针传递 编辑:程序博客网 时间:2024/06/15 10:14

 =是赋值   == 是判断               

<select id="findListTo" resultType="FmWarnOvertime">
   SELECT 
   avg(warn_days) as "warnDays",
   avg(ceil((sysdate-START_TIME-WARN_DAYS )))  as "aveSuperDays",
   avg(  ceil( (sysdate-START_TIME-WARN_DAYS )/WARN_DAYS  ) ) as "aveSuperRatio"
   FROM fm_warn_overtime 
   <where>

<if test="reason != null and reason != ''">
   reason like
<if test="dbName == 'oracle'">'%'||#{reason}||'%'</if>
</if>
<if test="desct != null and desct != ''">
   desct like
<if test="dbName == 'oracle'">'%'||#{desct}||'%'</if>
</if>

</where>
   
   Group by exp_imp_flag,warn_dura_type
  
   <if test="aveSuperDays != null and aveSuperDays != ''"> 
    having avg(ceil((sysdate-START_TIME-WARN_DAYS )))  = #{aveSuperDays}
   </if>
 <if test="aveSuperDays != null and aveSuperRatio != null and aveSuperRatio != ''"> 
  and avg(  ceil( (sysdate-START_TIME-WARN_DAYS )/WARN_DAYS  ) ) = #{aveSuperRatio}
  </if>
 
<if test="(aveSuperDays == null or aveSuperDays == '')and aveSuperRatio != null and aveSuperRatio != ''"> 
  having avg(  ceil( (sysdate-START_TIME-WARN_DAYS )/WARN_DAYS  ) ) = #{aveSuperRatio}
  </if>
</select>

自己开始写成了<if test="(aveSuperDays =null or aveSuperDays == '') 

导致其实aveSuperDays 是又值的,结果在这,判断语句写错了,写成赋值语句

报错:JDBC requires that the JdbcType must be specified for all nullable parameters.

JDBC要求必须为所有可空参数指定JdbcType。

原创粉丝点击