UUID field how to compare

n1ql

#1

I am building a product which consists of two document. The first documents key is a Java UUID. Which is stored as a “kind of foreign key” in the second document. How do I write compare statement for the foreign key.

I am trying to do something like below.

    @Query("#{#n1ql.selectEntity} WHERE tId.eq($1) AND name == $2")

I am using CrudRepository. The error that I see in the log is as below.
java.lang.IllegalArgumentException: Unsupported type for JsonArray: class java.util.UUID

What is the right way to compare UUIDs in n1ql.


#2

As far as N1QL UUID is string you should be able to compare. cc @subhashni


#3

Yes, that’s the workaround I am working with. But ideally I would like to keep the datatype as UUID. Is there any way to do that?


#4

Document key must be string and there is no data type called UUID in JSON. In N1QL UUID() function returns as string.


#5

Hi @vinay,

This can be done by using a custom converter for UUID to String with the fix DATACOUCH-384 which will be available in the next service release, until then the work around is to convert the UUIDs to string.