| java.lang.Object net.sf.jasperreports.engine.query.JRAbstractQueryExecuter net.sf.jasperreports.engine.query.JRJpaQueryExecuter
JRJpaQueryExecuter | public class JRJpaQueryExecuter extends JRAbstractQueryExecuter (Code) | | EJBQL query executer that uses the Java Persistence API.
To use EJBQL in queries, an javax.persistence.EntityManager is needed.
When running or filling reports the em need to be supplied with the named parameter
net.sf.jasperreports.engine.query.JRJpaQueryExecuterFactory.PARAMETER_JPA_ENTITY_MANAGER .
Example:
Map parameters = new HashMap();
EntityManager em = emf.createEntityManager();
parameters.put(JRJpaQueryExecuterFactory.PARAMETER_JPA_ENTITY_MANAGER, em);
JasperRunManager.runReportToPdfFile(fileName, parameters);
When dealing with large result sets, pagination can be used by setting the
net.sf.jasperreports.engine.query.JRJpaQueryExecuterFactory.PROPERTY_JPA_QUERY_PAGE_SIZE property in the report template.
Example:
<property name="net.sf.jasperreports.ejbql.query.page.size" value="100"/>
Implementation-specific query hints can be set either using report properties in the report template,
or by supplying the named parameter
net.sf.jasperreports.engine.query.JRJpaQueryExecuterFactory.PARAMETER_JPA_QUERY_HINTS_MAP containing a java.util.Map with named/value query hints.
Example using report property:
<property name="net.sf.jasperreports.ejbql.query.hint.fetchSize" value="100"/>
The name of the query hint need to be prefixed with net.sf.jasperreports.ejbql.query.hint. (
net.sf.jasperreports.engine.query.JRJpaQueryExecuterFactory.PROPERTY_JPA_QUERY_HINT_PREFIX ).
Above example will set a query hint with the name fetchSize and the String value 100 .
Example using map:
Map hints = new HashMap();
hints.put("fetchSize", new Integer(100));
hints.put("anyName", anyObject());
Map parameters = new HashMap();
EntityManager em = emf.createEntityManager();
parameters.put(JRJpaQueryExecuterFactory.PARAMETER_JPA_ENTITY_MANAGER, em);
parameters.put(JRJpaQueryExecuterFactory.PARAMETER_JPA_QUERY_HINTS_MAP, hints);
JasperRunManager.runReportToPdfFile(fileName, parameters);
Note that when using report properties only String values can be set as query hint.
When using a query hints map, any Object can be set as value.
author: Marcel Overdijk (marceloverdijk@hotmail.com) version: $Id: JRJpaQueryExecuter.java 1472 2006-11-09 17:16:52Z lucianc $ See Also: net.sf.jasperreports.engine.query.JRJpaQueryExecuterFactory |
close | public synchronized void close()(Code) | | |
createQuery | protected synchronized void createQuery(String queryString)(Code) | | Creates the EJBQL query object.
Parameters: queryString - the query string |
createResultDatasource | protected JRDataSource createResultDatasource()(Code) | | Creates a data source out of the query result.
the data source |
getParameterReplacement | protected String getParameterReplacement(String parameterName)(Code) | | |
getResultList | public List getResultList()(Code) | | Runs the query by calling javax.persistence.Query.getResultList .
All the result rows are returned.
the result of the query as a list |
getResultList | public List getResultList(int firstIndex, int resultCount)(Code) | | Returns a page of the query results by calling javax.persistence.Query.getResultList .
Parameters: firstIndex - the index of the first row to return Parameters: resultCount - the number of rows to return result row list |
Methods inherited from net.sf.jasperreports.engine.query.JRAbstractQueryExecuter | protected void addQueryMultiParameters(String parameterName, int count)(Code)(Java Doc) protected void addQueryParameter(String parameterName)(Code)(Java Doc) protected void appendClauseChunk(StringBuffer sbuffer, String[] clauseTokens)(Code)(Java Doc) protected void appendParameterChunk(StringBuffer sbuffer, String chunkText)(Code)(Java Doc) protected void appendParameterClauseChunk(StringBuffer sbuffer, String chunkText)(Code)(Java Doc) protected void appendQueryChunk(StringBuffer sbuffer, JRQueryChunk chunk)(Code)(Java Doc) protected void appendTextChunk(StringBuffer sbuffer, String text)(Code)(Java Doc) protected void applyClause(JRClauseFunction function, JRClauseTokens tokens, StringBuffer sbuffer)(Code)(Java Doc) protected void checkParameter(String parameterName)(Code)(Java Doc) protected List getCollectedParameterNames()(Code)(Java Doc) protected List getCollectedParameters()(Code)(Java Doc) protected JRFillParameter getParameter(String parameterName)(Code)(Java Doc) abstract protected String getParameterReplacement(String parameterName)(Code)(Java Doc) protected Object getParameterValue(String parameterName, boolean ignoreMissing)(Code)(Java Doc) protected Object getParameterValue(String parameterName)(Code)(Java Doc) protected String getQueryString()(Code)(Java Doc) protected JRValueParameter getValueParameter(String parameterName, boolean ignoreMissing)(Code)(Java Doc) protected JRValueParameter getValueParameter(String parameterName)(Code)(Java Doc) protected void parseQuery()(Code)(Java Doc) protected void registerClauseFunction(String id, JRClauseFunction function)(Code)(Java Doc) protected JRClauseFunction resolveFunction(String id)(Code)(Java Doc) protected void unregisterClauseFunction(String id)(Code)(Java Doc)
|
|
|