use of io.vertigo.commons.transaction.Transactional in project vertigo by KleeGroup.
the class AbstractSqlSearchLoader method loadNextURI.
/**
* {@inheritDoc}
*/
@Override
@Transactional
protected final List<URI<S>> loadNextURI(final P lastId, final DtDefinition dtDefinition) {
try (final VTransactionWritable tx = transactionManager.createCurrentTransaction()) {
final String tableName = getTableName(dtDefinition);
final String taskName = "TK_SELECT_" + tableName + "_NEXT_SEARCH_CHUNK";
final DtField idField = dtDefinition.getIdField().get();
final String idFieldName = idField.getName();
final String request = getNextIdsSqlQuery(tableName, idFieldName);
final TaskDefinition taskDefinition = TaskDefinition.builder(taskName).withEngine(TaskEngineSelect.class).withDataSpace(dtDefinition.getDataSpace()).withRequest(request).addInRequired(idFieldName, idField.getDomain()).withOutRequired("dtc", Home.getApp().getDefinitionSpace().resolve(DOMAIN_PREFIX + SEPARATOR + dtDefinition.getName() + "_DTC", Domain.class)).build();
final Task task = Task.builder(taskDefinition).addValue(idFieldName, lastId).build();
final DtList<S> resultDtc = taskManager.execute(task).getResult();
final List<URI<S>> uris = new ArrayList<>(resultDtc.size());
for (final S dto : resultDtc) {
uris.add(new URI<S>(dtDefinition, DtObjectUtil.getId(dto)));
}
return uris;
}
}
Aggregations