0

I want to have a method which searches for data on the basis of status and (SellerId or BuyerId). The following method name doesnt work for me and gives me an error: No parameter available for part status SIMPLE_PROPERTY (1): [Is, Equals] NEVER. What is to be corrected in the method signature? Seller and Buyer are two separate tables each having a field id.

findByStatusIsAndSellerIdOrStatusIsAndBuyerId(status, id)

Kavya Jain
  • 87
  • 1
  • 10
  • The Spring data method names get ridiculous with more than a couple of properties. I would suggest using the `@Query("...")` annotation to manually define and then you can call your method whatever. – Alan Hay Feb 14 '19 at 10:02
  • Possible duplicate of [Spring data jpa - How to combine multiple And and Or through method name](https://stackoverflow.com/questions/35788856/spring-data-jpa-how-to-combine-multiple-and-and-or-through-method-name) – Jens Schauder Jun 24 '19 at 05:10

1 Answers1

1
findByStatusIsAndSellerIdOrStatusIsAndBuyerId(status, id)

expects 4 parameters for the four conditions.

You also should never use a derived query with AND and OR because precedence gets pretty confusing at best.

So pick a name that you like and use a @Query annotation to specify the query to use.

SELECT x FROM X x where x.status = :status and (x.seller.id = :id or x.buyer.id = :id) should be close to what you need.

Jens Schauder
  • 77,657
  • 34
  • 181
  • 348