异常:
org.springframework.jdbc.UncategorizedSQLException:
### Error updating database. Cause: java.sql.SQLException: sql injection violation, syntax error: syntax error, error in :' a.vehicle_type = ?
wher', expect IDENTIFIER, actual IDENTIFIER pos 299, line 11, column 11, token IDENTIFIER a : update cims_charge_rule a
SET a.init_price = ?,
a.init_mileage = ?,
a.time_price = ?,
a.mileage_price = ?,
a.long_distance_price = ?,
a.long_distance_mileage = ?,
a.out_town_price = ?,
a.order_type = ?,
a.immediacy = ?
a.vehicle_type = ?
where
a.id = ?
Caused by: java.sql.SQLException: sql injection violation, syntax error: syntax error, error in :' a.vehicle_type = ?
wher', expect IDENTIFIER, actual IDENTIFIER pos 299, line 11, column 11, token IDENTIFIER a : update cims_charge_rule a
SET a.init_price = ?,
a.init_mileage = ?,
a.time_price = ?,
a.mileage_price = ?,
a.long_distance_price = ?,
a.long_distance_mileage = ?,
a.out_town_price = ?,
a.order_type = ?,
a.immediacy = ?
a.vehicle_type = ?
where
a.id = ?
Caused by: com.alibaba.druid.sql.parser.ParserException: syntax error, error in :' a.vehicle_type = ?
wher', expect IDENTIFIER, actual IDENTIFIER pos 299, line 11, column 11, token IDENTIFIER a
经过检查发现
<update id="updateCharge" parameterType="*****">
update cims_charge_rule a
<set>
<if test="initPrice != null">a.init_price = #{initPrice},</if>
<if test="initMileage != null">a.init_mileage = #{initMileage},</if>
<if test="timePrice != null">a.time_price = #{timePrice},</if>
<if test="mileagePrice != null">a.mileage_price = #{mileagePrice},</if>
<if test="longDistancePrice != null">a.long_distance_price = #{longDistancePrice},</if>
<if test="longDistanceMileage != null">a.long_distance_mileage = #{longDistanceMileage},</if>
<if test="outTownPrice != null">a.out_town_price = #{outTownPrice},</if>
<if test="orderType != null || orderType != ''">a.order_type = #{orderType},</if>
<if test="immediacy != null || immediacy != ''">a.immediacy = #{immediacy,}</if>
<if test="vehicleType != null || vehicleType != ''">a.vehicle_type = #{vehicleType}</if>
</set>
where
a.id = #{id}
</update>