JHipster 踩坑之旅(2)-Managing relationships(3)

A one-to-one relationship

一对一的关系

Driver (1) <-----> (1) Car

举例:一对一的关系意味着司机只能驾驶一辆车,而一辆车只能有一个司机。
 
================= Driver =================
Fields
name (String)
Generating relationships to other entities
? Do you want to add a relationship to another entity? Yes
? What is the name of the other entity? Car
? What is the name of the relationship? car
? What is the type of the relationship? one-to-one
? Is this entity the owner of the relationship? No
? What is the name of this relationship in the other entity? driver
 
================= Car =================
Fields
brand (String)
license (String)
Generating relationships to other entities
? Do you want to add a relationship to another entity? Yes
? What is the name of the other entity? Driver
? What is the name of the relationship? driver
? What is the type of the relationship? one-to-one
? Is this entity the owner of the relationship? Yes
? What is the name of this relationship in the other entity? car
? When you display this relationship with Angular, which field from ‘Driver’ do you want to use? This field will be displayed as a String, so it cannot be a Blob name
? Do you want to add any validation rules to this relationship? No
现在在这两个实体之间有一对一的关系!将在Car中选择一个司机,因为Car属于自己的一方。

文章已创建 112

发表评论

您的电子邮箱地址不会被公开。 必填项已用*标注

相关文章

开始在上面输入您的搜索词,然后按回车进行搜索。按ESC取消。

返回顶部