我打错了字,但结果出乎意料。不知道这是一个错误还是我做错了什么?
示例1 :访问单个记录时,这将为_links
中的SocialAccounts创建一个链接。
@OneToMany
@JoinTable(name = "contact_social",
joinColumns = @JoinColumn(name="contact_id", referencedColumnName="contact_id"),
inverseJoinColumns = @JoinColumn(name="social_id", referencedColumnName="social_id"))
public Set<Social> socialAccounts = new HashSet<>();
示例2 :这将在响应的字段区域中创建一个列表-> SocialAccounts []
@OneToMany
@JoinTable(name = "contact_social",
joinColumns = @JoinColumn(name="contact_id", referencedColumnName="contact_id"),
inverseJoinColumns = @JoinColumn(name="social_id", referencedColumnName="social_id"))
public Set<Social> SocialAccounts = new HashSet<>();
唯一的区别是socialAccounts
与SocialAccounts
什么是正确的?为什么行为不同?
示例1-响应
{
"firstName": "Jane",
"lastName": "Doe",
"company": "Doe, Jane",
"isConverted": false,
"dateCreated": "2018-08-17T05:06:18.068",
"dateModified": "2018-08-17T05:06:18.069",
"_links": {
"self": {
"href": "http://localhost:8080/leads/3d5a639c-d65b-4017-abbb-3bb4c6e69994"
},
"socialAccounts": {
"href": "http://localhost:8080/leads/3d5a639c-d65b-4017-abbb-3bb4c6e69994/socialAccounts"
}
}
}
示例2-响应
{
"firstName": "Jane",
"lastName": "Doe",
"company": "Doe, Jane",
"isConverted": false,
"dateCreated": "2018-08-17T05:06:18.068",
"dateModified": "2018-08-17T05:06:18.069",
"socialAccounts": [],
"_links": {
"self": {
"href": "http://localhost:8080/leads/3d5a639c-d65b-4017-abbb-3bb4c6e69994"
},
"SocialAccounts": {
"href": "http://localhost:8080/leads/3d5a639c-d65b-4017-abbb-3bb4c6e69994/SocialAccounts"
}
}
}