Jhipster用户朋友自我关系



我想使用实体"friend"在用户之间创建一个"friend"关系。我试过这个,但没用。

entity Friend {
status Boolean, 
modified LocalDate,
created LocalDate
}
relationship ManyToMany {
Friend{user(login)} to User,
User to Friend{user(login)}
}

我该怎么做?

感谢

您不能在JDL 中创建与User实体的关系

一个变通方法是创建另一个实体,并使用像这样的一对一关系

entity Friend {
status Boolean, 
modified LocalDate,
created LocalDate
}
entity UserExtended {
...
}
relationship OneToOne {
UserExtended to User
}
relationship ManyToMany {
Friend{userExtended(login)} to UserExtended,
UserExtended to Friend{userExtended(login)}
}

您可能需要考虑在生成的代码中直接创建与User的关系。

找到它:

entity UserExtra {
.....
}
entity Friend{
status Boolean, 
modified LocalDate,
created LocalDate
}
relationship OneToOne {
UserExtended{user(login)} to User
}
relationship OneToMany {
UserExtended{friends} to Friend{user}
}
relationship ManyToOne {
UserExtended{friend} to UserExtended{users}
}

最新更新