Class JRHibernateQueryExecuter
- java.lang.Object
-
- net.sf.jasperreports.engine.query.JRAbstractQueryExecuter
-
- net.sf.jasperreports.engine.query.JRHibernateQueryExecuter
-
- All Implemented Interfaces:
JRQueryExecuter
public class JRHibernateQueryExecuter extends JRAbstractQueryExecuter
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
Fields Modifier and Type Field Description static java.lang.StringCANONICAL_LANGUAGEstatic java.lang.StringEXCEPTION_MESSAGE_KEY_UNKNOWN_QUERY_RUN_TYPEstatic java.lang.StringEXCEPTION_MESSAGE_KEY_UNRESOLVED_TYPE_CONSTANT-
Fields 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
Constructors Constructor Description JRHibernateQueryExecuter(JasperReportsContext jasperReportsContext, JRDataset dataset, java.util.Map<java.lang.String,? extends JRValueParameter> parameters)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancancelQuery()Cancels the query if it's currently running.voidclearCache()voidclose()Closes the scrollable result when scroll execution type is used.voidcloseScrollableResults()Closes the scrollable results of the query.JRDataSourcecreateDatasource()Creates an instance ofJRHibernateListDataSource,JRHibernateIterateDataSourceorJRHibernateScrollDataSource, depending on theprotected voidcreateQuery(java.lang.String queryString)Creates the Hibernate query object.protected JRDataSourcecreateResultDatasource()Creates a data source out of the query result.protected java.lang.StringgetCanonicalQueryLanguage()Returns a canonical query language for this query executer implementation.JRDatasetgetDataset()Returns the dataset for which the query executer has been created.protected java.lang.StringgetHqlParameterName(java.lang.String parameterName)protected java.lang.StringgetParameterReplacement(java.lang.String parameterName)Returns the replacement text for a query parameter.java.lang.String[]getReturnAliases()Returns the aliases of the HQL query.org.hibernate.type.Type[]getReturnTypes()Returns the return types of the HQL query.java.util.Iterator<?>iterate()Runs the query by callingorg.hibernate.Query.iterate().java.util.List<?>list()Runs the query by callingorg.hibernate.Query.list().java.util.List<?>list(int firstIndex, int resultCount)Returns a page of the query results by callingorg.hibernate.Query.iterate().org.hibernate.ScrollableResultsscroll()Runs the query by callingorg.hibernate.Query.scroll().protected voidsetParameter(JRValueParameter parameter)Binds a parameter value to a query parameter.protected voidsetParameters()Binds values for all the query parameters.protected voidsetQueryRunning(boolean queryRunning)-
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, getParameter, getParameterValue, getParameterValue, getPropertiesUtil, getQueryExecutionContext, getQueryString, getRepositoryContext, getStringParameter, getStringParameterOrProperty, getValueParameter, getValueParameter, parameterHasValue, parseQuery, registerClauseFunction, resolveFunction, unregisterClauseFunction, visitQueryParameters
-
-
-
-
Field Detail
-
EXCEPTION_MESSAGE_KEY_UNKNOWN_QUERY_RUN_TYPE
public static final java.lang.String EXCEPTION_MESSAGE_KEY_UNKNOWN_QUERY_RUN_TYPE
- See Also:
- Constant Field Values
-
EXCEPTION_MESSAGE_KEY_UNRESOLVED_TYPE_CONSTANT
public static final java.lang.String EXCEPTION_MESSAGE_KEY_UNRESOLVED_TYPE_CONSTANT
- See Also:
- Constant Field Values
-
CANONICAL_LANGUAGE
public static final java.lang.String CANONICAL_LANGUAGE
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
JRHibernateQueryExecuter
public JRHibernateQueryExecuter(JasperReportsContext jasperReportsContext, JRDataset dataset, java.util.Map<java.lang.String,? extends JRValueParameter> parameters)
-
-
Method Detail
-
getCanonicalQueryLanguage
protected java.lang.String getCanonicalQueryLanguage()
Description copied from class:JRAbstractQueryExecuterReturns 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:
getCanonicalQueryLanguagein classJRAbstractQueryExecuter- Returns:
- a canonical query language
-
createDatasource
public JRDataSource createDatasource() throws JRException
Creates an instance ofJRHibernateListDataSource,JRHibernateIterateDataSourceorJRHibernateScrollDataSource, depending on the- Returns:
- a
JRDataSourcewrapping the query execution result. - Throws:
JRException
-
createResultDatasource
protected JRDataSource createResultDatasource()
Creates a data source out of the query result.- Returns:
- the data source
-
createQuery
protected void createQuery(java.lang.String queryString)
Creates the Hibernate query object. If the value of thePARAMETER_HIBERNATE_FILTER_COLLECTIONis not null, then a filter query is created using the value of the parameter as the collection.- Parameters:
queryString- the query string
-
setParameters
protected void setParameters()
Binds values for all the query parameters.
-
setParameter
protected void setParameter(JRValueParameter parameter)
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.
-
cancelQuery
public boolean cancelQuery() throws JRExceptionDescription copied from interface:JRQueryExecuterCancels 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:
trueif and only if the query was running and it has been canceled- Throws:
JRException
-
getParameterReplacement
protected java.lang.String getParameterReplacement(java.lang.String parameterName)
Description copied from class:JRAbstractQueryExecuterReturns the replacement text for a query parameter.- Specified by:
getParameterReplacementin classJRAbstractQueryExecuter- Parameters:
parameterName- the parameter name- Returns:
- the replacement text
- See Also:
JRQueryChunk.TYPE_PARAMETER
-
getHqlParameterName
protected java.lang.String getHqlParameterName(java.lang.String parameterName)
-
getReturnTypes
public org.hibernate.type.Type[] getReturnTypes()
Returns the return types of the HQL query.- Returns:
- the return types of the HQL query
-
getReturnAliases
public java.lang.String[] getReturnAliases()
Returns the aliases of the HQL query.- Returns:
- the aliases of the HQL query
-
getDataset
public JRDataset getDataset()
Returns the dataset for which the query executer has been created.- Returns:
- the dataset for which the query executer has been created
-
list
public java.util.List<?> 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
public java.util.List<?> list(int firstIndex, int resultCount)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
-
iterate
public java.util.Iterator<?> iterate()
Runs the query by callingorg.hibernate.Query.iterate().- Returns:
- query iterator
-
scroll
public org.hibernate.ScrollableResults scroll()
Runs the query by callingorg.hibernate.Query.scroll().- Returns:
- scrollable results of the query
-
clearCache
public void clearCache()
-
-