Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/hibernate/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 使用id的自集';休眠自连接多对多映射;s_Java_Hibernate_Hibernate Mapping - Fatal编程技术网

Java 使用id的自集';休眠自连接多对多映射;s

Java 使用id的自集';休眠自连接多对多映射;s,java,hibernate,hibernate-mapping,Java,Hibernate,Hibernate Mapping,我正在尝试使用一组长Id(self-Id)创建一个新的hibernate self-many映射。它的正确映射是什么 我试图在一个人和他的朋友之间建立一个映射关系(不正常的人) 我有一个到tbl_Person表的Person类映射 Person.java public class Person { private Long personId; private String name; //much more properties in here make this obj

我正在尝试使用一组长Id(self-Id)创建一个新的hibernate self-many映射。它的正确映射是什么

我试图在一个人和他的朋友之间建立一个映射关系(不正常的人) 我有一个到tbl_Person表的Person类映射

Person.java

public class Person {
    private Long personId;
    private String name;
    //much more properties in here make this object huge
    private Set<Person> friends= new HashSet<Person>();
}


谢谢。

为什么不使用lazy true?谢谢你的回答。我将使用lazy='true',但是你知道正确的映射应该是什么样子吗?据我所知,没有办法通过物理映射只保留id,只存储id,但它引用整个对象。为什么不使用lazy='true?谢谢你的回答。我将使用lazy='true',但您知道正确的映射应该是什么样子吗?据我所知,没有办法通过物理映射只保留id,只存储id,但它引用整个对象
<set name="friends" table="friends" cascade="none" lazy="false">
    <key column="friend_id"/>
    <many-to-many column="person_id" class="com.kruders.model.bean.Person"/>
</set>

    Set<Person> friends
    Set<Long> friendsIds
personId|friend
1       |2
1       |3
2       |1