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 はなく、スーパーバイザー オブジェクトには特別なフィールドはありません。