我需要使用命令"yo jhipster:entity myEntity"使用JHipster创建我自己的实体,该命令与JHipster中默认出现的User实体具有多对一关系.
我尝试在向导中创建与实体"user"和字段"login"的关系但没有成功,但它无法正常工作.
用JHipster做这个的好方法是什么?或者我是否必须在没有JHipster工具的情况下创建实体(但我需要CRUD!).
谢谢,
晏
sto*_*fer 18
只是一个更新 - 几天前发布的jhipster 2.5.0增加了对此的支持.创建此答案,因为注释中的格式使我很难阅读.
为您的实体创建关系时,只需回答这样的问题
? Do you want to add a relationship to another entity? Yes
? What is the name of the other entity? user
? What is the name of the relationship? owner
? What is the type of the relationship? many-to-one
? When you display this relationship with AngularJS, which field from 'user' do you want to use? login
Run Code Online (Sandbox Code Playgroud)
关于如何显示关系的可能值可以是:id,login,first_name,last_name,email
有关更多信息,请参阅https://jhipster.github.io/2015/03/01/jhipster-release-2.5.0.html
只是为了添加@stoffer的正确答案,如果你使用的是jdl,它将如下所示:
relationship ManyToOne {
Owner{user(email)} to User{owner(name)}
}
Run Code Online (Sandbox Code Playgroud)
小智 5
官方文件中的一个很好的示例是:
entity Blog {
name String required minlength(3),
handle String required minlength(2)
}
relationship ManyToOne {
Blog{user(login)} to User
}
Run Code Online (Sandbox Code Playgroud)
如果您使用的是 1.x 版本,则这无法正常工作,因此基本上您应该手动完成,无需生成器(但这绝对是可行的)。对于 2.x 版本,我们重构了 User 对象以具有 ID 字段 -> 这应该会使这变得更容易,但由于尚未发布,因此我们目前没有反馈。
| 归档时间: |
|
| 查看次数: |
11632 次 |
| 最近记录: |