use of org.qi4j.api.usecase.UsecaseBuilder in project qi4j-sdk by Qi4j.
the class SQLEntityStoreMixin method queryAllEntities.
private void queryAllEntities(Module module, EntityStatesVisitor entityStatesVisitor) {
Connection connection = null;
PreparedStatement ps = null;
ResultSet rs = null;
UsecaseBuilder builder = UsecaseBuilder.buildUsecase("qi4j.entitystore.sql.visit");
Usecase usecase = builder.withMetaInfo(CacheOptions.NEVER).newUsecase();
final DefaultEntityStoreUnitOfWork uow = new DefaultEntityStoreUnitOfWork(entityStoreSPI, newUnitOfWorkId(), module, usecase, System.currentTimeMillis());
try {
connection = database.getConnection();
ps = database.prepareGetAllEntitiesStatement(connection);
database.populateGetAllEntitiesStatement(ps);
rs = ps.executeQuery();
while (rs.next()) {
DefaultEntityState entityState = readEntityState(uow, database.getEntityValue(rs).getReader());
if (!entityStatesVisitor.visit(entityState)) {
return;
}
}
} catch (SQLException ex) {
throw new EntityStoreException(ex);
} finally {
SQLUtil.closeQuietly(rs);
SQLUtil.closeQuietly(ps);
SQLUtil.closeQuietly(connection);
}
}
Aggregations