У нас есть приложение Java ee, работающее на JBoss 6.4 GA с использованием JPA и Hibernate со следующими объектами:
@Entity
@SequenceGenerator(name = "sequence", sequenceName="SEQ_CAMPAIGNS_ID",allocationSize = 1)
@Table(name = "CAMPAIGN")
public class CampaignEntity implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "sequence")
@Column(name = "ID")
private Long id;
@Column(name = "NAME")
private String name;
@Column(name = "IS_ACTIVE", nullable = false)
private boolean active;
@Column(name = "START_DATE", nullable = false)
private Date startDate;
@Column(name = "END_DATE", nullable = false)
private Date endDate;
@Column(name = "LEGAL_ENTITY_ID", nullable = false)
private Integer legalEntityId;
@Column(name = "DEPARTMENT", nullable = false)
@Enumerated(value = EnumType.STRING)
private Department department;
@Column(name = "CATEGORY", nullable = false)
@Enumerated(value = EnumType.STRING)
private Category category;
@Embedded
CampaignConditionsEntity campaignConditions;
@OneToMany(cascade = CascadeType.ALL, mappedBy = "campaign", orphanRemoval = true)
@OrderBy
private List<CodeEntity> campaignCodes;
public CampaignEntity() {
}
И следующие CampaignConditionsEntity:
@Embeddable
public class CampaignConditionsEntity implements Serializable {
private static final String CAMPAIGN_ID = "CAMPAIGN_ID";
@ElementCollection(fetch = FetchType.EAGER)
@CollectionTable(name = "CAMPAIGN_COND_TRIP_TYPE", joinColumns = @JoinColumn(name = CAMPAIGN_ID))
private Set<TripTypeConditionEntity> tripTypeConditions;
И следующий CodeEntity:
@Entity
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
@SequenceGenerator(name = "sequence", sequenceName = "SEQ_CODES_ID", allocationSize = 1)
public abstract class CodeEntity implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "sequence")
@Column(name = "ID", nullable = false)
private Long id;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "CAMPAIGN_ID")
private CampaignEntity campaign;
@OneToOne(mappedBy = "code", cascade = CascadeType.ALL, fetch = FetchType.LAZY, optional = false, orphanRemoval = true)
private DiscountEntity discount;
@Column(name = "MAX_USAGES", nullable = false)
private Integer maxUsages;
@Column(name = "UNLIMITED_USAGES", nullable = false)
private boolean unlimitedUsages;
@Column(name = "NEGATIVE_SH", nullable = false)
private boolean negativeSH;
@Column(name = "UNIQUE_BUYER", nullable = false)
private boolean uniqueBuyer;
@Column(name = "START_DATE")
private Date startDate;
@Column(name = "END_DATE")
private Date endDate;
@Embedded
private CodeConditionsEntity codeConditions;
public CodeEntity() {
}
Это объект CodeConditionsEntity:
@Embeddable
public class CodeConditionsEntity implements Serializable {
private static final String CODE_ID = "CODE_ID";
@ElementCollection(fetch = FetchType.EAGER)
@CollectionTable(name = "CODE_COND_TRIP_TYPE", joinColumns = @JoinColumn(name = CODE_ID))
private Set<TripTypeConditionEntity> tripTypeConditions;
@ElementCollection(fetch = FetchType.EAGER)
@CollectionTable(name = "CODE_COND_CARRIERS", joinColumns = @JoinColumn(name = CODE_ID))
private Set<CarrierConditionEntity> carrierConditions;
Это объект CarrierConditionEntity:
@Embeddable
public class CarrierConditionEntity implements Serializable {
@Column(name = "CARRIER", nullable = false, length = 3)
private String carrierCode;
@Column(name = "IS_INCLUDED", nullable = false)
private boolean included;
Проблема в том, что в журналах мы находим неожиданные удаления, когда единственная операция, которую мы выполняем, - это поиск определенных объектов кампании.
В журналах производства мы находим следующие удаления
Hibernate: delete from CODE_COND_CARRIERS where CODE_ID=? and CARRIER=? and IS_INCLUDED=?
у вас есть предложения?
спасибо