Reputation: 2102
I have got a problem with my spring data jpa. When I do a select query instead of reciving the right results I get the first result duplicated the right number of times. So for example when I have such records in my database
Cat{ 'name':'johnny', 'status': 'Happy'}
Cat{ 'name':'johnny', 'status': 'Angry'}
Cat{ 'name':'johnny', 'status': 'Hungry'}
and I do a query Select * from cats where name = 'johnny'
instead of receiving these 3 results i receive Cat{ 'name':'johnny', 'status': 'Happy'}
duplicated three times.
What can be a reason of such a strange behaviour ?
In my real database I have unique keys on multiple columns, I thought maybe they need a special mapping ?
Upvotes: 1
Views: 70
Reputation: 2561
If there are multiple records then you should return List<Cat>
in your case.
List<Cat> findByName(String name);
Upvotes: 1