你说过
同一张桌子上的* 多对多关系 *
这不是一个好主意。这是一场噩梦。
试试这个
@Entitypublic class Friend { @Id @GeneratedValue(strategy=GenerationType.AUTO) private Integer friendId; @Column private String name; @oneToMany(mappedBy="me") private List<MyFriends> myFriends;}@Entitypublic class MyFriends { @EmbeddedId private MyFriendsId id; @Column private String additionalColumn; @ManyToOne @JoinColumn(name="ME_ID", insertable=false, updateable=false) private Friend me; @ManyToOne @JoinColumn(name="MY_FRIEND_ID", insertable=false, updateable=false) private Friend myFriend; @Embeddable public static class MyFriendsId implements Serializable { @Column(name="ME_ID", nullable=false, updateable=false) private Integer meId; @Column(name="MY_FRIEND_ID", nullable=false, updateable=false) private Integer myFriendId; public boolean equals(Object o) { if(o == null) return false; if(!(o instanceof MyFriendsId)) return false; MyFriendsId other = (MyFriendsId) o; if(!(other.getMeId().equals(getMeId())) return false; if(!(other.getMyFriendId().equals(getMyFriendId())) return false; return true; } public int hashpre() { // hashpre impl } }}问候,



