엄지월드

Error attempting to get column 'email_auth_yn' from result set. Cause: java.sql.SQLException: Type class java.time.LocalDateTime not supported type for BIT type ; uncategorized SQLException; SQL state [null]; error code [0]; Type class java.time.LocalDate 본문

java/Spring

Error attempting to get column 'email_auth_yn' from result set. Cause: java.sql.SQLException: Type class java.time.LocalDateTime not supported type for BIT type ; uncategorized SQLException; SQL state [null]; error code [0]; Type class java.time.LocalDate

킨글 2022. 8. 12. 10:19
DTO에 @Builder 추가 시 잘 되던 페이지가 갑자기 안되는 현상이 발생했다. 
This application has no explicit mapping for /error, so you are seeing this as a fallback.
Fri Aug 12 10:10:55 KST 2022
There was an unexpected error (type=Internal Server Error, status=500).
Error attempting to get column 'email_auth_yn' from result set. Cause: java.sql.SQLException: Type class java.time.LocalDateTime not supported type for BIT type ; uncategorized SQLException; SQL state [null]; error code [0]; Type class java.time.LocalDateTime not supported type for BIT type; nested exception is java.sql.SQLException: Type class java.time.LocalDateTime not supported type for BIT type
org.springframework.jdbc.UncategorizedSQLException: Error attempting to get column 'email_auth_yn' from result set. Cause: java.sql.SQLException: Type class java.time.LocalDateTime not supported type for BIT type ; uncategorized SQLException; SQL state [null]; error code [0]; Type class java.time.LocalDateTime not supported type for BIT type; nested exception is java.sql.SQLException: Type class java.time.LocalDateTime not supported type for BIT type
 

이게 무슨 소린고... 

java.time.LocalDateTime은 BIT를 지원하지 않는다? email_auth_yn은 LocalDateTime이 아니라 BIT가 맞는데?? 

package com.myapp.lms.admin.dto;

import com.myapp.lms.member.entity.Member;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.time.LocalDateTime;

@Data
@Builder
public class MemberDto {
    private String userId;
    private String userName;
    private String phone;
    private String password;
    private LocalDateTime regDt;

    private boolean emailAuthYn;
    private LocalDateTime emailAuthDt;
    private String emailAuthKey;

    private String resetPasswordKey;
    private LocalDateTime resetPasswordLimitDt;

    private boolean adminYn;

    private long totalCount;
    private long seq;

    // member를 MemberDto로 변경
    public static MemberDto of(Member member){
        return MemberDto.builder()
                .userId(member.getUserId())
                .userName(member.getUserName())
                .phone(member.getPhone())
                .password(member.getPassword())
                .regDt(member.getRegDt())
                .emailAuthYn(member.isEmailAuthYn())
                .emailAuthDt(member.getEmailAuthDt())
                .emailAuthKey(member.getEmailAuthKey())

                .resetPasswordKey(member.getResetPasswordKey())
                .resetPasswordLimitDt(member.getResetPasswordLimitDt())

                .adminYn(member.isAdminYn())

                .build();
    }
}

@Builder를 선언하면 생성자를 없애준다.

하지만 Mybatis는 생성자가 필요해서 생성자가 없어서 발생하는 문제이기 때문에  생성자를 만들어주면 된다고 한다.

@NoArgsConstructor 을 추가해주었고, 에러가 나서 보니 @NoArgsConstructor만 사용하게 되면 매개변수가 없다고 한다.

그래서 사용하려면 @AllArgsConstructor이 있어야 해서 추가해 주어 해결하였다.

@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class MemberDto {
	...
}

 

 

 

 

'java > Spring' 카테고리의 다른 글

mybatis mapper xml include  (0) 2022.08.14
@Builder를 사용하는 이유  (0) 2022.08.12
Spring paging  (0) 2022.08.10
thymeleaf fragment 설정  (0) 2022.08.09
Spring Security 설정  (0) 2022.08.05
Comments