use of jakarta.nosql.NonUniqueResultException in project jnosql-diana by eclipse.
the class DefaultDocumentPreparedStatement method getSingleResult.
@Override
public Optional<DocumentEntity> getSingleResult() {
Stream<DocumentEntity> entities = getResult();
final Iterator<DocumentEntity> iterator = entities.iterator();
if (!iterator.hasNext()) {
return Optional.empty();
}
final DocumentEntity next = iterator.next();
if (!iterator.hasNext()) {
return Optional.of(next);
}
throw new NonUniqueResultException("The select returns more than one entity, select: " + query);
}
use of jakarta.nosql.NonUniqueResultException in project jnosql-diana by eclipse.
the class DefaultKeyValuePreparedStatement method getSingleResult.
@Override
public Optional<Value> getSingleResult() {
Stream<Value> entities = getResult();
final Iterator<Value> iterator = entities.iterator();
if (!iterator.hasNext()) {
return Optional.empty();
}
final Value next = iterator.next();
if (!iterator.hasNext()) {
return Optional.of(next);
}
throw new NonUniqueResultException("The select returns more than one entity, select: " + query);
}
use of jakarta.nosql.NonUniqueResultException in project jnosql-diana by eclipse.
the class DefaultColumnPreparedStatement method getSingleResult.
@Override
public Optional<ColumnEntity> getSingleResult() {
Stream<ColumnEntity> entities = getResult();
final Iterator<ColumnEntity> iterator = entities.iterator();
if (!iterator.hasNext()) {
return Optional.empty();
}
final ColumnEntity next = iterator.next();
if (!iterator.hasNext()) {
return Optional.of(next);
}
throw new NonUniqueResultException("The select returns more than one entity, select: " + query);
}
use of jakarta.nosql.NonUniqueResultException in project jnosql-diana by eclipse.
the class DefaultVertexTraversal method getSingleResult.
@Override
public <T> Optional<T> getSingleResult() {
final Stream<T> stream = getResult();
final Iterator<T> iterator = stream.iterator();
if (!iterator.hasNext()) {
return Optional.empty();
}
final T entity = iterator.next();
if (!iterator.hasNext()) {
return Optional.of(entity);
}
throw new NonUniqueResultException("The Vertex traversal query returns more than one result");
}
Aggregations