Let me share my opinion.
At first, I think your question has nothing to do with spring loading. spring loading simply provides a convenient and easy way to launch the application and makes it easy to create the application. But still you have a rest controller, and from now on it is not much different for any other type of application.
So, you are really asking if it makes sense to support the abstraction of JSON objects and convert them to Business Logic Entity objects, and then convert them again to database objects, or enough to support only 2 levels and level out Json.
I think the answer is "it depends."
First of all, in general, the trend is currently a simplification. So, perhaps, it is enough to support only 1 level of objects.
There are many advantages to this approach:
- Obviously less code to support
- Development and testing speed (POJO must be verified, converters must be verified, etc.)
- Execution speed - you do not need to spend CPU time on conversion. The kind of obvious implication.
- Less obvious: memory consumption. Suppose you are working with most of the data returned by your DAO. Say it takes up 10 MB of memory (just for example). Now, if you start converting to Business Entities, you will spend another 10 MB, and now, if its objects are JJSon, well, its 10 MB again. The fact is that all these objects can coexist simultaneously in memory. Of course, the GC will probably take care of them if you fix it, but thatβs a completely different story.
However, there is one drawback to this simplification.
In one word, I would call this commitment
There are three types of APIs in an application.
The API you are targeting at the web service level is the JSon framework. Most likely, various clients (not necessarily using the JVM at all) work against your web service and consume data. Therefore, they really expect you to provide JSon objects of this structure.
API of your business. If your level of business logic is quite complex, you probably have a whole team that develops this logic. This way, you usually work at the API level between teams.
The DAO level is the same story as business logic.
So what happens if you, say, change this API at the same level. Does this mean that all levels will be violated?
Example
Suppose we do not support the "JSon" level. In this case, if we change the API at the Business Logic level, JSON will also automatically change. All other frameworks happily transform the object for us, and there is a chance that the user will receive other data.
Another example
Suppose your BL level provides a Person object that looks like this:
class Person { String firstName; String lastName; List<Language> languages; } class Language { ... }
Now let's say that you have a user interface that uses your REST service, which provides a list of faces upon request. What to do if the user interface has two different pages. One that shows only Persons (in this case, it makes no sense to provide a list of languages ββthat a person speaks). On the second page you want to get the full information.
So, you will eventually expose 2 web services or complicate the existing ones by some parameters (the more parameters than you, the less it reminds the others :)) Maybe the separation will help a little here? I dont know.
Bottom line. I would say that as long as you can live without such a separation - do it. It can work even for fairly large projects. And, of course, it can work for small or medium-sized projects.
If you find yourself struggling with corrections and you feel that such a separation will solve the problems - make a separation.
Hope this helps to understand the implications and choose what works for you.