Package org.apache.juneau.beanquery.sql
Class SqlBeanQueryContext.Builder<T>
java.lang.Object
org.apache.juneau.commons.beanquery.BeanQueryContext.Builder<T,SqlBeanQueryContext.Builder<T>>
org.apache.juneau.beanquery.sql.SqlBeanQueryContext.Builder<T>
- Type Parameters:
T- The row type.
- Enclosing class:
- SqlBeanQueryContext<T>
public static final class SqlBeanQueryContext.Builder<T>
extends BeanQueryContext.Builder<T,SqlBeanQueryContext.Builder<T>>
Builder for
SqlBeanQueryContext. See the class Javadoc for an example.-
Method Summary
Modifier and TypeMethodDescriptionbuild()Builds the immutable context.Maps a declared column to a different raw SQL column name (otherwise the column name is used).connectionReleaser(Consumer<Connection> value) Sets how a session gives back a connection it got from the supplier.connectionSupplier(Supplier<Connection> value) Sets where sessions get a connection when none is passed toSqlBeanQuerySession.Builder.connection(Connection).dataSource(DataSource value) Shorthand forconnectionSupplier(ds::getConnection), with aSQLExceptionwrapped as aBeanQueryExecutionException.dialect(SqlDialect value) Sets the SQL dialect.fetchSize(int value) Sets the JDBC fetch size for every statement.guard(SqlFragment value) Sets a server-only SQL predicate AND-ed into every statement.queryTimeout(Duration value) Sets the JDBC query timeout for every statement, rounded up to whole seconds.rowMapper(SqlRowMapper<T> value) Sets the table (or view) to query.Methods inherited from class org.apache.juneau.commons.beanquery.BeanQueryContext.Builder
allowRegex, column, columnOperators, columns, countPolicy, declared, defaultLimit, exclude, maxExpressionDepth, maxLimit, maxSearchClauses, maxSearchLength, maxSortKeys, operators, regexTimeout, self
-
Method Details
-
dialect
Sets the SQL dialect. Required.- Parameters:
value- The dialect. Must not benull .- Returns:
- This object.
-
table
Sets the table (or view) to query. Required.- Parameters:
value- The raw table name; the dialect quotes it. Must not be blank.- Returns:
- This object.
-
rowMapper
Sets howfindandstreamturn a row into a bean, overriding the defaultbuild()would pick from the row type. Not needed forfindValues,streamValuesorcount.- Parameters:
value- The row mapper. Must not benull .- Returns:
- This object.
-
columnSql
Maps a declared column to a different raw SQL column name (otherwise the column name is used).- Parameters:
column- The column name. Must be declared.sqlName- The raw SQL column name; the dialect quotes it. Must not be blank.- Returns:
- This object.
-
guard
Sets a server-only SQL predicate AND-ed into every statement. A request can neither see nor remove it.- Parameters:
value- The guard, ornull for none.- Returns:
- This object.
-
connectionSupplier
Sets where sessions get a connection when none is passed toSqlBeanQuerySession.Builder.connection(Connection). This ordataSource(DataSource)is required.- Parameters:
value- The supplier. Must not benull . Exceptions it throws becomeBeanQueryExecutionExceptions.- Returns:
- This object.
-
connectionReleaser
Sets how a session gives back a connection it got from the supplier. Default:Connection.close().- Parameters:
value- The releaser. Must not benull .- Returns:
- This object.
-
dataSource
Shorthand forconnectionSupplier(ds::getConnection), with aSQLExceptionwrapped as aBeanQueryExecutionException.- Parameters:
value- The data source. Must not benull .- Returns:
- This object.
-
fetchSize
Sets the JDBC fetch size for every statement. Default: 500.- Parameters:
value- The fetch size. Must be positive.- Returns:
- This object.
-
queryTimeout
Sets the JDBC query timeout for every statement, rounded up to whole seconds. Default: none.Leave unset and this still bounds any statement whose search includes
$regex, at a shorter built-in default — set this explicitly to control that bound instead of accepting the default.- Parameters:
value- The timeout, ornull for none. Must be positive if set.- Returns:
- This object.
-
build
Builds the immutable context.- Specified by:
buildin classBeanQueryContext.Builder<T,SqlBeanQueryContext.Builder<T>> - Returns:
- A new context.
- Throws:
IllegalStateException- If the dialect, the table, the connection source or every column is missing.
-