我此刻与MarkLogic POJO数据绑定接口工作时JSONMappingException。我可以为MarkLogic编写POJO。现在我想搜索这些POJO并检索搜索结果。我遵循以下指示:https://docs.marklogic.com/guide/java/binding#id_89573但是,搜索结果似乎不会返回正确的对象。我得到一个JSONMappingException。代码如下:MarkLogic POJO数据绑定接口:执行POJO搜索
HashMap<String, MatchedPropertyInfo> matchedProperties = new HashMap<String, MatchedPropertyInfo>();
PropertyMatches PM = new PropertyMatches(123,"uri/prefix/location2", "uri/prefix", 1234,0,"/aKey","/aLocation",true,matchedProperties);
MatchedPropertyInfo MPI1 = new MatchedPropertyInfo("matched/property/uri1", "matched/property/key1", "matched/property/location1", true,"ValueMatch1", 12, 1*1.0/3, true);
MatchedPropertyInfo MPI2 = new MatchedPropertyInfo("matched/property/uri2", "matched/property/key2", "matched/property/location2", true,"ValueMatch2", 14, 1.0/2.0, true);
PM.getMatchedProperties().put("matched/property/prefix/location1", MPI1);
PM.getMatchedProperties().put("matched/property/prefix/location2", MPI2);
PojoRepository myClassRepo = client.newPojoRepository(PropertyMatches.class, Long.class);
myClassRepo.write(PM);
PojoQueryBuilder qb = myClassRepo.getQueryBuilder();
PojoPage<PropertyMatches> matches = myClassRepo.search(qb.value("uri", "uri/prefix/location2"),1);
if (matches.hasContent()) {
while (matches.hasNext()) {
PropertyMatches aPM = matches.next();
System.out.println(" " + aPM.getURI());
}
} else {
System.out.println(" No matches");
}
PropertyMatches(PM)对象成功写入MarkLogic数据库。这个类包含一个成员:它与"uri/prefix/location2"
开始private String URI
。在上面的例子中,matches.hasContent()
返回true。但是,我越来越对PropertyMatches aPM = matches.next();