티스토리 뷰

Spring Data Jpa @Discriminator 다대일 Mapping


중요한 내용

@ManyToOne은 parent를 save 할 때 먼저 Many쪽에 있는 row들을 insert한 다음에 parent를 save할 수 있다.

Parent에서 @OneToMany(mappedBy = "parentName") 이런식으로 카멜케이스를 써야함.

@OneToMany(mappedBy = "parent_name") 이렇게 쓰면 매핑이 안됨


났던 에러들

1.Could not determine type for

- Parent에 @OneToMany(mappedBy="parent_table_name")를 빼면 난다.


2.mappedBy reference an unknown target entity property

- 알수 없는 대상 엔티티 프로퍼티를 참조 했다고 한다.

- Parent에 @OneToMany(mappedBy="parent_table_name")를 넣으면 난다.


3.LAZYInitializationError

매핑을 다 한다음에 에러남


4.Infinite recursion

@JsonBackReference를 써서 해결했음

List에서 Json으로 변환이 안되는 문제 


공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/04   »
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
글 보관함