I have a User entity which has a one-to-many relationship with UserSkill entity. UserSkill can be active and inactive (inactive is set upon skill deletion, instead of deleting it completely). The thing is, that most of the time active skills are important for end user (inactive may be used later for statistical purposes). Having that in mind, when I query User entity from the database, most of the time I want to access only active skills through it.
My question is, which implementation is better:
- I have
getUserSkills(simple getter) andgetActiveUserSkills(getter with some filtering) on theUserentity, and usegetActiveUserSkillsmost of the time. (Everyone seems to keep telling that POJO should be POJO, no additional logic.) - I have
userSkillService, and I havegetActiveUserSkills(User user)method, which returns only active user skills. I then use these active skills along withUserwhen I need them. The problem here is that every time I getUser, I will have those unnecessary inactive skills with it.
Other implementation suggestions are also welcome. Thanks !
Aucun commentaire:
Enregistrer un commentaire