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