본문 바로가기

개발중/troubleshooting

mybatis 에러 해결 : java.lang.IndexOutOfBoundsException

728x90
반응형

 

아래와 같은 샤라라라라 에러가 발생했다.

이 에러로 인해 2시간을 해맸다.

 

### Cause: java.lang.IndexOutOfBoundsException: Index: 25, Size: 25

 

 

더보기

org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException: 
### Error querying database.  Cause: java.lang.IndexOutOfBoundsException: Index: 25, Size: 25
### The error may exist in file [C:\coding\workspace-spring-tool-suite-4-4.9.0.RELEASE\POMS\target\classes\mybatis\neo\company\companyLucy.xml]
### The error may involve lucy.company.getCompany
### The error occurred while handling results
### SQL: SELECT C1.com_seq                                              AS comSeq          , C1.com_key                                            AS comKey          , C1.com_name                                           AS comName          , C1.com_use                                            AS comUse          , C1.com_reg_date                                       AS comRegDate          , C1.com_use_start_date                                 AS comUseStartDate          , C1.com_use_end_date                                   AS comUseEndDate          , C1.com_user_cnt                                       AS comUserCnt          , C1.com_viewer_cnt                                     AS comViewerCnt          , C1.com_category_cnt_km                                AS comCategoryCntKm          , C1.com_category_cnt_ks                                AS comCategoryCntKs          , C1.com_attr_cnt                                       AS comAttrCnt          , C1.com_search_sdate                                   AS comSearchSdate          , C1.com_search_month_limit                             AS comSearchMonth          , C1.com_search_month_limit_item                        AS comSearchMonthLimitItem          , C1.com_dataexport_rank                                AS comDataExportRank          , C1.com_compare_category_cnt                           AS comCompareCategory          , C1.com_compare_group_cnt                              AS comCompareGroupCnt          , C1.com_keyword_rule                                   AS comKeywordRule          ,(SELECT TO_DAYS(C1.com_use_end_date) - TO_DAYS(NOW())) AS subDate          , C1.com_alimi_telegram_max_cnt                         AS comAlimiTelegramMaxCnt          , C1.com_alimi_sms_use                                  AS comAlimiSmsUse          , C1.com_category_cnt_create                            AS comCategoryCntCreate          ,(SELECT COUNT(*) FROM USER AS U1 WHERE U1.com_seq = C1.com_seq AND U1.user_type='U') AS userCnt          ,(SELECT COUNT(*) FROM USER AS U1 WHERE U1.com_seq = C1.com_seq AND U1.user_type='V') AS viewerCnt     FROM COMPANY AS C1    WHERE 1 = 1            AND (SELECT TO_DAYS(C1.com_use_end_date) - TO_DAYS(C1.com_use_start_date))  <=  7                        AND C1.com_use = ?                   ORDER BY C1.com_seq ASC
### Cause: java.lang.IndexOutOfBoundsException: Index: 25, Size: 25

 

 

인터넷 상에는 여러가지 에러 방법이 있었으나 나와 맞지 않았다

 

내가 에러가 발생한 이유는 @build 때문이었다.

 


 

❌ 에러 수정 전 

 

import lombok.Builder;
import lombok.Getter; 
import lombok.Setter;

@Getter
@Setter
@Builder 

 

 

⭕에러 해결 후

 

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

@Getter
@Setter
@Builder
@NoArgsConstructor
@AllArgsConstructor


@Build 를 사용하면 단지 객체를 생성함에 있어서 편리함으로 인해서 @Build 를 추가했는데..


@Build 를 사용하려면

 

@NoArgsConstructor @AllArgsConstructor 를 같이 사용해주어야 에러가 발생하지 않는다.


🔰 글이 도움이 되었다면 Click 🔰

 


 

728x90
반응형