001: /**
002: * Objective Database Abstraction Layer (ODAL)
003: * Copyright (c) 2004, The ODAL Development Group
004: * All rights reserved.
005: * For definition of the ODAL Development Group please refer to LICENCE.txt file
006: *
007: * Distributable under LGPL license.
008: * See terms of license at gnu.org.
009: */package com.completex.objective.components.persistency;
010:
011: /**
012: * @author Gennady Krizhevsky
013: */
014: public interface QueryFactory extends BasicQueryFactory,
015: QueryFactoryCtl, QueryFactoryBase {
016:
017: /**
018: * Creates preset query object
019: *
020: * @param sql SQL statement
021: * @return new <code>Query</code> instance
022: */
023: Query newQuery(String sql);
024:
025: /**
026: * Creates preset query object
027: *
028: * @param singularResultFactory singular result factory
029: * @return new <code>Query</code> instance
030: */
031: Query newQuery(PersistentObjectFactory singularResultFactory);
032:
033: //
034: // Paginated "disconnected" queries:
035: //
036:
037: /**
038: * Creates preset query object which when executed brings only one page of results
039: *
040: * @param singularResultFactory singular result factory
041: * @param offset 0-based offset
042: * @param pageSize page size
043: * @return new <code>Query</code> instance
044: */
045: Query newDisconnectedPageQuery(
046: AbstractPersistentObject singularResultFactory,
047: long offset, long pageSize);
048:
049: /**
050: * Creates preset query object which when executed brings only one page of results
051: *
052: * @param sql SQL statement
053: * @param offset 0-based offset
054: * @param pageSize page size
055: * @return new <code>Query</code> instance
056: */
057: Query newDisconnectedPageQuery(String sql, long offset,
058: long pageSize);
059:
060: /**
061: * Creates preset query object which when executed brings only one page of results
062: *
063: * @param offset 0-based offset
064: * @param pageSize page size
065: * @return new <code>Query</code> instance
066: */
067: Query newDisconnectedPageQuery(long offset, long pageSize);
068:
069: /**
070: * Creates preset query object which when executed brings only one page of results
071: *
072: * @param query query object
073: * @param offset 0-based offset
074: * @param pageSize page size
075: * @return new <code>Query</code> instance
076: */
077: Query newDisconnectedPageQuery(Query query, long offset,
078: long pageSize);
079:
080: /**
081: * Creates preset query object which when executed brings only one page of results
082: *
083: * @param singularResultFactory
084: * @param page Page attributes
085: * @return new <code>Query</code> instance
086: * @see Page
087: */
088: Query newDisconnectedPageQuery(
089: AbstractPersistentObject singularResultFactory, Page page);
090:
091: /**
092: * Creates preset query object which when executed brings only one page of results
093: *
094: * @param query
095: * @param page Page attributes
096: * @return new <code>Query</code> instance
097: * @see Page
098: */
099: Query newDisconnectedPageQuery(Query query, Page page);
100:
101: /**
102: * Creates preset query object which when executed brings only one page of results
103: *
104: * @param page Page attributes
105: * @return new <code>Query</code> instance
106: * @see Page
107: */
108: Query newDisconnectedPageQuery(Page page);
109:
110: /**
111: * Creates preset query object which when executed brings only one page of results
112: *
113: * @param sql SQL statement
114: * @param page Page attributes
115: * @return new <code>Query</code> instance
116: */
117: Query newDisconnectedPageQuery(String sql, Page page);
118:
119: //
120: // Paginated "connected" queries:
121: //
122:
123: /**
124: * Creates preset query object which when executed brings only one page of results
125: * and does not disconnect from the database. It keeps cursor/result set open and only closes it either
126: * when there is nothing to retrieve or on transaction commit.
127: * <br><p>The following snippet shows how to use it:</br></p>
128: * <PRE>
129: * Query query = persistency.getQueryFactory().newConnectedForwardPageQuery(new Person(), 1000);
130: * <p/>
131: * List persons;
132: * while ((persons = persistency.select(query).size() > 0 ) {
133: * // Do your processing here
134: * }
135: * </PRE>
136: *
137: * @param singularResultFactory singular result factory
138: * @param pageSize page size
139: * @return new <code>Query</code> instance
140: */
141: Query newConnectedForwardPageQuery(
142: AbstractPersistentObject singularResultFactory,
143: long pageSize);
144:
145: /**
146: * Creates preset query object which when executed brings only one page of results
147: * and does not disconnect from the database. It keeps cursor/result set open and only closes it either
148: * when there is nothing to retrieve or on transaction commit.
149: * <br><p>The following snippet shows how to use it:</br></p>
150: * <PRE>
151: * Query query = persistency.getQueryFactory().newConnectedForwardPageQuery("select * from person", 1000);
152: * <p/>
153: * List persons;
154: * while ((persons = persistency.select(query).size() > 0 ) {
155: * // Do your processing here
156: * }
157: * </PRE>
158: *
159: * @param sql SQL statement
160: * @param pageSize page size
161: * @return new <code>Query</code> instance
162: */
163: Query newConnectedForwardPageQuery(String sql, long pageSize);
164:
165: /**
166: * Creates preset query object which when executed brings only one page of results
167: * and does not disconnect from the database. It keeps cursor/result set open and only closes it either
168: * when there is nothing to retrieve or on transaction commit.
169: * <br><p>The following snippet shows how to use it:</br></p>
170: * <PRE>
171: * Query query = persistency.getQueryFactory().newConnectedForwardPageQuery(1000);
172: * // query setup
173: * <p/>
174: * List persons;
175: * while ((persons = persistency.select(query).size() > 0 ) {
176: * // Do your processing here
177: * }
178: * </PRE>
179: *
180: * @param pageSize page size
181: * @return new <code>Query</code> instance
182: */
183: Query newConnectedForwardPageQuery(long pageSize);
184:
185: /**
186: * Creates preset query object which when executed brings only one page of results
187: * and does not disconnect from the database. It keeps cursor/result set open and only closes it either
188: * when there is nothing to retrieve or on transaction commit.
189: * <br><p>The following snippet shows how to use it:</br></p>
190: * <PRE>
191: * <p/>
192: * Query nonPaginatedQuery = persistency.getQueryFactory().newQuery(new Person());
193: * // nonPaginatedQuery setup ...
194: * <p/>
195: * Query query = persistency.getQueryFactory().newConnectedForwardPageQuery(nonPaginatedQuery, 1000);
196: * <p/>
197: * List persons;
198: * while ((persons = persistency.select(query).size() > 0 ) {
199: * // Do your processing here
200: * }
201: * </PRE>
202: *
203: * @param query non-paginated Query object
204: * @param pageSize page size
205: * @return new <code>Query</code> instance
206: */
207: Query newConnectedForwardPageQuery(Query query, long pageSize);
208:
209: //
210: // Queries By Example:
211: //
212:
213: /**
214: * Creates preset query object by <code>PersistentObject</code> with set values which are used in where clause
215: *
216: * @param persistentObject <code>PersistentObject</code> with set values
217: * @return new <code>Query</code> instance
218: */
219: Query newQueryByExample(PersistentObject persistentObject);
220:
221: /**
222: * Creates preset query object by <code>Compound</code> with set values which are used in where clause
223: *
224: * @param compound <code>Compound</code> with set values
225: * @return new <code>Query</code> instance
226: */
227: Query newQueryByCompoundExample(Compound compound);
228:
229: /**
230: * Creates new QBE out of compound object. Entries are joined explicitely in joinMode.
231: * Mode set to compound object initially gets reset.
232: *
233: * @param compound compound object which values are used in SQL condition
234: * @param joinMode Compound.INNER, Compound.OUTER or Compound.NONE
235: * @return new Query
236: */
237: Query newQueryByCompoundExample(Compound compound,
238: Compound.ImplicitJoinMode joinMode);
239:
240: Query newQueryByExample(PersistentObject persistentObject,
241: CompoundColumnFilter filters);
242:
243: Query newQueryByCompoundExample(Compound compound,
244: CompoundColumnFilter filters);
245:
246: Query newQueryByCompoundExample(Compound compound,
247: Compound.ImplicitJoinMode joinMode,
248: CompoundColumnFilter filters);
249: }
|