Ajax 调用 Spring/hibernate 网络应用程序后出现 Jackson 异常

Jackson exception after Ajax call in Spring/hibernate web-app

在我的 spring 网络应用程序中和 AJAX 调用以下异常触发:

com.fasterxml.jackson.databind.JsonMappingException: failed to lazily initialize a collection of role: com.domain.entities.Person.followerd, could not initialize proxy - no Session

父实体:

@Entity
public class Person {
 @OneToMany(mappedBy="follower")
 @JsonIgnore
 private List<FollowerPerson> followerd;
 ....

@ElementCollection(fetch = FetchType.EAGER)
@CollectionTable(name="phone", joinColumns=@JoinColumn(name="person"))
protected List<Phone> phones;
}

FollowerPerson 实体

@Entity
public class FollowerPerson implements Serializable {

    @EmbeddedId
    private FollowerPk id;

    @MapsId("std")
    @ManyToOne
    private Person std;

    @MapsId("follower")
    @ManyToOne
    private Person follower;
....
}

在我的 AppConfig 中,我使用这个 txManager spring + hibernate(基于 JPA):

@Bean
public PlatformTransactionManager txManager() {
    JpaTransactionManager jpaTransactionManager = new JpaTransactionManager(
            getEntityManagerFactoryBean().getObject());
    return jpaTransactionManager;
}

在查找所有人的findAll dao方法执行后ajax调用尝试识别列表时发生异常

当我用 fetch=FetchType.EAGER 注释这个属性时 将出现另一个异常:

cannot simultaneously fetch multiple bags: [com.domain.entities.Person.followerd, com.domain.entities.Person.phones]

请帮忙

如果可以,请更改要设置的列表。 LinkedHashSet 如果还需要下单