“ firstName”:“简”,

“ lastName”:“ Smith”,

“ middleName”:“琳达”,

“ maidenName”:“ Welch”,

“ preferredName”:“琳达”,

“ birthDate”:“ 1967-09-23”,

“性别女”,

“ email”:“ [email protected]”,

“ primaryPhone”:“ 555-555-5555”,

“主要地址”: {

"addressLine1": "123 Evergreen Terrance",
"addressLine2": "Unit 10001",
"addressLine3": "c/o John Smith",
"city": "Springfield",
"state": "MA",
"postalCode": "55801",
"country": "US"


},

最佳答案

我不确定您是否完全理解您的问题,但是如果您想直接将PrimaryAddress的字段保存在父表中,请直接将这些字段放在父类中并删除类PrimaryAddress。

但是,在这种情况下,您应该考虑对PrimaryAddress使用@OneToOne注释,如下所示:

@OneToOne
private PrimaryAddress primaryAddress;


此批注创建了另一个表primary_address,并在父表中添加了一个称为primary_address_id的附加字段作为外键。

10-04 19:11