[英]How to persist a recursive property in Hibernate?
我正在努力尝试一个涉及具有相同类类型属性的类的Hibernate映射。 即(简体):
public class A {
protected A next = null;
}
我的映射当前如下所示:
<hibernate-mapping package="mypackage">
<class name="A" table="tblA" lazy="false">
<id name="id">
<generator class="native"/>
</id>
<property name="next" type="A" />
</class>
</hibernate-mapping>
但是,在Hibernate初始化期间,我Exception in thread "main" org.hibernate.MappingException: Could not determine type for: A, at table: tblA, for columns: [org.hibernate.mapping.Column(next)]
得到了一个Exception in thread "main" org.hibernate.MappingException: Could not determine type for: A, at table: tblA, for columns: [org.hibernate.mapping.Column(next)]
。
我的理解是,我正在尝试使用尚未声明的映射(因为我现在正在这样做),因此可能需要类似前向声明的内容。 你有什么主意吗?
谢谢
Tunnuz
它是一个参考:
<many-to-one name="next"/>
<Property>
用于基本类型。 通常不需要声明类型,因为它是由Hibernate使用反射确定的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.