I'm persisting an entity in a CouchBase repository and trying to query it. The entity looks like this:
@Document(expiry = 0)
public class GsJsonStore implements Serializable {
private static final long serialVersionUID = 7133072282172062535L;
@Id @GeneratedValue(strategy=GenerationType.AUTO)
private long id;
@Field
private Map<String,Object> _object;
@Field
private String _subject;
@Field
private String _predicate;
//Getters and Setters
}
I'm querying the entity by using N1QL queries on the CouchbaseOperations template like this:
String query1 = "SELECT META(default).id as _ID, META(default).cas as _CAS, default.* FROM default WHERE "+key+"="+"'"+value+"'";
List<GsJsonStore> list = operations.findByN1QL(N1qlQuery.simple(query1), GsJsonStore.class);
I'm querying for a K-V pair within the _object Map. I get an error : No mapping metadata found for java.lang.Object
Why is this happening? Also, I'm storing a json object as Map<String,Object>
in Couchbase, I tried using the jackson JsonNode
type but the object was also storing class related metadata. Is there a better datatype to represent the json type?
EDIT
Data stored in Couchbase :
{
"_object" : {
"Name" : "Kapil",
"Age" : {
"Nested" : 21
}
},
"_subject" : "Subject",
"_predicate" : "Predicate"
}
The key I'm looking for is _object.Name and value is 'Kapil'