Skip to main content
Stack Overflow
  1. About
  2. For Teams

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

How to write a domain entity object to multiple database tables using Spring Data Jpa?

I have a domain model that corresponds to multiple tables when I use a relational database to design a data store. Now when I create this domain entity, I want to use Spring Data Jpa to write to multiple data tables at once. How to do it?

1.Domain Model:

{
 "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.Data tables:

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.Table relationship:

tb_execise_plan 1:m tb_execise_entry
tb_execise_entry 1:m tb_execise_entry_group

Answer*

Draft saved
Draft discarded
Cancel

lang-java

AltStyle によって変換されたページ (->オリジナル) /