티스토리 뷰


문제 : 

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
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2025/06   »
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30
글 보관함