我们有一个在 JBoss 6.4 GA 上运行的 Java ee 应用程序,使用 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;
慕后森
相关分类