I use Spring Data JPA for my repository layer. I need to query entities by every possible property and combinations of its properties. So my typical repository looks like this.
public interface UserRepository extends JpaRepository<User, Long> {
User findByLogin(String login);
User findByEmail(String email);
User findByName(String name);
User findByLoginAndEmail(String login, String email);
User findByLoginAndName(String login, String name);
User findByLoginAndEmailAndName(String login, String email, String name);
//and so on
}
Even with three properties it looks ugly enough. Are there any more flexible alternatives to this approach? Or this design is OK(at least I do not have to implements all of these methods)?