org.apache.ojb.broker.query
Interface Query

All Superinterfaces:
java.io.Serializable
All Known Implementing Classes:
AbstractQueryImpl, QueryByCriteria, QueryByIdentity, QueryByMtoNCriteria, QueryBySQL, ReportQueryByCriteria, ReportQueryByMtoNCriteria

public interface Query
extends java.io.Serializable

represents Queries that can be used by the OJB PersistenceBroker to retrieve Objects from the underlying DB. Until now there are two implementations: 1. QueryByCriteria, represents SELECT * FROM ... WHERE ... queries 2. QueryByIdentity, uses Example objects or OIDs as templates for the db lookup there could additional implementations, e.g for user defined SQL For the Criteria API I reused code from the COBRA project, as you will see by their class comments. I removed all stuff that relies on knowlegde of the DataDictionary or MetaData layer. The Query and Criteria classes thus don't know how to build SQL statements, as in the COBRA original sources. I use the this classes as mere data-structures, that are processed by the OJB Accesslayer (SqlGenerator, JdbcAccess). This design will allow to reuse the org.apache.ojb.broker.query package in other projects without breaking any references. I hope this will be useful for someone.

Version:
$Id: Query.java 365232 2005-12-21 22:36:07Z tomdz $
Author:
Thomas Mahler

Field Summary
static int NO_END_AT_INDEX
           
static int NO_START_AT_INDEX
           
static boolean NOT_SCROLLABLE
           
static boolean SCROLLABLE
           
static long serialVersionUID
           
 
Method Summary
 int fullSize()
          Deprecated. use OJBIterator.fullSize()
 void fullSize(int size)
          Deprecated.  
 java.lang.Class getBaseClass()
          return the base class, with respect to which all paths are done
 Criteria getCriteria()
          return the criteria of the query if present or null.
 int getEndAtIndex()
           
 java.lang.Object getExampleObject()
          return the template Object if present or null
 int getFetchSize()
          Returns the fetchSize hint for this Query
 java.util.List getGroupBy()
          Gets the groupby for ReportQueries of all Criteria and Sub Criteria the elements are of class FieldHelper
 Criteria getHavingCriteria()
          return the criteria of the query if present or null.
 java.util.List getOrderBy()
          Answer the orderBy of all Criteria and Sub Criteria the elements are of class FieldHelper
 java.util.List getPrefetchedRelationships()
          Returns the names of Relationships to be prefetched
 java.lang.Class getSearchClass()
          return the target class, representing the extend to be searched
 int getStartAtIndex()
           
 boolean getWithExtents()
           
 boolean isDistinct()
          return true if select DISTINCT should be used
 void setEndAtIndex(int endAtIndex)
          Set the row at which the query should stop retrieving results, inclusive.
 void setFetchSize(int fetchSize)
          Set fetchSize hint for this Query.
 void setStartAtIndex(int startAtIndex)
          Set the row at which the query should start retrieving results, inclusive first row is 1
 void setWithExtents(boolean withExtents)
           
 boolean usePaging()
          Answer true if start- and endIndex is set
 

Field Detail

serialVersionUID

static final long serialVersionUID
See Also:
Constant Field Values

NO_START_AT_INDEX

static final int NO_START_AT_INDEX
See Also:
Constant Field Values

NO_END_AT_INDEX

static final int NO_END_AT_INDEX
See Also:
Constant Field Values

SCROLLABLE

static final boolean SCROLLABLE
See Also:
Constant Field Values

NOT_SCROLLABLE

static final boolean NOT_SCROLLABLE
See Also:
Constant Field Values
Method Detail

getCriteria

Criteria getCriteria()
return the criteria of the query if present or null.


getHavingCriteria

Criteria getHavingCriteria()
return the criteria of the query if present or null.


getExampleObject

java.lang.Object getExampleObject()
return the template Object if present or null


getSearchClass

java.lang.Class getSearchClass()
return the target class, representing the extend to be searched


getBaseClass

java.lang.Class getBaseClass()
return the base class, with respect to which all paths are done


isDistinct

boolean isDistinct()
return true if select DISTINCT should be used


getOrderBy

java.util.List getOrderBy()
Answer the orderBy of all Criteria and Sub Criteria the elements are of class FieldHelper

Returns:
List of FieldHelper

getGroupBy

java.util.List getGroupBy()
Gets the groupby for ReportQueries of all Criteria and Sub Criteria the elements are of class FieldHelper

Returns:
List of FieldHelper

getStartAtIndex

int getStartAtIndex()
Returns:
the row at which the query should start retrieving results. If the start at index is 0, then ignore all cursor control.

setStartAtIndex

void setStartAtIndex(int startAtIndex)
Set the row at which the query should start retrieving results, inclusive first row is 1

Parameters:
startAtIndex - starting index, inclusive.

getEndAtIndex

int getEndAtIndex()
Returns:
the row at which the query should stop retrieving results. If the end at index is 0, ignore all cursor control

setEndAtIndex

void setEndAtIndex(int endAtIndex)
Set the row at which the query should stop retrieving results, inclusive. first row is 1

Parameters:
endAtIndex - ending index, inclusive

getPrefetchedRelationships

java.util.List getPrefetchedRelationships()
Returns the names of Relationships to be prefetched

Returns:
List of Strings

fullSize

void fullSize(int size)
Deprecated. 

Parameters:
size -

fullSize

int fullSize()
Deprecated. use OJBIterator.fullSize()

Returns:

setWithExtents

void setWithExtents(boolean withExtents)

getWithExtents

boolean getWithExtents()

usePaging

boolean usePaging()
Answer true if start- and endIndex is set

Returns:

setFetchSize

void setFetchSize(int fetchSize)
Set fetchSize hint for this Query. Passed to the JDBC driver on the Statement level. It is JDBC driver-dependant if this function has any effect at all, since fetchSize is only a hint.

Parameters:
fetchSize - the fetch size specific to this query

getFetchSize

int getFetchSize()
Returns the fetchSize hint for this Query

Returns:
the fetch size hint specific to this query (or 0 if not set / using driver default)


(C) 2002 - 2006 Apache Software Foundation
All rights reserved. Published under the Apache License 2.0.
http://db.apache.org/ojb
Version: 1.0.4, 2005-12-30