W
W
Wan-Derer2022-01-17 11:20:58
Java
Wan-Derer, 2022-01-17 11:20:58

Architecture. How correct is it to store non-database data in Entity?

Hello!
I am writing an application on Spring Boot/Spring Data.
Let's say I have a "model" class which is Entity. Its fields correspond to the fields of records in the database and are read in the usual way through the repository.
I want to add a number of fields to this class that are not in the database (declare them as Transient) and which I need to store intermediate values, flags, etc. It's convenient for me. it's easier to work with a single object than with two/three. But how correct is this from the point of view. architecture? Do they do that at all? What problems can come up here? And if not, how do they usually solve such problems?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Michael, 2022-01-18
@Akela_wolf

In principle, you can, no one will shoot you for this. Problems - it all depends on the scale of your application and the requirements for further support and changes in the code. I don’t see anything directly serious that will always or almost always come out in this story.

E
Egor P, 2022-01-18
@Egor4

I would make another EntityTo class and inject Entity into it and enrich it with fields.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question