我有一个名为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;
它指出right here:
当前不支持注释接口。