net.sf.jasperreports.engine.query
Class JRHibernateQueryExecuter

java.lang.Object
  extended by net.sf.jasperreports.engine.query.JRAbstractQueryExecuter
      extended by net.sf.jasperreports.engine.query.JRHibernateQueryExecuter
All Implemented Interfaces:
JRQueryExecuter

public class JRHibernateQueryExecuter
extends JRAbstractQueryExecuter

HQL query executer that uses Hibernate 3.

Version:
$Id: JRHibernateQueryExecuter.java 5180 2012-03-29 13:23:12Z teodord $
Author:
Lucian Chirita (lucianc@users.sourceforge.net)

Nested Class Summary
 
Nested classes/interfaces inherited from class net.sf.jasperreports.engine.query.JRAbstractQueryExecuter
JRAbstractQueryExecuter.QueryParameter
 
Field Summary
 
Fields inherited from class net.sf.jasperreports.engine.query.JRAbstractQueryExecuter
CLAUSE_POSITION_ID, clauseFunctions, dataset
 
Constructor Summary
JRHibernateQueryExecuter(JasperReportsContext jasperReportsContext, JRDataset dataset, java.util.Map<java.lang.String,? extends JRValueParameter> parameters)
           
JRHibernateQueryExecuter(JRDataset dataset, java.util.Map<java.lang.String,? extends JRValueParameter> parameters)
          Deprecated. Replaced by JRHibernateQueryExecuter(JasperReportsContext, JRDataset, Map).
 
Method Summary
 boolean cancelQuery()
          Cancels the query if it's currently running.
 void clearCache()
           
 void close()
          Closes the scrollable result when scroll execution type is used.
 void closeScrollableResults()
          Closes the scrollable results of the query.
 JRDataSource createDatasource()
          Creates an instance of JRHibernateListDataSource, JRHibernateIterateDataSource or JRHibernateScrollDataSource, depending on the
protected  void createQuery(java.lang.String queryString)
          Creates the Hibernate query object.
protected  JRDataSource createResultDatasource()
          Creates a data source out of the query result.
 JRDataset getDataset()
          Returns the dataset for which the query executer has been created.
protected  java.lang.String getHqlParameterName(java.lang.String parameterName)
           
protected  java.lang.String getParameterReplacement(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 calling org.hibernate.Query.iterate().
 java.util.List<?> list()
          Runs the query by calling org.hibernate.Query.list().
 java.util.List<?> list(int firstIndex, int resultCount)
          Returns a page of the query results by calling org.hibernate.Query.iterate().
 org.hibernate.ScrollableResults scroll()
          Runs the query by calling org.hibernate.Query.scroll().
protected  void setParameter(JRValueParameter parameter)
          Binds a parameter value to a query parameter.
protected  void setParameters()
          Binds values for all the query parameters.
protected  void setQueryRunning(boolean queryRunning)
           
 
Methods inherited from class net.sf.jasperreports.engine.query.JRAbstractQueryExecuter
addQueryMultiParameters, addQueryMultiParameters, addQueryParameter, appendClauseChunk, appendParameterChunk, appendParameterClauseChunk, appendQueryChunk, appendTextChunk, applyClause, checkParameter, getBooleanParameter, getBooleanParameterOrProperty, getCollectedParameterNames, getCollectedParameters, getJasperReportsContext, getParameter, getParameterValue, getParameterValue, getPropertiesUtil, getQueryString, getStringParameter, getStringParameterOrProperty, getValueParameter, getValueParameter, parameterHasValue, parseQuery, registerClauseFunction, resolveFunction, unregisterClauseFunction
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JRHibernateQueryExecuter

public JRHibernateQueryExecuter(JasperReportsContext jasperReportsContext,
                                JRDataset dataset,
                                java.util.Map<java.lang.String,? extends JRValueParameter> parameters)

JRHibernateQueryExecuter

public JRHibernateQueryExecuter(JRDataset dataset,
                                java.util.Map<java.lang.String,? extends JRValueParameter> parameters)
Deprecated. Replaced by JRHibernateQueryExecuter(JasperReportsContext, JRDataset, Map).

Method Detail

createDatasource

public JRDataSource createDatasource()
                              throws JRException
Creates an instance of JRHibernateListDataSource, JRHibernateIterateDataSource or JRHibernateScrollDataSource, depending on the

Returns:
a JRDataSource wrapping 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 the PARAMETER_HIBERNATE_FILTER_COLLECTION is 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 JRException
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

protected java.lang.String getParameterReplacement(java.lang.String parameterName)
Description copied from class: JRAbstractQueryExecuter
Returns the replacement text for a query parameter.

Specified by:
getParameterReplacement in class JRAbstractQueryExecuter
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 calling org.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 calling org.hibernate.Query.iterate().

Parameters:
firstIndex - the index of the first row to return
resultCount - the number of rows to return
Returns:
result row list

iterate

public java.util.Iterator<?> iterate()
Runs the query by calling org.hibernate.Query.iterate().

Returns:
query iterator

scroll

public org.hibernate.ScrollableResults scroll()
Runs the query by calling org.hibernate.Query.scroll().

Returns:
scrollable results of the query

clearCache

public void clearCache()


© 2001-2010 Jaspersoft Corporation www.jaspersoft.com