Question

Hi I got a table as follow (User table)

+----------+------------+
| Code     | reference  |
+----------+------------+
| adfasd   | hello      |
+----------+------------+
| wertwtw  | it works   |
+----------+------------+

when I make a method ==> findByCodeContaining(String param) -it works as this link says

when I make a method ==> findByreferenceContaining(String param) -it works

But, when I make a method ==> findByCodeContainingOrfindByreferenceContaining(String param) it does not work. even though I follow this link

I would like to know why it does not work and where did I make it wrong. Thanks.

No correct solution

OTHER TIPS

Your method is wrong. Remove the second 'findBy` part

findByCodeContainingOrReferenceContaining(String param)

I would also expect it to be Reference and not reference. Depending on how you created your entities.

I got it working as follow:

@Query("select u from User u where u.Code like ?1 or u.reference like ?2 ")
findByCodeContainingOrReferenceContaining(String param, String Param);

by following the above link.. thanks again.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top