KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectstyle > cayenne > query > GenericSelectQuery


1 /* ====================================================================
2  *
3  * The ObjectStyle Group Software License, version 1.1
4  * ObjectStyle Group - http://objectstyle.org/
5  *
6  * Copyright (c) 2002-2005, Andrei (Andrus) Adamchik and individual authors
7  * of the software. All rights reserved.
8  *
9  * Redistribution and use in source and binary forms, with or without
10  * modification, are permitted provided that the following conditions
11  * are met:
12  *
13  * 1. Redistributions of source code must retain the above copyright
14  * notice, this list of conditions and the following disclaimer.
15  *
16  * 2. Redistributions in binary form must reproduce the above copyright
17  * notice, this list of conditions and the following disclaimer in
18  * the documentation and/or other materials provided with the
19  * distribution.
20  *
21  * 3. The end-user documentation included with the redistribution, if any,
22  * must include the following acknowlegement:
23  * "This product includes software developed by independent contributors
24  * and hosted on ObjectStyle Group web site (http://objectstyle.org/)."
25  * Alternately, this acknowlegement may appear in the software itself,
26  * if and wherever such third-party acknowlegements normally appear.
27  *
28  * 4. The names "ObjectStyle Group" and "Cayenne" must not be used to endorse
29  * or promote products derived from this software without prior written
30  * permission. For written permission, email
31  * "andrus at objectstyle dot org".
32  *
33  * 5. Products derived from this software may not be called "ObjectStyle"
34  * or "Cayenne", nor may "ObjectStyle" or "Cayenne" appear in their
35  * names without prior written permission.
36  *
37  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
38  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
39  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
40  * DISCLAIMED. IN NO EVENT SHALL THE OBJECTSTYLE GROUP OR
41  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
42  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
43  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
44  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
45  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
46  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
47  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
48  * SUCH DAMAGE.
49  * ====================================================================
50  *
51  * This software consists of voluntary contributions made by many
52  * individuals and hosted on ObjectStyle Group web site. For more
53  * information on the ObjectStyle Group, please see
54  * <http://objectstyle.org/>.
55  */

56 package org.objectstyle.cayenne.query;
57
58 import java.util.Collection JavaDoc;
59
60 /**
61  * A query that returns result set. Concrete implementations can be object queries, raw
62  * sql queries, stored procedure queries, etc. The most commonly used GenericSelectQueries
63  * are {@link SelectQuery},{@link SQLTemplate}and {@link ProcedureQuery}.
64  *
65  * @author Andrei Adamchik
66  */

67 public interface GenericSelectQuery extends Query {
68
69     /**
70      * A cache policy that disables caching of query results.
71      *
72      * @since 1.1
73      */

74     public static final String JavaDoc NO_CACHE = "nocache";
75
76     /**
77      * A cache policy ruling that query results shall be cached separately for each
78      * DataContext.
79      *
80      * @since 1.1
81      */

82     public static final String JavaDoc LOCAL_CACHE = "localcache";
83
84     /**
85      * A cache policy ruling that query results shall be stored in a shared cache
86      * accessible by all DataContexts.
87      *
88      * @since 1.1
89      */

90     public static final String JavaDoc SHARED_CACHE = "sharedcache";
91
92     /**
93      * Defines the name of the property for the query {@link #getFetchLimit() fetch limit}.
94      *
95      * @since 1.1
96      */

97     public static final String JavaDoc FETCH_LIMIT_PROPERTY = "cayenne.GenericSelectQuery.fetchLimit";
98
99     /**
100      * Defines default query fetch limit, which is zero, meaning that all matching rows
101      * should be fetched.
102      *
103      * @since 1.1
104      */

105     public static final int FETCH_LIMIT_DEFAULT = 0;
106
107     /**
108      * Defines the name of the property for the query {@link #getPageSize() page size}.
109      *
110      * @since 1.1
111      */

112     public static final String JavaDoc PAGE_SIZE_PROPERTY = "cayenne.GenericSelectQuery.pageSize";
113
114     /**
115      * Defines default query page size, which is zero for no pagination.
116      *
117      * @since 1.1
118      */

119     public static final int PAGE_SIZE_DEFAULT = 0;
120
121     /**
122      * @since 1.1
123      */

124     public static final String JavaDoc FETCHING_DATA_ROWS_PROPERTY = "cayenne.GenericSelectQuery.fetchingDataRows";
125
126     /**
127      * @since 1.1
128      */

129     public static final boolean FETCHING_DATA_ROWS_DEFAULT = false;
130
131     /**
132      * @since 1.1
133      */

134     public static final String JavaDoc REFRESHING_OBJECTS_PROPERTY = "cayenne.GenericSelectQuery.refreshingObjects";
135
136     /**
137      * @since 1.1
138      */

139     public static final boolean REFRESHING_OBJECTS_DEFAULT = true;
140
141     /**
142      * @since 1.1
143      */

144     public static final String JavaDoc RESOLVING_INHERITED_PROPERTY = "cayenne.GenericSelectQuery.resolvingInherited";
145
146     /**
147      * @since 1.1
148      */

149     public static final boolean RESOLVING_INHERITED_DEFAULT = true;
150
151     /**
152      * @since 1.1
153      */

154     public static final String JavaDoc CACHE_POLICY_PROPERTY = "cayenne.GenericSelectQuery.cachePolicy";
155
156     /**
157      * @since 1.1
158      */

159     public static final String JavaDoc CACHE_POLICY_DEFAULT = NO_CACHE;
160
161     /**
162      * Returns query cache policy, which can be one of {@link #NO_CACHE},
163      * {@link #LOCAL_CACHE}, or {@link #SHARED_CACHE}. NO_CACHE is generally a default
164      * policy.
165      *
166      * @since 1.1
167      */

168     public String JavaDoc getCachePolicy();
169
170     /**
171      * Returns <code>true</code> if this query should produce a list of data rows as
172      * opposed to DataObjects, <code>false</code> for DataObjects. This is a hint to
173      * QueryEngine executing this query.
174      */

175     public boolean isFetchingDataRows();
176
177     /**
178      * Returns <code>true</code> if the query results should replace any currently
179      * cached values, returns <code>false</code> otherwise. If
180      * {@link #isFetchingDataRows()}returns <code>true</code>, this setting is not
181      * applicable and has no effect.
182      *
183      * @since 1.1
184      */

185     public boolean isRefreshingObjects();
186
187     /**
188      * Returns true if objects fetched via this query should be fully resolved according
189      * to the inheritance hierarchy.
190      *
191      * @since 1.1
192      */

193     public boolean isResolvingInherited();
194
195     /**
196      * Returns query page size. Page size is a hint to Cayenne that query should be
197      * performed page by page, instead of retrieveing all results at once. If the value
198      * returned is less than or equal to zero, no paging should occur.
199      */

200     public int getPageSize();
201
202     /**
203      * Returns the limit on the maximium number of records that can be returned by this
204      * query. If the actual number of rows in the result exceeds the fetch limit, they
205      * will be discarded. One possible use of fetch limit is using it as a safeguard
206      * against large result sets that may lead to the application running out of memory,
207      * etc. If a fetch limit is greater or equal to zero, all rows will be returned.
208      *
209      * @return the limit on the maximium number of records that can be returned by this
210      * query
211      */

212     public int getFetchLimit();
213     
214     /**
215      * Returns a collection of joint prefetches. Joint prefetches (unlike regular ones)
216      * are possible in all types of selecting queries.
217      *
218      * @since 1.2
219      */

220     public Collection JavaDoc getJointPrefetches();
221 }
Popular Tags