我正在努力在这里完成一项任务,虽然可能并不难,但是却完全迷失了自己,绝望了,所以希望你们对此有所了解。
在这里:
假设我有一个这样的映射:
BREAK
@Entity
@Table(name = "TB_ECRAN")
public class Break extends AbstractCommonEntity {
@Id
@GeneratedValue(generator = "id_gen_break", strategy = GenerationType.SEQUENCE)
@SequenceGenerator(name = "id_gen_break", sequenceName = "SQ_ECRAN", allocationSize = 1)
private Long id;
@OneToOne(cascade = CascadeType.ALL)
@JoinColumns({
@JoinColumn(name = "ID", referencedColumnName = "ECRAN_ID", insertable = false, updatable = false),
@JoinColumn(name = "CIBLE_TARIF_ID", referencedColumnName = "CIBLE_ID", insertable = false, updatable = false)
})
private Audience targettedAudience;
// other properties, get/set and so on
}
音频
@Entity
@Table(name = "TB_AUDIENCES")
public class Audience implements Serializable {
@Id
@GeneratedValue(generator = "id_gen_audience", strategy = GenerationType.SEQUENCE)
@SequenceGenerator(name = "id_gen_audience", sequenceName = "SQ_AUDIENCES", allocationSize = 1)
private Long id;
@Column(name = "CIBLE_ID")
private Long targetId;
@Column(name = "ECRAN_ID")
private Long breakId;
// other properties, get/set and so on
}
这是我最想要实现的目标,即:
最后一点是行不通的,通过上面的代码,我可以使用细分受众群体来获取休息时间,但是当我要创建/更新休息时间时,就无法通过级联创建受众群体,手动定义Audience.breakId和Audience.targetId以使其正常工作。
我已经在互联网上搜索了好几个小时,寻求帮助,但是奇怪的是(这不可能是一个奇怪的案例!?),似乎没有任何效果……任何人都有解决该问题的想法?预先非常感谢:)