KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > ojb > broker > query > Query


1 package org.apache.ojb.broker.query;
2
3 /* Copyright 2002-2005 The Apache Software Foundation
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */

17
18 import java.util.List JavaDoc;
19
20 /**
21  * represents Queries that can be used by the OJB PersistenceBroker
22  * to retrieve Objects from the underlying DB.
23  * Until now there are two implementations:
24  * 1. QueryByCriteria, represents SELECT * FROM ... WHERE ... queries
25  * 2. QueryByIdentity, uses Example objects or OIDs
26  * as templates for the db lookup
27  * there could additional implementations, e.g for user defined SQL
28  *
29  * For the Criteria API I reused code from the COBRA project,
30  * as you will see by their class comments.
31  *
32  * I removed all stuff that relies on knowlegde of the DataDictionary
33  * or MetaData layer. The Query and Criteria classes thus don't know
34  * how to build SQL statements, as in the COBRA original sources.
35  * I use the this classes as mere data-structures, that are
36  * processed by the OJB Accesslayer (SqlGenerator, JdbcAccess).
37  *
38  * This design will allow to reuse the org.apache.ojb.broker.query package in other
39  * projects without breaking any references. I hope this will be
40  * useful for someone.
41  *
42  * @author Thomas Mahler
43  * @version $Id: Query.java,v 1.17.2.3 2005/12/21 22:27:09 tomdz Exp $
44  */

45 public interface Query extends java.io.Serializable JavaDoc
46 {
47     static final long serialVersionUID = 7616997212439931319L;
48     
49     public static final int NO_START_AT_INDEX = 0;
50     public static final int NO_END_AT_INDEX = 0;
51     public static final boolean SCROLLABLE = true;
52     public static final boolean NOT_SCROLLABLE = false;
53
54     /**
55      * return the criteria of the query if present or null.
56      */

57     public abstract Criteria getCriteria();
58
59     /**
60      * return the criteria of the query if present or null.
61      */

62     public abstract Criteria getHavingCriteria();
63
64     /**
65      * return the template Object if present or null
66      */

67     public abstract Object JavaDoc getExampleObject();
68
69     /**
70      * return the target class, representing the extend to be searched
71      */

72     public abstract Class JavaDoc getSearchClass();
73
74     /**
75      * return the base class, with respect to which all paths are done
76      */

77     public abstract Class JavaDoc getBaseClass();
78
79     /**
80      * return true if select DISTINCT should be used
81      */

82     public boolean isDistinct();
83
84     /**
85      * Answer the orderBy of all Criteria and Sub Criteria the elements are of
86      * class FieldHelper
87      * @return List of FieldHelper
88      */

89     public List JavaDoc getOrderBy();
90
91     /**
92      * Gets the groupby for ReportQueries of all Criteria and Sub Criteria
93      * the elements are of class FieldHelper
94      * @return List of FieldHelper
95      */

96     public List JavaDoc getGroupBy();
97
98     /**
99      *
100      * @return the row at which the query should start retrieving results.
101      * If the start at index is 0, then ignore all cursor control.
102      */

103     int getStartAtIndex();
104
105     /**
106      * Set the row at which the query should start retrieving results, inclusive
107      * first row is 1
108      * @param startAtIndex starting index, inclusive.
109      */

110     void setStartAtIndex(int startAtIndex);
111
112     /**
113      *
114      * @return the row at which the query should stop retrieving results.
115      * If the end at index is 0, ignore all cursor control
116      */

117     int getEndAtIndex();
118
119     /**
120      * Set the row at which the query should stop retrieving results, inclusive.
121      * first row is 1
122      * @param endAtIndex ending index, inclusive
123      */

124     void setEndAtIndex(int endAtIndex);
125
126     /**
127      * Returns the names of Relationships to be prefetched
128      * @return List of Strings
129      */

130     public List JavaDoc getPrefetchedRelationships();
131
132     /**
133      * @deprecated
134      * @param size
135      */

136     void fullSize(int size);
137     /**
138      * @deprecated use OJBIterator.fullSize()
139      * @return
140      */

141     int fullSize();
142
143     void setWithExtents(boolean withExtents);
144     boolean getWithExtents();
145     
146     /**
147      * Answer true if start- and endIndex is set
148      * @return
149      */

150     public boolean usePaging();
151
152     /**
153      * Set fetchSize hint for this Query. Passed to the JDBC driver on the
154      * Statement level. It is JDBC driver-dependant if this function has
155      * any effect at all, since fetchSize is only a hint.
156      * @param fetchSize the fetch size specific to this query
157      */

158     void setFetchSize(int fetchSize);
159
160     /**
161      * Returns the fetchSize hint for this Query
162      * @return the fetch size hint specific to this query
163      * (or 0 if not set / using driver default)
164      */

165     int getFetchSize();
166
167 }
168
Popular Tags