Skip to content
Advertisement

JPA repository return one item from db but there are multiple item in the db

I have the following function in my repository

Set<Felhasznalo> findAllByNevContainsIgnoreCase(String nev);

When I use this function in the controller I got back one User.

For example, if I have a String “John” and I call the repo function with that string I got back “John Doe” but I also have “John Doe Jr” in the db and I need him too.

Why I get only one User?

Advertisement

Answer

I see you are using a Set. Maybe you have implemented an equals() function which checks the names and the Set filters out duplicate elements.

Try changing your code to this:

List<Felhasznalo> findAllByNevContainsIgnoreCase(String nev);

So use a List.

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement