Package io.jmix.reports.libintegration
Class JpqlDataLoader
java.lang.Object
io.jmix.reports.yarg.loaders.impl.AbstractDataLoader
io.jmix.reports.yarg.loaders.impl.AbstractDbDataLoader
io.jmix.reports.libintegration.JpqlDataLoader
- All Implemented Interfaces:
ReportDataLoader,StreamingReportDataLoader
@NullMarked
public class JpqlDataLoader
extends AbstractDbDataLoader
implements ReportDataLoader, StreamingReportDataLoader
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected classLazy iterator over an EclipseLink CursoredStream; wraps entities into EntityMap, scalars via OutputValue.protected static final recordNested classes/interfaces inherited from class io.jmix.reports.yarg.loaders.impl.AbstractDbDataLoader
AbstractDbDataLoader.OutputValue, AbstractDbDataLoader.QueryPack, AbstractDbDataLoader.QueryParameter -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected org.springframework.beans.factory.BeanFactoryprotected intRelease EclipseLink's internal row references every N rows.protected DataManagerprotected ReportsGroovyFeatureSupportprotected StoreAwareLocatorprotected intJDBC fetch size for the streaming cursor.Cached JDBC streaming fetch size per data store — the database product does not change at runtime.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 voidcloseCursorQuietly(org.eclipse.persistence.queries.CursoredStream cursor, String dataSetName) Closes the EclipseLink cursor without letting a close failure escape: on a broken connection close() can throw, and in afinallythat would replace the in-flight exception (masking a user cancel or formatter error and stripping the ReportingException type runReport routes on).protected @Nullable IntegerdetectStreamingFetchSize(String storeName) MySQL Connector/J ignores a positive fetch size and buffers the whole result set client-side;Integer.MIN_VALUEswitches it (and MariaDB Connector/J) to row streaming.protected @Nullable Listprotected jakarta.persistence.Queryprotected StringinsertParameterToQuery(String query, AbstractDbDataLoader.QueryParameter parameter) 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) Streams rows from an EclipseLink cursor.protected List<AbstractDbDataLoader.OutputValue> protected JpqlDataLoader.PreparedJpqlQueryprepareJpqlQuery(String query, @Nullable BandData parentBand, Map<String, Object> params, boolean processTemplate) Stripsas "alias"entries from the JPQL text, capturing them as output value names.protected Stringprotected Stringprotected intresolveStreamingFetchSize(String storeName) Cached per store (the database product is stable, so the metadata connection runs once per store).voidsetCursorClearInterval(int cursorClearInterval) voidsetStreamingFetchSize(int streamingFetchSize) protected StringMethods inherited from class io.jmix.reports.yarg.loaders.impl.AbstractDbDataLoader
fillOutputData, fillOutputRow, findParameterNames, prepareQueryMethods inherited from class io.jmix.reports.yarg.loaders.impl.AbstractDataLoader
addParentBandDataToParameters, convertOutputValue, convertParameter, getFieldsConverter, getParametersConverter, setFieldsConverter, setParametersConverter
-
Field Details
-
streamingFetchSizeByStore
Cached JDBC streaming fetch size per data store — the database product does not change at runtime. -
beanFactory
@Autowired protected org.springframework.beans.factory.BeanFactory beanFactory -
dataManager
-
storeAwareLocator
-
groovyFeatureSupport
-
streamingFetchSize
protected int streamingFetchSizeJDBC fetch size for the streaming cursor. -
cursorClearInterval
protected int cursorClearIntervalRelease EclipseLink's internal row references every N rows.
-
-
Constructor Details
-
JpqlDataLoader
public JpqlDataLoader()
-
-
Method Details
-
setStreamingFetchSize
public void setStreamingFetchSize(int streamingFetchSize) -
setCursorClearInterval
public void setCursorClearInterval(int cursorClearInterval) -
parseQueryOutputParametersNames
-
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
-
prepareJpqlQuery
protected JpqlDataLoader.PreparedJpqlQuery prepareJpqlQuery(String query, @Nullable BandData parentBand, Map<String, Object> params, boolean processTemplate) Stripsas "alias"entries from the JPQL text, capturing them as output value names. -
loadDataStreaming
public <T> T loadDataStreaming(ReportQuery reportQuery, @Nullable BandData parentBand, Map<String, Object> params, Function<Iterator<Map<String, Object>>, T> work) Streams rows from an EclipseLink cursor. The whole callback runs inside the store's transaction, keeping the cursor and lazyEntityMapattribute access valid for the entire render.- Specified by:
loadDataStreamingin interfaceStreamingReportDataLoader
-
resolveStreamingFetchSize
Cached per store (the database product is stable, so the metadata connection runs once per store). A transient detection failure is NOT cached: it falls back to the default for this call but lets the next report retry, so a one-off failure (e.g. a pool spike) does not pin MySQL to a buffering fetch size forever. -
detectStreamingFetchSize
MySQL Connector/J ignores a positive fetch size and buffers the whole result set client-side;Integer.MIN_VALUEswitches it (and MariaDB Connector/J) to row streaming. The EclipseLink cursor consumes rows forward-only, so the driver's row-streaming mode fits it. MirrorsSqlDataLoader#resolveStreamingFetchSize. Returnsnullon a transient failure so the caller can fall back without caching. -
closeCursorQuietly
protected void closeCursorQuietly(org.eclipse.persistence.queries.CursoredStream cursor, String dataSetName) Closes the EclipseLink cursor without letting a close failure escape: on a broken connection close() can throw, and in afinallythat would replace the in-flight exception (masking a user cancel or formatter error and stripping the ReportingException type runReport routes on). Mirrors the SqlDataLoader teardown, which guards rollback/setAutoCommit the same way. -
executeQuery
-
insertParameters
-
insertParameterToQuery
protected String insertParameterToQuery(String query, AbstractDbDataLoader.QueryParameter parameter) - Overrides:
insertParameterToQueryin classAbstractDbDataLoader
-
resolveNamedParameterName
-
processQueryTemplate
protected String processQueryTemplate(String query, @Nullable BandData parentBand, Map<String, Object> reportParams) - Overrides:
processQueryTemplatein classAbstractDbDataLoader
-
trimQuery
-