<How can I get data from DB in my service layer?> ...
# stackoverflow
u
How can I get data from DB in my service layer? I have a method in my repository 'getUserByNameAndAge()', which returns a user from DB by 2 arguments. In my service layer I need to check, if I don't have in DB user with requested name, i need to throw some custom 'InvalidUserNameException', and if i don't have in db user with such age, i need to throw some custom 'InvalidUserAgeException'. But i really can't understand how can I do this. Here is my repository interface UserRepository : JpaRepository { @Query(value = "SELECT u.name,...