当我使用关系数据库设计数据存储时,我有一个对应于多个表的域模型。现在,当我创建这个域实体时,我想使用 Spring Data Jpa 一次写入多个数据表。怎么做?
1.领域模型:
{
"id": 2,
"startTime": "2018-07-09T08:59:08.853Z",
"endTime": "2018-07-09T08:59:08.853Z",
"group": 2,
"entries": [
{
"id": 1,
"target": 90,
"isFinished": false,
"name": "俯卧撑",
"groups": [
{
"id": 1,
"name": "第一组",
"number": 30
},
{
"id": 2,
"name": "第一组",
"number": 30
}
]
}
]
}
2.数据表:</p>
tb_execise_plan(id, start_time, end_time, group)
tb_execise_entry(id,name,target, is_finished, execise_plan_id, project_id)
tb_execise_entry_group(id,name,number,execise_entry_id)
3.表关系:
tb_execise_plan 1:m tb_execise_entry
tb_execise_entry 1:m tb_execise_entry_group