Я получаю эту ошибку при запуске.
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'contolsEntityManagerFactory' defined in class path resource [com/fmr/config/ControlPersistenceContext.class]: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: [PersistenceUnit: controls] Unable to build Hibernate SessionFactory; nested exception is org.hibernate.loader.MultipleBagFetchException: cannot simultaneously fetch multiple bags: [com.mycompany.database.DocumentDetail.documentValidationList, com.mycompany.database.SqlDetail.sqlValidationList]
По сути, у меня есть сущность ValidationStep, которая имеет однозначное сопоставление для SqlDetail или DocumentDetail.
SqlDetail имеетСписок проверок SqlValidations от одного ко многим
DocumentDetail содержит один список проверок документов
ValidationStep
@Entity
public class ValidationStep {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@ManyToOne
@JoinColumn(name= "automation_information_aId", referencedColumnName= "aId")
private AutomationInformation automationInformation;
private int sequence;
public enum ValidationType {
Email, Document, Sql, Custom
};
@Enumerated(EnumType.STRING)
private ValidationType type;
@OneToOne(cascade = { CascadeType.ALL }, orphanRemoval = true,fetch=FetchType.EAGER)
private EmailDetail emailDetail;
@OneToOne(cascade = { CascadeType.ALL }, orphanRemoval = true,fetch=FetchType.EAGER)
private DocumentDetail documentDetail;
@OneToOne(cascade = { CascadeType.ALL }, orphanRemoval = true,fetch=FetchType.EAGER)
private SqlDetail sqlDetail;
private String description;
DocumentDetail
@Entity
public class DocumentDetail {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
//no cascade, a connectionManager save/update cant save/update a a credential
//unidirectional mapping,
@OneToOne(fetch=FetchType.EAGER)
@JoinColumn(name= "credential_id")
private Credential credential;
@OneToMany(cascade = CascadeType.ALL, orphanRemoval = true,fetch=FetchType.EAGER)
@JoinColumn(name = "documentDetail_id")
private List<DocumentValidation> documentValidationList;
public enum DocumentLocationType {
Confluence, DocumentCentral, FileShare, OneDrive, SharePoint
};
@Enumerated(EnumType.STRING)
private DocumentLocationType locationType;
private String locationUrl;
DocumentValidation
@Entity
public class DocumentValidation implements Comparable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
//type of validation
public enum DocumentValidationKey {
NameContains, NameMatchesRegex, LastUpdated, DocumentContains, NameStartsWith, NameEndsWith, DocumentContentsMatchsRegex, NameExactly
}
@Enumerated(EnumType.STRING)
private DocumentValidationKey validationType;
//value which results in pass
private String validationValue;
SqlDetail в значительной степени идентичен DocumentDetail, а SqlValidation идентичен DocumentValidation