KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sf > jasperreports > engine > query > JRJpaQueryExecuterFactory


1 /*
2  * ============================================================================
3  * GNU Lesser General Public License
4  * ============================================================================
5  *
6  * JasperReports - Free Java report-generating library.
7  * Copyright (C) 2001-2005 JasperSoft Corporation http://www.jaspersoft.com
8  *
9  * This library is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public
11  * License as published by the Free Software Foundation; either
12  * version 2.1 of the License, or (at your option) any later version.
13  *
14  * This library is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17  * Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public
20  * License along with this library; if not, write to the Free Software
21  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
22  *
23  * JasperSoft Corporation
24  * 303 Second Street, Suite 450 North
25  * San Francisco, CA 94107
26  * http://www.jaspersoft.com
27  */

28 package net.sf.jasperreports.engine.query;
29
30 import java.util.Map JavaDoc;
31
32 import javax.persistence.EntityManager;
33
34 import net.sf.jasperreports.engine.JRDataset;
35 import net.sf.jasperreports.engine.JRException;
36 import net.sf.jasperreports.engine.util.JRProperties;
37
38 /**
39  * Java Persistence API query executer factory for EJBQL queries.
40  * <p/>
41  * The factory creates {@link net.sf.jasperreports.engine.query.JRJpaQueryExecuter JRJpaQueryExecuter}
42  * query executers.
43  *
44  * @author Marcel Overdijk (marceloverdijk@hotmail.com)
45  * @version $Id: JRJpaQueryExecuterFactory.java 1251 2006-05-08 14:15:01 +0300 (Mon, 08 May 2006) lucianc $
46  */

47 public class JRJpaQueryExecuterFactory implements JRQueryExecuterFactory {
48
49     /**
50      * EJBQL query language.
51      */

52     public static final String JavaDoc QUERY_LANGUAGE_EJBQL = "ejbql";
53
54     /**
55      * Built-in parameter holding the value of the <code>javax.persistence.EntityManager</code> to be used for creating the query.
56      */

57     public static final String JavaDoc PARAMETER_JPA_ENTITY_MANAGER = "JPA_ENTITY_MANAGER";
58
59     /**
60      * Built-in parameter (optional) holding the value of the query hints map.
61      * Each named/value pair will be set as query hint against the query.
62      */

63     public static final String JavaDoc PARAMETER_JPA_QUERY_HINTS_MAP = "JPA_QUERY_HINTS_MAP";
64     
65     
66     private static final Object JavaDoc[] JPA_BUILTIN_PARAMETERS = {
67         PARAMETER_JPA_ENTITY_MANAGER, EntityManager.class,
68         PARAMETER_JPA_QUERY_HINTS_MAP, Map JavaDoc.class
69     };
70     
71     public Object JavaDoc[] getBuiltinParameters() {
72         return JPA_BUILTIN_PARAMETERS;
73     }
74
75     /**
76      * Property specifying the number of result rows to be retrieved at once.
77      * <p/>
78      * Result pagination is implemented by <code>javax.persistence.Query.setFirstResult()</code> and <code>javax.persistence.Query.setMaxResults()</code>.
79      * <p/>
80      * By default, all the rows are retrieved (no result pagination is performed).
81      */

82     public static final String JavaDoc PROPERTY_JPA_QUERY_PAGE_SIZE = JRProperties.PROPERTY_PREFIX + "ejbql.query.page.size";
83
84     /**
85      * Property specifying the prefix for EJBQL query hints.
86      */

87     public static final String JavaDoc PROPERTY_JPA_QUERY_HINT_PREFIX = JRProperties.PROPERTY_PREFIX + "ejbql.query.hint.";
88     
89     public JRQueryExecuter createQueryExecuter(JRDataset dataset, Map JavaDoc parameters) throws JRException {
90         return new JRJpaQueryExecuter(dataset, parameters);
91     }
92
93     /**
94      * Returns <code>true</code> for all parameter types.
95      */

96     public boolean supportsQueryParameterType(String JavaDoc className) {
97         return true;
98     }
99 }
100
Popular Tags