hibernate json数据死循环

package com.temp.entity;

import java.util.Date;
import java.util.HashSet;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import static javax.persistence.GenerationType.IDENTITY;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.hibernate.annotations.Cascade;

import com.fasterxml.jackson.annotation.JsonIgnore;

/**
 * TUser entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "t_user", catalog = "temp")
public class User implements IEntity {

    // Fields

    private Integer id;
    private String tel;
    private String userName;
    private String password;
    private String image;
    private String name;
    private String email;
    private Date birthDate;
    private Date lastDate;
    private String loginIp;
    private Date loginDate;
    private Integer state;
    private Date createDate;
    private Date modifyDate;
    private String tokenKey;
    private String nickName;
    private String sex;
    private Integer age;
    private Double height;
    private Integer tempState;
    private Double warnTemp;
    private Set<Child> TChilds = new HashSet<Child>(0);

    @Id
    @GeneratedValue(strategy = IDENTITY)
    @Column(name = "id", unique = true, nullable = false)
    public Integer getId() {
        return this.id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    @Column(name = "tel", length = 20)
    public String getTel() {
        return this.tel;
    }

    public void setTel(String tel) {
        this.tel = tel;
    }

    @Column(name = "user_name", length = 20)
    public String getUserName() {
        return this.userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    @Column(name = "password", nullable = false, length = 32)
    public String getPassword() {
        return this.password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    @Column(name = "image", length = 200)
    public String getImage() {
        return this.image;
    }

    public void setImage(String image) {
        this.image = image;
    }

    @Column(name = "name", length = 10)
    public String getName() {
        return this.name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Column(name = "email", length = 100)
    public String getEmail() {
        return this.email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    @Column(name = "birth_date", length = 19)
    public Date getBirthDate() {
        return this.birthDate;
    }

    public void setBirthDate(Date birthDate) {
        this.birthDate = birthDate;
    }

    @Column(name = "last_date", length = 19)
    public Date getLastDate() {
        return this.lastDate;
    }

    public void setLastDate(Date lastDate) {
        this.lastDate = lastDate;
    }

    @Column(name = "login_ip", length = 50)
    public String getLoginIp() {
        return this.loginIp;
    }

    public void setLoginIp(String loginIp) {
        this.loginIp = loginIp;
    }

    @Column(name = "login_date", length = 19)
    public Date getLoginDate() {
        return this.loginDate;
    }

    public void setLoginDate(Date loginDate) {
        this.loginDate = loginDate;
    }

    @Column(name = "state", nullable = false)
    public Integer getState() {
        return this.state;
    }

    public void setState(Integer state) {
        this.state = state;
    }

    @Column(name = "create_date", nullable = false, length = 19)
    public Date getCreateDate() {
        return this.createDate;
    }

    public void setCreateDate(Date createDate) {
        this.createDate = createDate;
    }

    @Column(name = "modify_date", nullable = false, length = 19)
    public Date getModifyDate() {
        return this.modifyDate;
    }

    public void setModifyDate(Date modifyDate) {
        this.modifyDate = modifyDate;
    }

    @Column(name = "token_key", length = 200)
    public String getTokenKey() {
        return this.tokenKey;
    }

    public void setTokenKey(String tokenKey) {
        this.tokenKey = tokenKey;
    }

    @Column(name = "nick_name", length = 20)
    public String getNickName() {
        return this.nickName;
    }

    public void setNickName(String nickName) {
        this.nickName = nickName;
    }

    @Column(name = "sex", length = 5)
    public String getSex() {
        return this.sex;
    }

    public void setSex(String sex) {
        this.sex = sex;
    }

    @Column(name = "age")
    public Integer getAge() {
        return this.age;
    }

    public void setAge(Integer age) {
        this.age = age;
    }

    @Column(name = "height")
    public Double getHeight() {
        return this.height;
    }

    public void setHeight(Double height) {
        this.height = height;
    }

    @Column(name = "temp_state")
    public Integer getTempState() {
        return this.tempState;
    }

    public void setTempState(Integer tempState) {
        this.tempState = tempState;
    }

    @Column(name = "warn_temp", precision = 4)
    public Double getWarnTemp() {
        return this.warnTemp;
    }

    public void setWarnTemp(Double warnTemp) {
        this.warnTemp = warnTemp;
    }

    @OneToMany( fetch = FetchType.EAGER, mappedBy = "user")
    @Cascade(value=org.hibernate.annotations.CascadeType.SAVE_UPDATE)
    @JsonIgnore public Set<Child> getTChilds() {
        return this.TChilds;
    }

    public void setTChilds(Set<Child> TChilds) {
        this.TChilds = TChilds;
    }

}
原文地址:https://www.cnblogs.com/jinjixia/p/4845768.html