My Requirements:
I have to save user information along with permissions associated with related markets and stores.
For Example:
User Details:
- Username
- Admin
- Area
- List
- List
Markets:
Stores:
And the end results in the database must be saved as follows:
Profile - Table:
Profile_ID Profile_Name Admin Area Email_ID
1 xyz TRUE Store [email protected]
2 abc FALSE WareHse [email protected]
Market- Table:
MKT_ID MKT_NAME Permission Profile_ID
101 Bangalore view 1
102 Hyderabad approve 1
101 Bangalore approve 2
102 Hyderabad approve 2
Store - Table:
Store_ID Store Name Permission MKT_ID Profile_ID
1001 B-AAA View 101 1
1002 B-BBB View 101 1
2001 H-AAA approve 102 1
2002 H-BBB approve 102 1
1001 B-AAA approve 101 2
1002 B-BBB approve 101 2
2001 H-AAA approve 102 2
2002 H-BBB approve 102 2
With the following additional requirement points:
Profile -> Market
is a OneToMany
entity relationship,
Market -> Store
is a OneToMany
entity relationship
- In my example there are two markets i.e. Bangalore and Hyderabad and Bangalore and Hyderabad has two stores respectively. So while saving one profile record two markets records will be saved and four profile records will be saved.
- If the same markets or same store is found for a existing user it will update the record rather than creating a new record across all the tables.
Any help with the: Save
, Update
and Delete
database operations across all scenarios will be very much appreciated.
I tried the following approach.
question from:
https://stackoverflow.com/questions/65859396/how-is-a-onetomany-relationship-between-entities-defined-in-jpa-hibernate 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…