[英]Map Collection of Interface using annotation in Hibernate
我有一個名為Rule
的接口,帶有2個實現類,它們都共享一個Abstract基類。
@MappedSuperclass
public interface Rule { .. }
@Entity
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
public abstract class BaseRule implements Rule {
@Entity
public class ImlementingRule1 extends BaseRule {
@Entity
public class ImlementingRule1 extends BaseRule {
我在containgRules類中使用此Rule
接口,例如:
@OneToMany
@JoinColumn(name = "RULES_ID")
private List<Rule> rules;
無論我嘗試哪種設置,我最終都會得到:
Caused by: org.hibernate.MappingException: Cannot use identity column key generation with <union-subclass> mapping for: mynamespace.BaseRule
我個人沒有發現其他解決方案,只能使用抽象基類代替接口。
@OneToMany
@JoinColumn(name = "RULES_ID")
private List<BaseRule> rules;
它說在這里 :
當前不支持注釋接口。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.