相关疑难解决方法(0)

Jackson JSON和Hibernate JPA问题的无限递归

在尝试将具有双向关联的JPA对象转换为JSON时,我不断获取

org.codehaus.jackson.map.JsonMappingException: Infinite recursion (StackOverflowError)
Run Code Online (Sandbox Code Playgroud)

我找到的只是这个线程,基本上建议避免双向关联.有没有人对这个春天的bug有一个解决方法?

------编辑2010-07-24 16:26:22 -------

Codesnippets:

业务对象1:

@Entity
@Table(name = "ta_trainee", uniqueConstraints = {@UniqueConstraint(columnNames = {"id"})})
public class Trainee extends BusinessObject {

    @Id
    @GeneratedValue(strategy = GenerationType.TABLE)
    @Column(name = "id", nullable = false)
    private Integer id;

    @Column(name = "name", nullable = true)
    private String name;

    @Column(name = "surname", nullable = true)
    private String surname;

    @OneToMany(mappedBy = "trainee", fetch = FetchType.EAGER, cascade = CascadeType.ALL)
    @Column(nullable = true)
    private Set<BodyStat> bodyStats;

    @OneToMany(mappedBy = "trainee", fetch = FetchType.EAGER, …
Run Code Online (Sandbox Code Playgroud)

java orm json spring-mvc jackson

375
推荐指数
15
解决办法
26万
查看次数

标签 统计

jackson ×1

java ×1

json ×1

orm ×1

spring-mvc ×1