Spring Boot: keywords supported for JPA

YouAreAwesome :

I wanted to perform the Spring JPA repository where wanted to apply the and operation among 2 columns where one column cloud have multiple values in it.

SQL query for the same:

select * from table_name where col1='col1_val' and col2 IN ('col2_val_a','col2_val_b','col2_val_c');

I know that for and operation I can extend the JpaRepository and create the method with like this for:

List<MyPoJoObject> findByCol1AndCol2(String col1_val,String col2_val);

and for IN operation we can use : findByCol2In(Collection<String> col2_val)

But i did not know how i can club both the mentioned JPA default method into one, as per my sql statement mentioned before.

Jonathan JOhx :

You can use the following method named:

List<MyPoJoObject> findByCol1AndCol2In(String col1_val, Collection<String> col2_val);

On this link repository-query-keywords you can find repository query keywords that you can use and combine them as well.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=165182&siteId=1