S
S
Sergey Litvinov2019-11-10 23:23:05
Java
Sergey Litvinov, 2019-11-10 23:23:05

Spring Data, how to write on it correctly?

I am writing a project in Spring.
And the monoculture of the domain began to strain me. Let me explain:
There is a model with several connections. Dialogue with Spring:
- I want to have links to all these links when querying.
- Not a question, for this there are domain objects in the properties.
- I want the user to enter a component_id, not an object of the Component class
- No problem, create a DTO.
- But after all, you still have to create objects (for saving), okay, let's create an empty one with an id (received from the user in the DTO).
- object references an unsaved transient instance!
- that is, I need to search for an object with such an id in the database, then push it into the property of the desired object, and then save it?
- Yes
- And if there are 10 of them?
- What is the problem?
- 20 sql queries per save - doesn't that seem like a bit much?
- No
- any other options?
- change the cascade
- but I will need to delete descendants ...
But is there some way to optimize and logically configure the interaction of the model?
What is the philosophy of the developers, what concepts should be thought of?
How to write in Spring Data?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question