Reputation: 1135
I'm struggling to understand how to implement a simple query like
SELECT * from Orders where category=1 and userid=1
with Spring + JPA + Mysql.
I see that extending JpaRepository
the query findByUserId
and findByCategory
are already implemented and working.
However, how do I add a simple filter to the basic query?
I cannot apply the filter to the result as it will be too big.
I am struggling to find the right direction.
Upvotes: 0
Views: 107
Reputation: 328
If you extended JpaRepository, you can do something like this:
List<Order> findByUserIdAndCategory(Integer userId, Integer category);
You can take a look at JpaRepository query methods here: https://docs.spring.io/spring-data/jpa/docs/current/reference/html/#jpa.query-methods.query-creation
Upvotes: 1