Class SqlDataLoader
java.lang.Object
io.jmix.reports.yarg.loaders.impl.AbstractDataLoader
io.jmix.reports.yarg.loaders.impl.AbstractDbDataLoader
io.jmix.reports.yarg.loaders.impl.SqlDataLoader
- All Implemented Interfaces:
ReportDataLoader,StreamingReportDataLoader
- Direct Known Subclasses:
JmixSqlDataLoader
Loads data from database using sql
You can use aliases for output values
Example:
select login as "Login", password as "Password" from user where create_ts > ${startDate}
${startDate} is alias of the input parameter, which will be passed to the query
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected classForward-only row iterator; output columns are captured from metadata once, at construction.Nested classes/interfaces inherited from class io.jmix.reports.yarg.loaders.impl.AbstractDbDataLoader
AbstractDbDataLoader.OutputValue, AbstractDbDataLoader.QueryPack, AbstractDbDataLoader.QueryParameter -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected intJDBC fetch size for the streaming cursor; PostgreSQL also requires autoCommit=false to stream.Fields inherited from class io.jmix.reports.yarg.loaders.impl.AbstractDbDataLoader
COMMON_PARAM_PATTERNFields inherited from class io.jmix.reports.yarg.loaders.impl.AbstractDataLoader
fieldsConverter, parametersConverter -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected List<AbstractDbDataLoader.OutputValue> buildOutputValues(ResultSetMetaData metaData, String query) Builds the output-value descriptors from the result-set metadata, capturing each column's case-sensitiveas <synonym>alias from the query.This method MUST return list of mutable maps.<T> TloadDataStreaming(ReportQuery reportQuery, @Nullable BandData parentBand, Map<String, Object> params, Function<Iterator<Map<String, Object>>, T> work) protected DataSourceresolveDataSource(ReportQuery reportQuery) The data source the streaming cursor connects to.protected intresolveStreamingFetchSize(Connection connection) MySQL Connector/J ignores positive fetch sizes and buffers the whole result set client-side;Integer.MIN_VALUEswitches it (and MariaDB Connector/J) to row streaming.protected ListrunQuery(ReportQuery reportQuery, String queryString, Object[] params, ResultSetHandler<List> handler) voidsetStreamingFetchSize(int streamingFetchSize) Methods inherited from class io.jmix.reports.yarg.loaders.impl.AbstractDbDataLoader
fillOutputData, fillOutputRow, findParameterNames, insertParameterToQuery, prepareQuery, processQueryTemplateMethods inherited from class io.jmix.reports.yarg.loaders.impl.AbstractDataLoader
addParentBandDataToParameters, convertOutputValue, convertParameter, getFieldsConverter, getParametersConverter, setFieldsConverter, setParametersConverter
-
Field Details
-
streamingFetchSize
protected int streamingFetchSizeJDBC fetch size for the streaming cursor; PostgreSQL also requires autoCommit=false to stream.
-
-
Constructor Details
-
SqlDataLoader
-
-
Method Details
-
setStreamingFetchSize
public void setStreamingFetchSize(int streamingFetchSize) -
loadData
public List<Map<String,Object>> loadData(ReportQuery reportQuery, @Nullable BandData parentBand, Map<String, Object> params) Description copied from interface:ReportDataLoaderThis method MUST return list of mutable maps. We need mutability to put there some values implicitly.- Specified by:
loadDatain interfaceReportDataLoader
-
runQuery
protected List runQuery(ReportQuery reportQuery, String queryString, Object[] params, ResultSetHandler<List> handler) throws SQLException - Throws:
SQLException
-
loadDataStreaming
public <T> T loadDataStreaming(ReportQuery reportQuery, @Nullable BandData parentBand, Map<String, Object> params, Function<Iterator<Map<String, Object>>, T> work) - Specified by:
loadDataStreamingin interfaceStreamingReportDataLoader
-
getDataSource
-
resolveDataSource
The data source the streaming cursor connects to. The default is the constructor-injected one; subclasses may route by the dataset's data store (mirrorsrunQueryoverrides). -
resolveStreamingFetchSize
MySQL Connector/J ignores positive fetch sizes and buffers the whole result set client-side;Integer.MIN_VALUEswitches it (and MariaDB Connector/J) to row streaming.- Throws:
SQLException
-
buildOutputValues
protected List<AbstractDbDataLoader.OutputValue> buildOutputValues(ResultSetMetaData metaData, String query) throws SQLException Builds the output-value descriptors from the result-set metadata, capturing each column's case-sensitiveas <synonym>alias from the query. Shared by the batch loader and the streaming cursor so the synonym semantics stay in one place.- Throws:
SQLException
-