Package net.sf.jasperreports.hibernate
Class JRHibernateQueryExecuter
java.lang.Object
net.sf.jasperreports.engine.query.JRAbstractQueryExecuter
net.sf.jasperreports.hibernate.JRHibernateQueryExecuter
- All Implemented Interfaces:
JRQueryExecuter
HQL query executer that uses Hibernate 3.
- Author:
- Lucian Chirita (lucianc@users.sourceforge.net)
-
Nested Class Summary
Nested classes/interfaces inherited from class net.sf.jasperreports.engine.query.JRAbstractQueryExecuter
JRAbstractQueryExecuter.QueryParameter, JRAbstractQueryExecuter.QueryParameterEntry, JRAbstractQueryExecuter.QueryParameterVisitor, JRAbstractQueryExecuter.ValuedQueryParameter, JRAbstractQueryExecuter.VisitExceptionWrapper
-
Field Summary
FieldsFields inherited from class net.sf.jasperreports.engine.query.JRAbstractQueryExecuter
clauseFunctions, dataset, EXCEPTION_MESSAGE_KEY_NUMERIC_TYPE_REQUIRED, EXCEPTION_MESSAGE_KEY_PARAMETER_NOT_FOUND, EXCEPTION_MESSAGE_KEY_QUERY_CLAUSE_CIRCULARLY_NESTED_PARAMETER, EXCEPTION_MESSAGE_KEY_QUERY_CLAUSE_ID_FIRST_TOKEN_MISSING, EXCEPTION_MESSAGE_KEY_QUERY_CLAUSE_NOT_FOUND, EXCEPTION_MESSAGE_KEY_UNSUPPORTED_PARAMETER_TYPE, GET_COLLECTED
-
Constructor Summary
ConstructorsConstructorDescriptionJRHibernateQueryExecuter
(JasperReportsContext jasperReportsContext, JRDataset dataset, Map<String, ? extends JRValueParameter> parameters) -
Method Summary
Modifier and TypeMethodDescriptionboolean
Cancels the query if it's currently running.void
void
close()
Closes the scrollable result when scroll execution type is used.protected void
void
Closes the scrollable results of the query.Creates an instance ofJRHibernateListDataSource
,JRHibernateIterateDataSource
orJRHibernateScrollDataSource
, depending on theprotected void
createQuery
(String queryString) Creates the Hibernate query object.protected JRDataSource
Creates a data source out of the query result.protected String
Returns a canonical query language for this query executer implementation.Returns the dataset for which the query executer has been created.protected String
getHqlParameterName
(String parameterName) protected String
getParameterReplacement
(String parameterName) Returns the replacement text for a query parameter.protected org.hibernate.Session
List
<jakarta.persistence.Tuple> list()
Runs the query by callingorg.hibernate.Query.list()
.List
<jakarta.persistence.Tuple> list
(int firstIndex, int resultCount) Returns a page of the query results by callingorg.hibernate.Query.iterate()
.org.hibernate.ScrollableResults
<jakarta.persistence.Tuple> scroll()
Runs the query by callingorg.hibernate.Query.scroll()
.protected void
setParameter
(JRValueParameter parameter) Binds a parameter value to a query parameter.protected void
Binds values for all the query parameters.protected void
setQueryRunning
(boolean queryRunning) Stream
<jakarta.persistence.Tuple> stream()
Runs the query by callingorg.hibernate.Query.iterate()
.Methods inherited from class net.sf.jasperreports.engine.query.JRAbstractQueryExecuter
addQueryMultiParameters, addQueryMultiParameters, addQueryParameter, addQueryParameter, appendClauseChunk, appendParameterChunk, appendParameterClauseChunk, appendQueryChunk, appendTextChunk, applyClause, checkParameter, findExtensionQueryFunction, getBooleanParameter, getBooleanParameter, getBooleanParameterOrProperty, getBooleanParameterOrProperty, getCollectedParameterNames, getCollectedParameters, getIntegerParameter, getIntegerParameter, getIntegerParameterOrProperty, getIntegerParameterOrProperty, getJasperReportsContext, getParameterValue, getParameterValue, getPropertiesUtil, getQueryExecutionContext, getQueryString, getRepositoryContext, getStringParameter, getStringParameterOrProperty, getValueParameter, getValueParameter, parameterHasValue, parseQuery, registerClauseFunction, resolveFunction, unregisterClauseFunction, visitQueryParameters
-
Field Details
-
EXCEPTION_MESSAGE_KEY_UNKNOWN_QUERY_RUN_TYPE
- See Also:
-
EXCEPTION_MESSAGE_KEY_UNRESOLVED_TYPE_CONSTANT
- See Also:
-
CANONICAL_LANGUAGE
- See Also:
-
-
Constructor Details
-
JRHibernateQueryExecuter
public JRHibernateQueryExecuter(JasperReportsContext jasperReportsContext, JRDataset dataset, Map<String, ? extends JRValueParameter> parameters)
-
-
Method Details
-
getCanonicalQueryLanguage
Description copied from class:JRAbstractQueryExecuter
Returns a canonical query language for this query executer implementation.The canonical language is used to retrieve extensions for the query executer.
The default implementation returns the runtime query language used in the dataset, but query executer implementations should override this method and return a fixed language.
- Overrides:
getCanonicalQueryLanguage
in classJRAbstractQueryExecuter
- Returns:
- a canonical query language
-
createDatasource
Creates an instance ofJRHibernateListDataSource
,JRHibernateIterateDataSource
orJRHibernateScrollDataSource
, depending on the- Returns:
- a
JRDataSource
wrapping the query execution result. - Throws:
JRException
-
createResultDatasource
Creates a data source out of the query result.- Returns:
- the data source
-
createQuery
Creates the Hibernate query object.- Parameters:
queryString
- the query string
-
setParameters
protected void setParameters()Binds values for all the query parameters. -
setParameter
Binds a parameter value to a query parameter.- Parameters:
parameter
- the report parameter
-
close
public void close()Closes the scrollable result when scroll execution type is used. -
closeScrollableResults
public void closeScrollableResults()Closes the scrollable results of the query. -
closeResultsStream
protected void closeResultsStream() -
cancelQuery
Description copied from interface:JRQueryExecuter
Cancels the query if it's currently running. This method will be called from a different thread if the client decides to cancel the filling process.- Returns:
true
if and only if the query was running and it has been canceled- Throws:
JRException
-
getParameterReplacement
Description copied from class:JRAbstractQueryExecuter
Returns the replacement text for a query parameter.- Specified by:
getParameterReplacement
in classJRAbstractQueryExecuter
- Parameters:
parameterName
- the parameter name- Returns:
- the replacement text
- See Also:
-
getHqlParameterName
-
getDataset
Returns the dataset for which the query executer has been created.- Returns:
- the dataset for which the query executer has been created
-
list
Runs the query by callingorg.hibernate.Query.list()
. All the result rows are returned.- Returns:
- the result of the query as a list
-
setQueryRunning
protected void setQueryRunning(boolean queryRunning) -
list
Returns a page of the query results by callingorg.hibernate.Query.iterate()
.- Parameters:
firstIndex
- the index of the first row to returnresultCount
- the number of rows to return- Returns:
- result row list
-
stream
Runs the query by callingorg.hibernate.Query.iterate()
.- Returns:
- query iterator
-
scroll
public org.hibernate.ScrollableResults<jakarta.persistence.Tuple> scroll()Runs the query by callingorg.hibernate.Query.scroll()
.- Returns:
- scrollable results of the query
-
getSession
protected org.hibernate.Session getSession() -
clearCache
public void clearCache()
-