I've come from a background in my previous role of doing all data persistence with all custom SQL and JDBC. Just started a new job for a small business where I'm the only developer and have decided to develop the businesses systems using Spring Boot with JPA for data persistence.
I don't know how I should be handling updates on child tables. I'm currently using the Spring Crud Repository for basic tables but have got to my first parent child relationship.
Given the below example table structure, how should I be managing updates?
+-------------------------+ | Order | +-------------------------+ | orderNumber | PK | +-------------------------+ +-------------------------+ | OrderLine | +-------------------------+ | orderNumber | PK | +-------------------------+ | lineNumber | PK | +-------------------------+
The users could update or delete existing order lines.
When doing an update, I could delete all of the existing orderLines first and recreate them but not sure if this is bad practice?
What is the normal approach with Spring Boot and JPA?
Should I be using some kind of cascade settings on the parent entity?