update the N1QL example Code
This commit is contained in:
parent
18b830d695
commit
a2760396cd
@ -3,14 +3,18 @@ package com.baeldung.couchbase.n1ql;
|
|||||||
import com.couchbase.client.java.query.N1qlQueryResult;
|
import com.couchbase.client.java.query.N1qlQueryResult;
|
||||||
import com.fasterxml.jackson.databind.JsonNode;
|
import com.fasterxml.jackson.databind.JsonNode;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.Logger;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class CodeSnippets {
|
public class CodeSnippets {
|
||||||
|
|
||||||
private static ObjectMapper objectMapper = new ObjectMapper();
|
private static ObjectMapper objectMapper = new ObjectMapper();
|
||||||
|
private static final Logger logger = Logger.getLogger(CodeSnippets.class.getName());
|
||||||
|
|
||||||
public static List<JsonNode> extractJsonResult(N1qlQueryResult result) {
|
public static List<JsonNode> extractJsonResult(N1qlQueryResult result) {
|
||||||
return result.allRows().stream()
|
return result.allRows().stream()
|
||||||
@ -18,7 +22,7 @@ public class CodeSnippets {
|
|||||||
try {
|
try {
|
||||||
return objectMapper.readTree(row.value().toString());
|
return objectMapper.readTree(row.value().toString());
|
||||||
}catch (IOException e) {
|
}catch (IOException e) {
|
||||||
e.printStackTrace();
|
logger.log(Level.WARNING, e.getLocalizedMessage());
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user