我可以在我的 HBM 映射中执行以下操作吗?
<class name="Employee" table="employees">
<!-- assume that each person only has exactly one supervisor -->
<many-to-one name="supervisor" class="Employee" column="supervisorId" />
</class>
当我使用上述 HBM 映射时,我的服务器拒绝启动并出现以下错误:
org.hibernate.InstantiationException: could not instantiate test object Employee
Caused by: java.lang.StackOverflowError
at Employee.<init>(Employee.java:11)
at Employee.<init>(Employee.java:11)
at Employee.<init>(Employee.java:11)
...... (about a hundred duplicates)
Employee.java 的第 11 行只是说:
public class Employee implements Serializable {
我应该如何模拟我的主管与员工的关系?主管没有特殊的 POJO,主管对象没有特殊字段。