繁体   English   中英

在Hibernate中使用注释映射接口的地图集合

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM