【发布时间】:2013-03-07 14:19:23
【问题描述】:
我最近尝试为我的一些休眠映射实体引入接口,但不知道如何配置映射。
当我在没有任何进一步声明的情况下使用接口时,我总是得到以下异常:
org.hibernate.MappingException: Could not determine type for: ...MyInterface
当我明确定义 targetEntity 时,我发现一切正常:
@OneToOne(targetEntity=InterfaceImpl.class)
private MyInterface myInterface;
不幸的是,这个解决方案在我的情况下不起作用:我无法通过注释定义 targetEntity,因为我想将此类提取到一个不包含甚至不知道接口的最终实现的公共外部库。
那么有没有另一种方法来声明应该使用哪个实现,我可以在提取的库之外使用?
【问题讨论】:
标签: java hibernate jpa jpa-2.0