@Entity
@Getter
@NoArgsConstructor
@AllArgsConstructor
@Builder
@JsonPropertyOrder({"id", "parent", "celebCategory", "celebNameKr", "celebNameEn", "celebStatus", "created_at", "updated_at"})
@Table(name = "celeb")
public class Celeb extends BaseEntity {
@Id @GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "celeb_id")
private Long id;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "parent_id")
private Celeb parent;
@ManyToOne
@JoinColumn(name = "celeb_category_id")
private CelebCategory celebCategory;
private String celebNameKr;
private String celebNameEn;
@Enumerated(EnumType.STRING)
private CelebStatus celebStatus;
@OneToMany(mappedBy = "parent", fetch = FetchType.LAZY)
private List<Celeb> subCelebList = new ArrayList<>();
}
ERROR 8736 --- [nio-8080-exec-2] c.s.s.g.c.e.GlobalExceptionHandler : Error: RuntimeException, Class : HttpMessageNotWritableException, Message : Could not write JSON: Infinite recursion (StackOverflowError)
다음 어노테이션 추가
@JsonIgnoreProperties({"subCelebList"})
@Entity
@Getter
@NoArgsConstructor
@AllArgsConstructor
@Builder
@JsonPropertyOrder({"id", "parent", "celebCategory", "celebNameKr", "celebNameEn", "celebStatus", "created_at", "updated_at"})
@JsonIgnoreProperties({"subCelebList"}) // <- 추가
@Table(name = "celeb")
public class Celeb extends BaseEntity {
...
}
ERROR 17692 --- [nio-8080-exec-1] c.s.s.g.c.e.GlobalExceptionHandler : Error: RuntimeException, Class : HttpMessageConversionException, Message : Type definition error: [simple type, class org.hibernate.proxy.pojo.bytebuddy.ByteBuddyInterceptor]
프로퍼티 추가
@JsonIgnoreProperties({"hibernateLazyInitializer", "handler", "subCelebList"})
@Entity
@Getter
@NoArgsConstructor
@AllArgsConstructor
@Builder
@JsonPropertyOrder({"id", "parent", "celebCategory", "celebNameKr", "celebNameEn", "celebStatus", "created_at", "updated_at"})
@JsonIgnoreProperties({"hibernateLazyInitializer", "handler", "subCelebList"}) // <- 수정
@Table(name = "celeb")
public class Celeb extends BaseEntity {
...
}