hibernate entity to json

后端 未结 4 878
伪装坚强ぢ
伪装坚强ぢ 2021-01-06 05:06

i use Hibernate 4 and Spring 3.

i have two entity.

Book entity

@Entity
@Table(name = \"book\")
public class Book implements Serializable {

          


        
4条回答
  •  刺人心
    刺人心 (楼主)
    2021-01-06 05:32

    You can use @com.fasterxml.jackson.annotation.JsonIgnore annotation to avoid a field to be serialized. Thus the getter of that field won't get called.

    @JsonIgnore
    @OneToMany( mappedBy = "author", cascade = CascadeType.ALL, orphanRemoval = true)
    private Set books = new HashSet();
    

提交回复
热议问题