例如,我想在用户 A 和用户 B 之间建立关系,他们有名为 MakeFriend 的关系实体,我使用下面的代码,但我也想在关系实体中设置一些属性值,如角色 = 10....... ..
userRepository.createRelationshipBetween(startUser, endUser, MakeFriend.class, RelTypes.FRIEND.name());
@RelationshipEntity
public class MakeFriend {
@GraphId
private Long id;
private String role;
@StartNode
private UserEntity startUser;
@EndNode
private UserEntity endUser
@NodeEntity
public class UserEntity implements Serializable {
private static final long serialVersionUID = 1L;
public static final String FRIEND = "FRIEND";
public static final String JOYNED = "JOYNED";
@GraphId
private Long id;
@Indexed(unique = true)
private Long userId;
private String email;