use of org.neo4j.ogm.drivers.embedded.response.RowModelResponse in project neo4j-ogm by neo4j.
the class EmbeddedRequest method execute.
@Override
public Response<RowModel> execute(DefaultRequest query) {
// TODO this is a hack to get the embedded driver to work with executing multiple statements
final List<RowModel> rowmodels = new ArrayList<>();
String[] columns = null;
for (Statement statement : query.getStatements()) {
Result result = executeRequest(statement);
if (columns == null) {
columns = result.columns().toArray(new String[result.columns().size()]);
}
RowModelResponse rowModelResponse = new RowModelResponse(result, entityAdapter);
RowModel model;
while ((model = rowModelResponse.next()) != null) {
rowmodels.add(model);
}
result.close();
}
final String[] finalColumns = columns;
return new Response<>() {
int currentRow = 0;
@Override
public RowModel next() {
if (currentRow < rowmodels.size()) {
return rowmodels.get(currentRow++);
}
return null;
}
@Override
public void close() {
}
@Override
public String[] columns() {
return finalColumns;
}
};
}
Aggregations