Generic service for CRUD operations
In my Spring Boot project, I want to have a single service class for generic CRUD that can handle any entity, not to extend it, just to call it from controllers indicating entity, repository and DTO (Or something like this) the main idea is to have a single service class to CRUD to all entities, if the entity have unique or different behavior I will separate it in other service e.g. user authentication. Reference the entities, repositories and DTOs outside the CRUD service. Doing this to not repeat the same logic and creating a class for each entity.
7 Replies
⌛
This post has been reserved for your question.
Hey @Franscis123$#! Please useTIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here./close
or theClose Post
button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically marked as dormant after 300 minutes of inactivity.
This service template dedicated to Flavor entity I want can be used for all entities:
isnt an interface with methods like create etc better
and then you can just implement it
I do it, that is the simple way, but the idea is not repeat that logic creating a class for each entity
💤
Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.
In case your post is not getting any attention, you can try to use /help ping
.
Warning: abusing this will result in moderative actions taken against you.
I got it this way:
In the controller:
💤
Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.
In case your post is not getting any attention, you can try to use /help ping
.
Warning: abusing this will result in moderative actions taken against you.