티스토리 뷰
사용자 정보 저장할 때 비밀번호와, 비밀번호확인이 있다...
비밀번호 확인은 Front단에서만 점검용으로 사용한다.. 하지만 화면에 <input>으로 존재하므로
JSON.stringify($("#facilityForm").serializeObject())를 하다 보면 자연스레 DB에 없는 column들도 넘어가게 마련..
이럴 때 Back(Server or Api)단에서 DB에 없는 필드를 무시하는 조치가 필요하다...
1. @Transient 추가
import javax.persistence.Transient;
@Transient는 JPA관련 annotation이다.
그런데 두두.. 이것으로만으로 해결되지 않는 문제가 발생했다.
Resolved [org.springframework.http.converter.HttpMessageNotReadableException: JSON parse error: Unrecognized field "userPwd2"
(com.mindone.okch.common.domain.User) , not marked as ignorable; nested exception is
com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException:
(15 known properties: "regDt", "userAra", "userId", "phone", "regId", "modDt", "ugrpCde", "userAtt", "userGrp", "useYn", "modId", "userNam", "userPwd", "email", "attCode"])
2. @JsonIgnoreProperties(ignoreUnknown = true)
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
@JsonIgnoreProperties는 jackson관련 annotation이다.
위 문장 추가시 해결!
@JsonIgnoreProperties(ignoreUnknown = true)
@Entity
@Builder
@NoArgsConstructor
@AllArgsConstructor
//@Getter @Setter
@Table(name = "CM_USR")
public class User extends AbstractTbl { // 사용자
@Id
@ApiModelProperty(value = "사용자아이디")
@Column(name = "USER_ID")
private String userId;
@ApiModelProperty(value = "비밀번호")
@Column(name = "USER_PWD")
private String userPwd;
@ApiModelProperty(value = "비밀번호확인")
@Transient
private String userPwd2;
}
참고 : https://medium.com/@circlee7/jackson-annotations-19886933a252
Jackson annotations
json관련 jackson 에서 지원하는 유용한 어노테이션 기능들을 살펴보자
medium.com
'Skill > JPA' 카테고리의 다른 글
[JPA] Querydsl 1분주기 데이터 중 10분 데이터 가져오기 (0) | 2020.09.22 |
---|---|
Hibernate enable_lazy_load_no_trans Property (0) | 2020.08.18 |
[JPA] Open Session In View (0) | 2020.06.26 |
[JPA] MessageConverterConfiguration 적용시 에러 (0) | 2020.06.26 |
[JPA] org.hibernate.loader.MultipleBagFetchException (0) | 2020.06.26 |
- Total
- Today
- Yesterday
- QueryDSL
- JQuery
- @ExceptionHandler
- setter
- border-collapse
- springboot
- PostgreSQL
- oracle
- Keycode
- element위치
- draw.io
- 진열사랑
- ul li로 테이블
- CSS
- $.each
- object key
- excel
- 여러 컬럼 update
- sumifs
- 전후방탐색
- DatePicker
- 프로젝트명변경
- 정규식
- spring
- devtools
- $.extend
- Javascript
- getter
- caniuse
- lombok
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |