Sanka
Sanka

Reputation: 1324

Unable to execute query due to the following n1ql errors

I am unable to execute a query due to the following n1ql errors:

Repository Query:

public ClientMatrixFactorPopUp findBySupportedValuesAndRequestId(SortedMap supportedValues,Long requestId);

Expected N1QL:

SELECT * FROM b_factor
    WHERE  _class = "com.intervest.price.oxygen.model.ClientMatrixFactorPopUp" and requestId=21
    and supportedValues= { "BAGGAGE_COVER": "0", "CANCELLATION_COVER": "0", "GADGET_COVER": "2", "TRIP_EXCESS": "250" }

StackTrace:

Unable to execute query due to the following n1ql errors: 
{"msg":"Object member missing name or value: (`BAGGAGE_COVER` = 500) - at , \n Object member missing name or value: (`CANCELLATION_COVER` = 500) - at , \n Object member missing name or value:         (`GADGET_COVER` = 1) - at , \n Object member missing name or value: (`TRIP_EXCESS` = 50) - at }","code":3000}
[
  {
    "b_factor": {
      "_class": "com.intervest.price.oxygen.model.ClientMatrixFactorPopUp",
      "requestId": 21,
      results": [...],
      "supportedValues":{
        "BAGGAGE_COVER": "0",
        "CANCELLATION_COVER":"0",
        "GADGET_COVER":"2",
        "TRIP_EXCESS":"250"
      }
    }
  }
]

Upvotes: 2

Views: 276

Answers (1)

vsr
vsr

Reputation: 7414

It looks like spring data generated wrong query. The error shows there is back ticks around BAGGAGE_COVER. It should have been constant object.

Check the query generation right.

The query provided above will work. Try in Web console and verify.

Unless really need exact match, Instead of object comparison should try required fields, So that document has extra fields it can match.

SELECT * FROM b_factor
WHERE _class = "com.intervest.price.oxygen.model.ClientMatrixFactorPopUp" 
      AND requestId = 21
      AND supportedValues.BAGGAGE_COVER = "0"
      AND supportedValues.CANCELLATION_COVER = "0"
      AND supportedValues.GADGET_COVER = "2"
      AND supportedValues.TRIP_EXCESS = "250";

Upvotes: 2

Related Questions