I am currently planning to reorganize an old codebase written in spring + hibernate.
I have seen so many methods in a dao layer that solves the same goal as.
for example, I have a user_info table
there are as many methods in dao-layer as
getUserInfoById(String userId);
getUserInfoByName(String name);
getUserInfoByIdAndName(String userId,String name)
and the list goes on.
I know this is a very bad practice.
I thought that a solution like I will have only one getUserInfo (User user) method inside this method I will encapsulate the construction of the request, for example
query.with(user.username).with(user.userId)...
I don't know if this is right to follow ...
any suggestions? Any links to pages that explain this concept from the simplest things are also welcome.
source
share