public abstract class BaseSQLQuery extends Object
Modifier and Type | Field and Description |
---|---|
protected static Databases |
dbs |
protected List<String> |
fieldNames |
Constructor and Description |
---|
BaseSQLQuery() |
Modifier and Type | Method and Description |
---|---|
Optional<Row> |
first()
Executes the given query returning the first matching row wrapped as
Optional . |
abstract void |
iterate(Function<Row,Boolean> handler,
sirius.kernel.commons.Limit limit)
Executes the given query by invoking the given handler for each result row.
|
void |
iterateAll(Consumer<Row> consumer,
sirius.kernel.commons.Limit limit)
Executes the given query by invoking the
Consumer for each
result row. |
protected Row |
loadIntoRow(ResultSet rs) |
protected void |
processResultSet(Function<Row,Boolean> handler,
sirius.kernel.commons.Limit effectiveLimit,
ResultSet resultSet,
sirius.kernel.async.TaskContext taskContext) |
Row |
queryFirst()
Executes the given query returning the first matching row.
|
List<Row> |
queryList()
Executes the given query returning the result as list
|
List<Row> |
queryList(sirius.kernel.commons.Limit limit)
Executes the given query returning the result as list with at most maxRows entries
|
protected abstract void |
writeBlobToParameter(String name,
Blob blob) |
@Nonnull public List<Row> queryList() throws SQLException
Row
sSQLException
- in case of a database error@Nonnull public List<Row> queryList(sirius.kernel.commons.Limit limit) throws SQLException
limit
- the limit which controls which and how many rows are outputRow
sSQLException
- in case of a database errorpublic abstract void iterate(Function<Row,Boolean> handler, @Nullable sirius.kernel.commons.Limit limit) throws SQLException
Consider using the method instead of queryList()
if a large result set is expected as this method. As
this method only processes one row at a time, this might be much more memory efficient.
handler
- the row handler invoked for each rowlimit
- the limit which controls which and how many rows are output. Can be null to indicate
that there is no limit.SQLException
- in case of a database errorpublic void iterateAll(Consumer<Row> consumer, @Nullable sirius.kernel.commons.Limit limit) throws SQLException
Consumer
for each
result row.consumer
- the row handler invoked for each rowlimit
- the limit which controls which and how many rows are output. Can be null to indicate
that there is no limit.SQLException
- in case of a database errorprotected void processResultSet(Function<Row,Boolean> handler, sirius.kernel.commons.Limit effectiveLimit, ResultSet resultSet, sirius.kernel.async.TaskContext taskContext) throws SQLException
SQLException
@Nonnull public Optional<Row> first() throws SQLException
Optional
.
This method behaves like queryFirst()
but returns an optional value instead of null.
SQLException
- in case of a database error@Nullable public Row queryFirst() throws SQLException
If the resulting row contains a Blob
an OutputStream
as to be passed in as parameter
with the name name as the column. The contents of the blob will then be written into the given
output stream (without closing it).
SQLException
- in case of a database errorprotected Row loadIntoRow(ResultSet rs) throws SQLException
SQLException
protected abstract void writeBlobToParameter(String name, Blob blob) throws SQLException
SQLException
Copyright © 2018. All rights reserved.