0

Try to solve the issue with usage filter object properties as arguments in @Query methods in reactive crud repository using spring-data-r2dbc.

@Query("SELECT id, someId FROM Foo WHERE someId=:query.someId"")
Flux<Foo> findByCollectionQuery(FooCollectionQuery query);

FooCollectionQuery:

@Value
public class PaymentCollectionQuery {

    @NotNull
    UUID someId;

}

Is there a possibility to provide the whole PaymentCollectionQuery object to @Query annotations specifying concrete property in query?

Right now I got the following exception:

java.lang.UnsupportedOperationException: Binding parameters is not supported for the statement 'SELECT id, someId FROM Foo WHERE someId=query.someId'
Viktor M.
  • 4,393
  • 9
  • 40
  • 71

1 Answers1

0

Try to use SpEL:

@Query("SELECT id, someId FROM Foo WHERE someId = :#{#query.someId}")
Flux<Foo> findByCollectionQuery(@Param("query") FooCollectionQuery query);
zfChaos
  • 415
  • 4
  • 13
  • Unfortunately, it seems only Spring JPA support it, but JPA don't support R2DBC, only JDBC. Found related issue regarding SpEL usage with R2DBC - https://github.com/spring-projects/spring-data-r2dbc/issues/164 but no progress. – Viktor M. Dec 20 '19 at 14:42