티스토리 뷰
문제 :
update TB_RECIPE
set
<if test="recipeAmt != null and recipeAmt != ''">
recipe_amt = #{recipeAmt}
</if>
<if test="note == null or note ==''">
note = ''
</if>
이거 너무 짜증나고 곤란했는데
jdbcType을 명시해주면 손쉽게 목표를 이룰 수 있다.
note에 값이 있으면 그 값을 사용하고, 공백이거나 null이면 자동으로 null로 넣어준다.
/* RecipeDAO.updateRecipe 레시피 정보 수정 */
update TB_RECIPE
set note = #{note, jdbcType=VARCHAR}
<if test="recipeAmt != null and recipeAmt != ''">
, recipe_amt = #{recipeAmt}
</if>
where recipe_seq = #{id}
limit 1
'시행착오' 카테고리의 다른 글
eclipse error: Java was started but returned exit code=1 (0) | 2019.01.18 |
---|