KickJava   Java API By Example, From Geeks To Geeks.

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


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.ArrayList JavaDoc;
59 import java.util.Collection JavaDoc;
60 import java.util.Collections JavaDoc;
61 import java.util.HashSet JavaDoc;
62 import java.util.Iterator JavaDoc;
63 import java.util.List JavaDoc;
64 import java.util.Map JavaDoc;
65 import java.util.Set JavaDoc;
66
67 import org.objectstyle.cayenne.exp.Expression;
68 import org.objectstyle.cayenne.map.DbAttribute;
69 import org.objectstyle.cayenne.map.DbEntity;
70 import org.objectstyle.cayenne.map.EntityResolver;
71 import org.objectstyle.cayenne.map.ObjEntity;
72 import org.objectstyle.cayenne.map.Procedure;
73 import org.objectstyle.cayenne.map.QueryBuilder;
74 import org.objectstyle.cayenne.util.XMLEncoder;
75 import org.objectstyle.cayenne.util.XMLSerializable;
76
77 /**
78  * SelectQuery is a Query object describing what rows to retrieve from the database and
79  * how to convert them to objects. SelectQuery is defined in terms of object mapping.
80  * During execution Cayenne translates it to SQL PreparedStatements using a SQL dialect of
81  * the target database. SelectQuery defines a set of parameters for the fetch. Most
82  * important parameters are the "root", "qualifier", and "ordering".
83  *
84  * @author Andrei Adamchik
85  */

86 public class SelectQuery extends QualifiedQuery implements GenericSelectQuery,
87         ParameterizedQuery, XMLSerializable {
88
89     public static final String JavaDoc DISTINCT_PROPERTY = "cayenne.SelectQuery.distinct";
90     public static final boolean DISTINCT_DEFAULT = false;
91
92     protected List JavaDoc customDbAttributes;
93     protected List JavaDoc orderings;
94     protected Set JavaDoc prefetches;
95     protected boolean distinct;
96
97     protected Expression parentQualifier;
98     protected String JavaDoc parentObjEntityName;
99     protected SelectExecutionProperties selectProperties = new SelectExecutionProperties();
100
101     /** Creates an empty SelectQuery. */
102     public SelectQuery() {
103     }
104
105     /**
106      * Creates a SelectQuery with null qualifier, for the specifed ObjEntity
107      *
108      * @param root the ObjEntity this SelectQuery is for.
109      */

110     public SelectQuery(ObjEntity root) {
111         this(root, null);
112     }
113
114     /**
115      * Creates a SelectQuery for the specifed ObjEntity with the given qualifier
116      *
117      * @param root the ObjEntity this SelectQuery is for.
118      * @param qualifier an Expression indicating which objects should be fetched
119      */

120     public SelectQuery(ObjEntity root, Expression qualifier) {
121         this();
122         this.init(root, qualifier);
123     }
124
125     /**
126      * Creates a SelectQuery that selects all objects of a given persistent class.
127      *
128      * @param rootClass the Class of objects fetched by this query.
129      */

130     public SelectQuery(Class JavaDoc rootClass) {
131         this(rootClass, null);
132     }
133
134     /**
135      * Creates a SelectQuery that selects objects of a given persistent class that match
136      * supplied qualifier.
137      *
138      * @param rootClass the Class of objects fetched by this query.
139      */

140     public SelectQuery(Class JavaDoc rootClass, Expression qualifier) {
141         init(rootClass, qualifier);
142     }
143
144     /**
145      * Creates a SelectQuery for the specifed DbEntity.
146      *
147      * @param root the DbEntity this SelectQuery is for.
148      * @since 1.1
149      */

150     public SelectQuery(DbEntity root) {
151         this(root, null);
152     }
153
154     /**
155      * Creates a SelectQuery for the specifed DbEntity with the given qualifier.
156      *
157      * @param root the DbEntity this SelectQuery is for.
158      * @param qualifier an Expression indicating which objects should be fetched
159      * @since 1.1
160      */

161     public SelectQuery(DbEntity root, Expression qualifier) {
162         this();
163         this.init(root, qualifier);
164     }
165
166     /**
167      * Creates SelectQuery with <code>objEntityName</code> parameter.
168      */

169     public SelectQuery(String JavaDoc objEntityName) {
170         this(objEntityName, null);
171     }
172
173     /**
174      * Creates SelectQuery with <code>objEntityName</code> and <code>qualifier</code>
175      * parameters.
176      */

177     public SelectQuery(String JavaDoc objEntityName, Expression qualifier) {
178         init(objEntityName, qualifier);
179     }
180
181     private void init(Object JavaDoc root, Expression qualifier) {
182         this.setRoot(root);
183         this.setQualifier(qualifier);
184     }
185
186     /**
187      * Routes itself and if there are any prefetches configured, creates prefetch queries
188      * and routes them as well.
189      *
190      * @since 1.2
191      */

192     public void route(QueryRouter router, EntityResolver resolver) {
193
194         // route self
195
super.route(router, resolver);
196
197         // create and route prefetch queries if any
198
if (!isFetchingDataRows()) {
199
200             Iterator JavaDoc prefetchIt = getPrefetches().iterator();
201             while (prefetchIt.hasNext()) {
202                 String JavaDoc prefetchKey = (String JavaDoc) prefetchIt.next();
203
204                 // TODO: with routing API, PrefetchSelectQuery no longer needs
205
// EntityResolver to be passed in constructor, as it is passed during
206
// routing.
207
// should refactor PrefetchSelectQuery
208
PrefetchSelectQuery prefetchQuery = new PrefetchSelectQuery(
209                         resolver,
210                         this,
211                         prefetchKey);
212                 prefetchQuery.route(router, resolver);
213             }
214         }
215     }
216
217     /**
218      * Calls "makeSelect" on the visitor.
219      *
220      * @since 1.2
221      */

222     public SQLAction createSQLAction(SQLActionVisitor visitor) {
223         return visitor.objectSelectAction(this);
224     }
225
226     /**
227      * Initializes query parameters using a set of properties.
228      *
229      * @since 1.1
230      */

231     public void initWithProperties(Map JavaDoc properties) {
232
233         // must init defaults even if properties are empty
234
if (properties == null) {
235             properties = Collections.EMPTY_MAP;
236         }
237
238         Object JavaDoc distinct = properties.get(DISTINCT_PROPERTY);
239
240         // init ivars from properties
241
this.distinct = (distinct != null)
242                 ? "true".equalsIgnoreCase(distinct.toString())
243                 : DISTINCT_DEFAULT;
244
245         selectProperties.initWithProperties(properties);
246     }
247
248     /**
249      * Prints itself as XML to the provided PrintWriter.
250      *
251      * @since 1.1
252      */

253     public void encodeAsXML(XMLEncoder encoder) {
254         encoder.print("<query name=\"");
255         encoder.print(getName());
256         encoder.print("\" factory=\"");
257         encoder.print("org.objectstyle.cayenne.map.SelectQueryBuilder");
258
259         String JavaDoc rootString = null;
260         String JavaDoc rootType = null;
261
262         if (root instanceof String JavaDoc) {
263             rootType = QueryBuilder.OBJ_ENTITY_ROOT;
264             rootString = root.toString();
265         }
266         else if (root instanceof ObjEntity) {
267             rootType = QueryBuilder.OBJ_ENTITY_ROOT;
268             rootString = ((ObjEntity) root).getName();
269         }
270         else if (root instanceof DbEntity) {
271             rootType = QueryBuilder.DB_ENTITY_ROOT;
272             rootString = ((DbEntity) root).getName();
273         }
274         else if (root instanceof Procedure) {
275             rootType = QueryBuilder.PROCEDURE_ROOT;
276             rootString = ((Procedure) root).getName();
277         }
278         else if (root instanceof Class JavaDoc) {
279             rootType = QueryBuilder.JAVA_CLASS_ROOT;
280             rootString = ((Class JavaDoc) root).getName();
281         }
282
283         if (rootType != null) {
284             encoder.print("\" root=\"");
285             encoder.print(rootType);
286             encoder.print("\" root-name=\"");
287             encoder.print(rootString);
288         }
289
290         encoder.println("\">");
291
292         encoder.indent(1);
293
294         // print properties
295
if (distinct != DISTINCT_DEFAULT) {
296             encoder.printProperty(DISTINCT_PROPERTY, distinct);
297         }
298
299         selectProperties.encodeAsXML(encoder);
300
301         // encode qualifier
302
if (qualifier != null) {
303             encoder.print("<qualifier>");
304             qualifier.encodeAsXML(encoder);
305             encoder.println("</qualifier>");
306         }
307
308         // encode orderings
309
if (orderings != null && !orderings.isEmpty()) {
310             Iterator JavaDoc it = orderings.iterator();
311             while (it.hasNext()) {
312                 Ordering ordering = (Ordering) it.next();
313                 ordering.encodeAsXML(encoder);
314             }
315         }
316
317         // encode prefetches
318
if (prefetches != null && !prefetches.isEmpty()) {
319             Iterator JavaDoc it = prefetches.iterator();
320             while (it.hasNext()) {
321                 String JavaDoc prefetch = (String JavaDoc) it.next();
322
323                 // currently prefetch is a String, but DTD
324
// treats it as a path expression... I guess for now
325
// it will be an overkill to wrap it in "<![CDATA[.."
326
encoder.print("<prefetch>");
327                 encoder.print(prefetch);
328                 encoder.println("</prefetch>");
329             }
330         }
331
332         // TODO: encode join prefetches...
333

334         encoder.indent(-1);
335         encoder.println("</query>");
336     }
337
338     /**
339      * A shortcut for {@link #queryWithParameters(Map, boolean)}that prunes parts of
340      * qualifier that have no parameter value set.
341      */

342     public SelectQuery queryWithParameters(Map JavaDoc parameters) {
343         return queryWithParameters(parameters, true);
344     }
345
346     /**
347      * Returns a query built using this query as a prototype, using a set of parameters to
348      * build the qualifier.
349      *
350      * @see org.objectstyle.cayenne.exp.Expression#expWithParameters(java.util.Map,
351      * boolean) parameter substitution.
352      */

353     public SelectQuery queryWithParameters(Map JavaDoc parameters, boolean pruneMissing) {
354         // create a query replica
355
SelectQuery query = new SelectQuery();
356         query.setDistinct(distinct);
357
358         this.selectProperties.copyToProperties(query.selectProperties);
359
360         query.setLoggingLevel(logLevel);
361         query.setParentObjEntityName(parentObjEntityName);
362         query.setParentQualifier(parentQualifier);
363         query.setRoot(root);
364
365         if (prefetches != null) {
366             query.addPrefetches(prefetches);
367         }
368
369         if (orderings != null) {
370             query.addOrderings(orderings);
371         }
372
373         if (customDbAttributes != null) {
374             query.addCustomDbAttributes(customDbAttributes);
375         }
376
377         // substitute qualifier parameters
378
if (qualifier != null) {
379             query.setQualifier(qualifier.expWithParameters(parameters, pruneMissing));
380         }
381
382         // TODO: implement algorithm for building the name based on the original name and
383
// the hashcode of the map of parameters. This way query clone can take advantage
384
// of caching.
385

386         return query;
387     }
388
389     /**
390      * Creates and returns a new SelectQuery built using this query as a prototype and
391      * substituting qualifier parameters with the values from the map.
392      *
393      * @since 1.1
394      */

395     public Query createQuery(Map JavaDoc parameters) {
396         return queryWithParameters(parameters);
397     }
398
399     /**
400      * Adds ordering specification to this query orderings.
401      */

402     public void addOrdering(Ordering ordering) {
403         nonNullOrderings().add(ordering);
404     }
405
406     /**
407      * Adds a list of orderings.
408      */

409     public void addOrderings(List JavaDoc orderings) {
410         nonNullOrderings().addAll(orderings);
411     }
412
413     /** Adds ordering specification to this query orderings. */
414     public void addOrdering(String JavaDoc sortPathSpec, boolean isAscending) {
415         this.addOrdering(new Ordering(sortPathSpec, isAscending));
416     }
417
418     /** Adds ordering specification to this query orderings. */
419     public void addOrdering(String JavaDoc sortPathSpec, boolean isAscending, boolean ignoreCase) {
420         this.addOrdering(new Ordering(sortPathSpec, isAscending, ignoreCase));
421     }
422
423     /**
424      * Removes ordering.
425      *
426      * @since 1.1
427      */

428     public void removeOrdering(Ordering ordering) {
429         if (orderings != null) {
430             orderings.remove(ordering);
431         }
432     }
433
434     /**
435      * Returns a list of orderings used by this query.
436      */

437     public List JavaDoc getOrderings() {
438         return (orderings != null) ? orderings : Collections.EMPTY_LIST;
439     }
440
441     /**
442      * Clears all configured orderings.
443      */

444     public void clearOrderings() {
445         orderings = null;
446     }
447
448     /**
449      * Returns true if this query returns distinct rows.
450      */

451     public boolean isDistinct() {
452         return distinct;
453     }
454
455     /**
456      * Sets <code>distinct</code> property that determines whether this query returns
457      * distinct row.
458      */

459     public void setDistinct(boolean distinct) {
460         this.distinct = distinct;
461     }
462
463     /**
464      * Returns a list of attributes that will be included in the results of this query.
465      */

466     public List JavaDoc getCustomDbAttributes() {
467         // if query root is DbEntity, and no custom attributes
468
// are defined, return DbEntity attributes.
469
if ((customDbAttributes == null || customDbAttributes.isEmpty())
470                 && (getRoot() instanceof DbEntity)) {
471             Collection JavaDoc attributes = ((DbEntity) getRoot()).getAttributes();
472             List JavaDoc attributeNames = new ArrayList JavaDoc(attributes.size());
473             Iterator JavaDoc it = attributes.iterator();
474             while (it.hasNext()) {
475                 DbAttribute attribute = (DbAttribute) it.next();
476                 attributeNames.add(attribute.getName());
477             }
478
479             return attributeNames;
480         }
481         else {
482             return (customDbAttributes != null)
483                     ? customDbAttributes
484                     : Collections.EMPTY_LIST;
485         }
486     }
487
488     /**
489      * Adds a path to the DbAttribute that should be included in the results of this
490      * query. Valid paths would look like <code>ARTIST_NAME</code>,
491      * <code>PAINTING_ARRAY.PAINTING_ID</code>, etc.
492      */

493     public void addCustomDbAttribute(String JavaDoc attributePath) {
494         nonNullCustomDbAttributes().add(attributePath);
495     }
496
497     public void addCustomDbAttributes(List JavaDoc attrPaths) {
498         nonNullCustomDbAttributes().addAll(attrPaths);
499     }
500
501     /**
502      * Returns <code>true</code> if there is at least one custom query attribute
503      * specified, otherwise returns <code>false</code> for the case when the query
504      * results will contain only the root entity attributes.
505      * <p>
506      * Note that queries that are fetching custom attributes always return data rows
507      * instead of DataObjects.
508      * </p>
509      */

510     public boolean isFetchingCustomAttributes() {
511         return (getRoot() instanceof DbEntity)
512                 || (customDbAttributes != null && !customDbAttributes.isEmpty());
513     }
514
515     /**
516      * Returns a list that internally stores custom db attributes, creating it on demand.
517      *
518      * @since 1.2
519      */

520     List JavaDoc nonNullCustomDbAttributes() {
521         if (customDbAttributes == null) {
522             customDbAttributes = new ArrayList JavaDoc();
523         }
524
525         return customDbAttributes;
526     }
527
528     /**
529      * Returns a list that internally stores orderings, creating it on demand.
530      *
531      * @since 1.2
532      */

533     List JavaDoc nonNullOrderings() {
534         if (orderings == null) {
535             orderings = new ArrayList JavaDoc();
536         }
537
538         return orderings;
539     }
540
541     /**
542      * Returns a collection that internally stores prefetches, creating such collection on
543      * demand.
544      *
545      * @since 1.2
546      */

547     Collection JavaDoc nonNullPrefetches() {
548         if (prefetches == null) {
549             prefetches = new HashSet JavaDoc();
550         }
551
552         return prefetches;
553     }
554
555     /**
556      * Returns a collection of joint prefetches.
557      *
558      * @since 1.2
559      */

560     public Collection JavaDoc getJointPrefetches() {
561         return selectProperties.getJointPrefetches();
562     }
563
564     /**
565      * Adds a joint prefetch.
566      *
567      * @since 1.2
568      */

569     public void addJointPrefetch(String JavaDoc relationshipPath) {
570         selectProperties.addJointPrefetch(relationshipPath);
571     }
572
573     /**
574      * Adds all joint prefetches from a provided collection.
575      *
576      * @since 1.2
577      */

578     public void addJointPrefetches(Collection JavaDoc relationshipPaths) {
579         selectProperties.addJointPrefetches(relationshipPaths);
580     }
581
582     /**
583      * Clears all joint prefetches.
584      *
585      * @since 1.2
586      */

587     public void clearJointPrefetches() {
588         selectProperties.clearJointPrefetches();
589     }
590
591     /**
592      * Removes joint prefetch.
593      *
594      * @since 1.2
595      */

596     public void removeJointPrefetch(String JavaDoc relationshipPath) {
597         selectProperties.removeJointPrefetch(relationshipPath);
598     }
599
600     /**
601      * Returns a collection of String paths indicating relationships to objects that are
602      * prefetched together with this query.
603      */

604     public Collection JavaDoc getPrefetches() {
605         return (prefetches != null) ? prefetches : Collections.EMPTY_SET;
606     }
607
608     /**
609      * Adds a relationship path to the internal collection of paths that should be
610      * prefetched when the query is executed.
611      */

612     public void addPrefetch(String JavaDoc relationshipPath) {
613         nonNullPrefetches().add(relationshipPath);
614     }
615
616     /**
617      * Adds all relationship paths in a collection to the internal collection of
618      * prefetched paths.
619      */

620     public void addPrefetches(Collection JavaDoc relationshipPaths) {
621         nonNullPrefetches().addAll(relationshipPaths);
622     }
623
624     /**
625      * Clears all stored prefetch paths.
626      */

627     public void clearPrefetches() {
628         prefetches.clear();
629     }
630
631     /**
632      * Removes prefetch.
633      *
634      * @since 1.1
635      */

636     public void removePrefetch(String JavaDoc prefetch) {
637         if (prefetches != null) {
638             prefetches.remove(prefetch);
639         }
640     }
641
642     /**
643      * Returns <code>true</code> if this query should produce a list of data rows as
644      * opposed to DataObjects, <code>false</code> for DataObjects. This is a hint to
645      * QueryEngine executing this query.
646      */

647     public boolean isFetchingDataRows() {
648         return this.isFetchingCustomAttributes() || selectProperties.isFetchingDataRows();
649     }
650
651     /**
652      * Sets query result type. If <code>flag</code> parameter is <code>true</code>,
653      * then results will be in the form of data rows.
654      * <p>
655      * <i>Note that if <code>isFetchingCustAttributes()</code> returns <code>true</code>,
656      * this setting has no effect, and data rows are always fetched. </i>
657      * </p>
658      */

659     public void setFetchingDataRows(boolean flag) {
660         selectProperties.setFetchingDataRows(flag);
661     }
662
663     /**
664      * Returns refresh policy of this query. Default is <code>true</code>.
665      *
666      * @since 1.1
667      */

668     public boolean isRefreshingObjects() {
669         return selectProperties.isRefreshingObjects();
670     }
671
672     /**
673      * @since 1.1
674      */

675     public void setRefreshingObjects(boolean flag) {
676         selectProperties.setRefreshingObjects(flag);
677     }
678
679     /**
680      * @since 1.1
681      */

682     public String JavaDoc getCachePolicy() {
683         return selectProperties.getCachePolicy();
684     }
685
686     /**
687      * @since 1.1
688      */

689     public void setCachePolicy(String JavaDoc policy) {
690         this.selectProperties.setCachePolicy(policy);
691     }
692
693     /**
694      * Returns the fetchLimit.
695      *
696      * @return int
697      */

698     public int getFetchLimit() {
699         return selectProperties.getFetchLimit();
700     }
701
702     /**
703      * Sets the fetchLimit.
704      *
705      * @param fetchLimit The fetchLimit to set
706      */

707     public void setFetchLimit(int fetchLimit) {
708         this.selectProperties.setFetchLimit(fetchLimit);
709     }
710
711     /** Setter for query's parent entity qualifier. */
712     public void setParentQualifier(Expression parentQualifier) {
713         this.parentQualifier = parentQualifier;
714     }
715
716     /** Getter for query parent entity qualifier. */
717     public Expression getParentQualifier() {
718         return parentQualifier;
719     }
720
721     /**
722      * Adds specified parent entity qualifier to the existing parent entity qualifier
723      * joining it using "AND".
724      */

725     public void andParentQualifier(Expression e) {
726         parentQualifier = (parentQualifier != null) ? parentQualifier.andExp(e) : e;
727     }
728
729     /**
730      * Adds specified parent entity qualifier to the existing qualifier joining it using
731      * "OR".
732      */

733     public void orParentQualifier(Expression e) {
734         parentQualifier = (parentQualifier != null) ? parentQualifier.orExp(e) : e;
735     }
736
737     /**
738      * Returns the name of parent ObjEntity.
739      *
740      * @return String
741      */

742     public String JavaDoc getParentObjEntityName() {
743         return parentObjEntityName;
744     }
745
746     /**
747      * Sets the name of parent ObjEntity. If query's root ObjEntity maps to a derived
748      * entity in the DataMap, this query qualifier will resolve to a HAVING clause of an
749      * SQL statement. To allow fine tuning the query before applying GROUP BY and HAVING,
750      * callers can setup the name of parent ObjEntity and parent qualifier that will be
751      * used to create WHERE clause preceeding GROUP BY.
752      * <p>
753      * For instance this is helpful to qualify the fetch on a related entity attributes,
754      * since HAVING does not allow joins.
755      * </p>
756      *
757      * @param parentObjEntityName The parentObjEntityName to set
758      */

759     public void setParentObjEntityName(String JavaDoc parentObjEntityName) {
760         this.parentObjEntityName = parentObjEntityName;
761     }
762
763     /**
764      * Returns <code>true</code> if this query has an extra qualifier that uses a parent
765      * entity of the query root entity for additional result filtering.
766      */

767     public boolean isQualifiedOnParent() {
768         return getParentObjEntityName() != null && parentQualifier != null;
769     }
770
771     /**
772      * Returns <code>pageSize</code> property. Page size is a hint telling Cayenne
773      * QueryEngine that query result should use paging instead of reading the whole result
774      * in the memory.
775      *
776      * @return int
777      */

778     public int getPageSize() {
779         return selectProperties.getPageSize();
780     }
781
782     /**
783      * Sets <code>pageSize</code> property.
784      *
785      * @param pageSize The pageSize to set
786      */

787     public void setPageSize(int pageSize) {
788         selectProperties.setPageSize(pageSize);
789     }
790
791     /**
792      * Returns true if objects fetched via this query should be fully resolved according
793      * to the inheritance hierarchy.
794      *
795      * @since 1.1
796      */

797     public boolean isResolvingInherited() {
798         return selectProperties.isResolvingInherited();
799     }
800
801     /**
802      * Sets whether the objects fetched via this query should be fully resolved according
803      * to the inheritance hierarchy.
804      *
805      * @since 1.1
806      */

807     public void setResolvingInherited(boolean b) {
808         selectProperties.setResolvingInherited(b);
809     }
810 }
Popular Tags