Reputation: 616
I need to write filtering method based on county/status/symbol.
my repository query looks like this
@Query("#{#n1ql.selectEntity} WHERE `platform`='FXSERVICE' " +
"AND `deleted`=false "+
"AND `country` like $country "+
"AND `symbol` like $symbol "+
"AND `state` like $state "+
"AND #{#n1ql.filter}")
Stream<TradeOrderDO> findByCountry(@Param("country") String country, @Param("symbol") String symbol, @Param("state") String state);
and calling the api like this
String country = "INDIA";
String symbol = "INR";
String state = "MANUAL";
tradeOrderRepository.findByCountry(country, symbol, state)
Now I pass all the values (county/symbol/state) it works fine.
But if want to filter with only state and ignore county and symbol
String country = "%%";
String symbol = "%%";
String state = "MANUAL";
tradeOrderRepository.findByCountry(country, symbol, state)
Query does not work. It does not return any value. In query editor of couchbase , '%%' wild card works but not working for repository query. How do I write the query for this type of filtering.
Upvotes: 0
Views: 280
Reputation: 616
@Query("#{#n1ql.selectEntity} WHERE `platform`='FXSERVICE' " +
"AND `deleted`=false "+
"AND `country` like '%' || $country || '%' "+
"AND `symbol` like '%' || $symbol || '%' "+
"AND `state` like '%' || $state || '%' "+
"AND #{#n1ql.filter}")
Stream<TradeOrderDO> findByCountry(@Param("country") String country, @Param("symbol") String symbol, @Param("state") String state);
With this query it works.
Upvotes: 1