spkrgg
80
2020-01-13 17:23:54
2
349

mybatis 쿼리문 질문입니다!


안녕하세요 초보 코딩러입니다!


다름이 아니라 제가 지금 SeatVO에 NineToTen, TenToEleven..... 등등의 게터 세터로 정의한 필드값이 있구요!

그리고, 이 값들이 1이 될때마다 db 컬럼에 1이 추가되는 것을 구현하려고 합니다.

근데, 이게 값이 전혀 들어가지 않아서 질문을 하려고합니다


mybatis 쿼리부분입니다

<update id="updateseattotal" parameterType="SeatVO">
update seat_total 
<set>
<if test="#{NineToTen} == 1">
NineToTen = NineToTen + 1,
</if> 
<if test="TenToElven == '1'">
TenToEleven = TenToEleven + 1,
</if>
<if test = "ElevenToTwelve == 1">
ElevenToTwelve = ElevenToTwelve + 1,
</if>
<if test = "TwelveToThirteen == 1">
TwelveThirteen = TwelveThirteen + 1,
</if>
<if test = "ThirteenToFourteen == 1">
ThirteenToFourteen = ThirteenToFourteen + 1,
</if>
<if test = "FourteenToFifteen == 1">
FourteenToFifteen = FourteenToFifteen + 1,
</if>
<if test = "FifteenToSixteen == 1">
FifteenToSixteen = FifteenToSixteen + 1,
</if>
<if test = "SixteenToSeventeen == 1">
SixteenToSeventeen = SixteenToSeventeen + 1,
</if>
<if test = "SeventeenToEightteen == 1">
SeventeenToEightteen = SeventeenToEightteen + 1,
</if>
<if test = "EightteenToNineteen == 1">
EightteenToNineteen = EightteenToNineteen + 1,
</if>
<if test = "NineteenToTwenty == 1">
NineteenToTwenty = NineteenToTwenty + 1,
</if>
<if test = "TwentyToTwentyOne == 1">
NineteenToTwenty = NineteenToTwenty + 1,
</if>
<if test = "TwentyOneToTwentyTwo == 1">
TwentyOneToTwentyTwo = TwentyOneToTwentyTwo + 1
</if>
</set>
 where seat = #{seat}
</update>



SeatVO 클래스입니다

package org.zerock.domain;

public class SeatVO {
   
   private String seat;
   
     private Integer NineToTen; 
     private Integer TenToEleven; 
     private Integer ElevenToTwelve; 
     private Integer TwelveToThirteen; 
     private Integer ThirteenToFourteen; 
     private Integer FourteenToFifteen; 
     private Integer FifteenToSixteen; 
     private Integer SixteenToSeventeen; 
     private Integer SeventeenToEightteen; 
     private Integer EightteenToNineteen; 
     private Integer NineteenToTwenty; 
     private Integer TwentyToTwentyOne; 
     private Integer TwentyOneToTwentyTwo;
    
   public String getSeat() {
     return seat;
   }
   public void setSeat(String seat) {
     this.seat = seat;
   }
   public Integer getNineToTen() {
      return NineToTen;
   }
   public void setNineToTen(Integer nineToTen) {
      NineToTen = nineToTen;
   }
   public Integer getTenToEleven() {
      return TenToEleven;
   }
   public void setTenToEleven(Integer tenToEleven) {
      TenToEleven = tenToEleven;
   }
   public Integer getElevenToTwelve() {
      return ElevenToTwelve;
   }
   public void setElevenToTwelve(Integer elevenToTwelve) {
      ElevenToTwelve = elevenToTwelve;
   }
   public Integer getTwelveToThirteen() {
	   return TwelveToThirteen;
   }
   public void setTwelveToThirteen(Integer twelveToThirteen) {
	   TwelveToThirteen = twelveToThirteen;
   }
   public Integer getThirteenToFourteen() {
      return ThirteenToFourteen;
   }
   public void setThirteenToFourteen(Integer thirteenToFourteen) {
      ThirteenToFourteen = thirteenToFourteen;
   }
   public Integer getFourteenToFifteen() {
      return FourteenToFifteen;
   }
   public void setFourteenToFifteen(Integer fourteenToFifteen) {
      FourteenToFifteen = fourteenToFifteen;
   }
   public Integer getFifteenToSixteen() {
      return FifteenToSixteen;
   }
   public void setFifteenToSixteen(Integer fifteenToSixteen) {
      FifteenToSixteen = fifteenToSixteen;
   }
   public Integer getSixteenToSeventeen() {
      return SixteenToSeventeen;
   }
   public void setSixteenToSeventeen(Integer sixteenToSeventeen) {
      SixteenToSeventeen = sixteenToSeventeen;
   }
   public Integer getSeventeenToEightteen() {
      return SeventeenToEightteen;
   }
   public void setSeventeenToEightteen(Integer seventeenToEightteen) {
      SeventeenToEightteen = seventeenToEightteen;
   }
   public Integer getEightteenToNineteen() {
      return EightteenToNineteen;
   }
   public void setEightteenToNineteen(Integer eightteenToNineteen) {
      EightteenToNineteen = eightteenToNineteen;
   }
   public Integer getNineteenToTwenty() {
      return NineteenToTwenty;
   }
   public void setNineteenToTwenty(Integer nineteenToTwenty) {
      NineteenToTwenty = nineteenToTwenty;
   }
   public Integer getTwentyToTwentyOne() {
      return TwentyToTwentyOne;
   }
   public void setTwentyToTwentyOne(Integer twentyToTwentyOne) {
      TwentyToTwentyOne = twentyToTwentyOne;
   }
   public Integer getTwentyOneToTwentyTwo() {
      return TwentyOneToTwentyTwo;
   }
   public void setTwentyOneToTwentyTwo(Integer twentyOneToTwentyTwo) {
      TwentyOneToTwentyTwo = twentyOneToTwentyTwo;
   }
      
     
}


이 위에서 #{} 붙이고, '1' 한 것은 한 번 저렇게 하면 되나 시도해보려고 했던 것입니다ㅠ 

동적쿼리를 아예 처음써봐서 모르겠습니다.. 조금만 도와주시면 감사드리겠습니다..!


쿼리문에서 어떤 부분을 바꿔야 제대로 db에 1씩 추가될까요?

0
  • 답변 2

  • star16m
    811
    2020-01-13 19:38:02

    잘 되지 않을때는 디버깅하는 법을 차근차근 적용해 보세요

    mybatis 에 의해 생성된 sql을 로그로 출력하는것도 좋은 방법입니다

    변수를 select 해보는것도 좋구요

    Nine 이라는 변수는 getNine 으로 참조되어 사실은 nine 을 참조합니다

    getter 와 setter 에 대한 정의를 별도로 하지 않으셨다면요


  • 초급개발자111
    107
    2020-01-13 20:11:06

    로그를 보여주시는게 다른분들이 보시기에 편할거같네요

  • 로그인을 하시면 답변을 등록할 수 있습니다.