KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > oracle > toplink > essentials > internal > parsing > ejbql > EJBQLCallQueryMechanism


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the "License"). You may not use this file except
5  * in compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * glassfish/bootstrap/legal/CDDLv1.0.txt or
9  * https://glassfish.dev.java.net/public/CDDLv1.0.html.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * HEADER in each file and include the License file at
15  * glassfish/bootstrap/legal/CDDLv1.0.txt. If applicable,
16  * add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your
18  * own identifying information: Portions Copyright [yyyy]
19  * [name of copyright owner]
20  */

21 // Copyright (c) 1998, 2006, Oracle. All rights reserved.
22
package oracle.toplink.essentials.internal.parsing.ejbql;
23
24 import oracle.toplink.essentials.internal.queryframework.*;
25 import oracle.toplink.essentials.exceptions.*;
26 import oracle.toplink.essentials.queryframework.*;
27 import oracle.toplink.essentials.internal.sessions.AbstractSession;
28
29 /**
30  * INTERNAL
31  * <p><b>Purpose</b>:
32  * Mechanism used for EJBQL.
33  * <p>
34  * <p><b>Responsibilities</b>:
35  * Executes the appropriate call.
36  *
37  * @author Jon Driscoll, Joel Lucuik
38  * @since TopLink 4.0
39  */

40 public class EJBQLCallQueryMechanism extends ExpressionQueryMechanism {
41     //EJBQLCall gets its own variable, rather than inheriting
42
//call (because an EJBQLCall is out on its own)
43
protected EJBQLCall ejbqlCall;
44
45     /**
46      * Initialize the state of the query
47      * @param query - owner of mechanism
48      */

49     public EJBQLCallQueryMechanism(DatabaseQuery query) {
50         super(query);
51     }
52
53     /**
54      * INTERNAL
55      * Initialize the state of the query
56      * @param query - owner of mechanism
57      * @param call - Database call
58      */

59     public EJBQLCallQueryMechanism(DatabaseQuery query, EJBQLCall call) {
60         this(query);
61         this.ejbqlCall = call;
62         call.setQuery(query);
63     }
64
65     public Object JavaDoc clone() {
66         EJBQLCallQueryMechanism copyOfMyself = (EJBQLCallQueryMechanism)super.clone();
67         copyOfMyself.ejbqlCall = (EJBQLCall)ejbqlCall.clone();
68         return copyOfMyself;
69
70     }
71
72     /**
73      * Internal:
74      * In the case of EJBQL, an expression needs to be generated, and the query populated.
75      */

76     public void buildSelectionCriteria(AbstractSession newSession) {
77         getEJBQLCall().setQuery(getQuery());
78         getEJBQLCall().populateQuery(newSession);
79     }
80
81     public EJBQLCall getEJBQLCall() {
82         return ejbqlCall;
83     }
84
85     public boolean isEJBQLCallQueryMechanism() {
86         return true;
87     }
88
89     /**
90      * All the query mechanism related things are initialized here.
91      * This method is called on the *clone* of the query with
92      * every execution.
93      */

94     public void prepareForExecution() throws QueryException {
95     }
96
97     public void setEJBQLCall(EJBQLCall newEJBQLCall) {
98         ejbqlCall = newEJBQLCall;
99     }
100 }
101
Popular Tags