rg.hibernate.loader.MultipleBagFetchException:无法同时获取多个行李

时间:2018-05-02 15:32:30

标签: java hibernate spring-boot

这个错误不允许我访问jsondoc,我已经尝试过这里提供的一些解决方案,但我仍然遇到同样的问题。

我希望我能够清楚地知道我希望你帮助我。

我留下了错误以及错误中提到的其中一个类。

      Caused by: org.hibernate.loader.MultipleBagFetchException: cannot  
      simultaneously fetch multiple bags: 
      [com.credix.sib.canales.applicant.Applicant.phoneApplicant, 
      com.credix.sib.canales.applicant.Applicant.addressApplicant]

添加了错误

中显示的其中一个类
      @Entity
   @Table(name="APL_APPLICANT", schema="CREDITAPPLICATION")
   @NamedQuery(name="Applicant.findAll", query="SELECT a FROM Applicant a")
   public class Applicant implements Serializable {
private static final long serialVersionUID = 1L;

@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
@Column(name="APL_Id", insertable=false, updatable=false)
@ApiObjectField(description = "Id del Aplicante", required = true)
private Long id;

@Temporal(TemporalType.TIMESTAMP)
@Column(name="APL_CreateDate", updatable=false)
@ApiObjectField(description = "Fecha de creación del Aplicante", required = true)
private Date createDate;

@Column(name="APL_Email")
@ApiObjectField(description = "Email del Aplicante", required = true)
private String email;

@Column(name="APL_Identification", updatable=false)
@ApiObjectField(description = "Identificación del Aplicante", required = true)
private String identification;

@Temporal(TemporalType.TIMESTAMP)
@Column(name="APL_LastModifiedDate")
@ApiObjectField(description = "Fecha de la última modificación del Aplicante", required = true)
private Date lastModifiedDate;

@Column(name="APL_PrintName")
@ApiObjectField(description = "Nombre del Aplicante", required = true)
private String printName;

@OneToOne(fetch=FetchType.EAGER)
@JoinColumn(name="APS_Id")
@ApiObjectField(description = "Objeto Status del Aplicante", required = true)
private ApplicantStatus applicantStatus;

@OneToOne(fetch=FetchType.LAZY)
@JoinColumn(name="IDT_Id")
@ApiObjectField(description = "Objeto tipo de identificación del Aplicante", required = true)
private IdentificationType identificationType;

@OneToOne(fetch=FetchType.LAZY)
@JoinColumn(name="USU_IdCreate")
@ApiObjectField(description = "Objeto usuario creador del Aplicante")
private User userCreate;

@OneToOne(fetch=FetchType.LAZY)
@JoinColumn(name="USU_IdLastModified", updatable = false)
@ApiObjectField(description = "Objeto usuario ultima modificación del Aplicante")
private User userLastModified;

@OneToOne(fetch=FetchType.EAGER)
@JoinColumn(name="APL_Id")
@ApiObjectField(description = "Objeto que contiene los datos personales del aplicante")
private PersonApplicant personApplicant;

@OneToMany(fetch=FetchType.EAGER)
@JoinColumn(name="APL_Id")
@ApiObjectField(description = "Lista de direcciones del aplicante")
private List<AddressApplicant> addressApplicant;

@OneToMany(fetch=FetchType.EAGER)
@JoinColumn(name="APL_Id")
@ApiObjectField(description = "Lista de números telefónicos del aplicante")
private List<PhoneApplicant> phoneApplicant;

@OneToMany(fetch=FetchType.LAZY)
@JoinColumn(name="APL_Id")
@ApiObjectField(description = "Lista de tipos de notificación del aplicante")
private List<PublicityNotification> publicityNotification;

@OneToOne(fetch=FetchType.LAZY)
@JoinColumn(name="CTR_Id")
@ApiObjectField(description = "Objeto tipo de Pais", required = true)
private Country country;

public Applicant() {
}

public Long getId() {
    return this.id;
}

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

public Date getCreateDate() {
    return this.createDate;
}

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

public String getEmail() {
    return this.email;
}

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

public String getIdentification() {
    return this.identification;
}

public void setIdentification(String identification) {
    this.identification = identification;
}

public Date getLastModifiedDate() {
    return this.lastModifiedDate;
}

public void setLastModifiedDate(Date lastModifiedDate) {
    this.lastModifiedDate = lastModifiedDate;
}

public String getPrintName() {
    return this.printName;
}

public void setPrintName(String printName) {
    this.printName = printName;
}

public ApplicantStatus getApplicantStatus() {
    return this.applicantStatus;
}

public void setApplicantStatus(ApplicantStatus applicantStatus) {
    this.applicantStatus = applicantStatus;
}

public IdentificationType getIdentificationType() {
    return this.identificationType;
}

public void setIdentificationType(IdentificationType identificationType) {
    this.identificationType = identificationType;
}

public User getUserCreate() {
    return this.userCreate;
}

public void setUserCreate(User userCreate) {
    this.userCreate = userCreate;
}

public User getUserLastModified() {
    return this.userLastModified;
}

public void setUserLastModified(User userLastModified) {
    this.userLastModified = userLastModified;
}

public PersonApplicant getPersonApplicant() {
    return this.personApplicant;
}

public void setPersonApplicant(PersonApplicant personApplicant) {
    this.personApplicant = personApplicant;
}

public List<AddressApplicant> getAddressApplicant() {

ArrayList<AddressApplicant>();
        return this.addressApplicant;
}

public void setAddressApplicant(List<AddressApplicant> addressApplicant) {
    this.addressApplicant = addressApplicant;
}

public List<PhoneApplicant> getPhoneApplicant() {

ArrayList<PhoneApplicant>();

    return this.phoneApplicant;
}

public void setPhoneApplicant(List<PhoneApplicant> phoneApplicant) {
    this.phoneApplicant = phoneApplicant;
}

public List<PublicityNotification> getPublicityNotification() {

 ArrayList<PublicityNotification>();
  return this.publicityNotification;
}

public void setPublicityNotification(List<PublicityNotification> 
 publicityNotification) {
    this.publicityNotification = publicityNotification;
}

/**
 * @return the country
 */
public Country getCountry() {
    return country;
}

/**
 * @param country the country to set
 */
public void setCountry(Country country) {
    this.country = country;
}

}

我希望得到一些建议

1 个答案:

答案 0 :(得分:0)

如消息所示:您POST

要解决问题,您可以:

  1. 将用于cannot simultaneously fetch multiple bagsphoneApplicant的集合类型从addressApplicant更改为List。此解决方案将导致集合无订单且无重复。如果您坚持订购带有可能重复的订单,请使用下面描述的第二个选项。

  2. 为两个列表使用注释Set提供订单列。