|
PSE 2000 Group 4 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
jobmatch.data.ProfileQuery
ProfileQuery is used to query the Profile table in the database.
It returns objects of type ProfileDO.
General usage:
In DODS: Create a Data Object named "Dog", and create an Attribute named "Name", and set that Attribute to "Can be queried." DODS will then generate the method DogQuery.setQueryName().
In your Business Layer, prepare the query:
DogQuery dq = new DogQuery(); dq.setQueryName("Rex") if ( Rex is a reserved name ) dq.requireUniqueInstance();Then, get the query results one of two ways:
#1:
String names = ""; DogBDO[] dogs = dq.getBDOArray(); for ( int i = 0; i < dogs.length; i++ ) { names += dogs[i].getName() + " "; }or #2:
String names = ""; DogBDO dog; while ( null != ( dog = dq.getNextBDO() ) ) { names += dog.getName() + " "; }Note: Methods
getDOArray()
and getNextDO()
do exist, but they are not generally used
in the Business or Presentation layers of an application.
All access to the Data Layer (DO classes) should occur via
the Business Layer (BDO classes).
Only the Business Layer (BDO classes and classes extending them)
should need to manipulate the Data Layer (DO classes).
See also the comments in the BDO constructors.
Note: If requireUniqueInstance()
was called,
then getBDOArray()
or getNextBDO()
will throw an exception if more than one "Rex" was found.
Note: Results of the query will come from the Data Object cache if:
- The cache is available.
- Matches were found in the cache.
- No other tables (Data Objects of other types) were involved
in the query.
This can happen if you extend the DogQuery
class
and you make calls to the QueryBuilder
object
to add SQL involving other tables.
If any of these conditions is not true,
then any results from the query will come from the database.
To reuse the query object, call:
dq.reset();
Constructor Summary | |
ProfileQuery()
Public constructor. |
Method Summary | |
void |
addOrderByCompany()
Add Company to the ORDER BY clause. |
void |
addOrderByCompany(boolean direction_flag)
Add Company to the ORDER BY clause. |
void |
addOrderByLastNotification()
Add LastNotification to the ORDER BY clause. |
void |
addOrderByLastNotification(boolean direction_flag)
Add LastNotification to the ORDER BY clause. |
void |
addOrderByMatchTree()
Add MatchTree to the ORDER BY clause. |
void |
addOrderByMatchTree(boolean direction_flag)
Add MatchTree to the ORDER BY clause. |
void |
addOrderByName()
Add Name to the ORDER BY clause. |
void |
addOrderByName(boolean direction_flag)
Add Name to the ORDER BY clause. |
void |
addOrderByNeedsRematching()
Add NeedsRematching to the ORDER BY clause. |
void |
addOrderByNeedsRematching(boolean direction_flag)
Add NeedsRematching to the ORDER BY clause. |
void |
addOrderByNotificationPeriod()
Add NotificationPeriod to the ORDER BY clause. |
void |
addOrderByNotificationPeriod(boolean direction_flag)
Add NotificationPeriod to the ORDER BY clause. |
void |
addOrderByNotify()
Add Notify to the ORDER BY clause. |
void |
addOrderByNotify(boolean direction_flag)
Add Notify to the ORDER BY clause. |
void |
closeParen()
Place a closing parenthesis in the WHERE clause. |
ResultSet |
executeQuery(jobmatch.data.DBConnection conn)
Method to query objects from the database. |
ProfileBDO[] |
getBDOArray()
Return array of BDOs constructed from ResultSet returned by query. |
ProfileDO[] |
getDOArray()
Return array of DOs constructed from ResultSet returned by query. |
ProfileBDO |
getNextBDO()
Return successive BDOs from array built from ResultSet returned by query. |
ProfileDO |
getNextDO()
Return successive DOs from array built from ResultSet returned by query. |
jobmatch.data.QueryBuilder |
getQueryBuilder()
Returns the QueryBuilder that this ProfileQuery
uses to construct and execute database queries. |
void |
hitDatabase()
|
Object |
next(ResultSet rs)
WARNING! This method is disabled. |
void |
openParen()
Place an open parenthesis in the WHERE clause. |
void |
or()
Insert an OR between WHERE clauses. |
void |
requireUniqueInstance()
Set "unique instance" assertion bit. |
void |
reset()
Reset the query parameters. |
void |
setQueryCompany(CompanyDO x)
Set the Company to query |
void |
setQueryCompany(CompanyDO x,
boolean exact)
Set the Company to query. |
void |
setQueryHandle(String handle)
Set the object handle to query. |
void |
setQueryLastNotification(Timestamp x)
Set the LastNotification to query |
void |
setQueryLastNotification(Timestamp x,
boolean exact)
Set the LastNotification to query. |
void |
setQueryMatchTree(byte[] x)
Set the MatchTree to query |
void |
setQueryMatchTree(byte[] x,
boolean exact)
Set the MatchTree to query. |
void |
setQueryName(String x)
Set the Name to query |
void |
setQueryName(String x,
boolean exact)
Set the Name to query. |
void |
setQueryNeedsRematching(boolean x)
Set the NeedsRematching to query |
void |
setQueryNeedsRematching(boolean x,
boolean exact)
Set the NeedsRematching to query. |
void |
setQueryNotificationPeriod(int x)
Set the NotificationPeriod to query |
void |
setQueryNotificationPeriod(int x,
boolean exact)
Set the NotificationPeriod to query. |
void |
setQueryNotify(boolean x)
Set the Notify to query |
void |
setQueryNotify(boolean x,
boolean exact)
Set the Notify to query. |
void |
setQueryOId(jobmatch.data.ObjectId oid)
Set the OID to query. |
Constructor Detail |
public ProfileQuery()
Method Detail |
public void hitDatabase()
public ProfileDO[] getDOArray() throws jobmatch.data.DataObjectException, jobmatch.data.NonUniqueQueryException
public ProfileDO getNextDO() throws jobmatch.data.DataObjectException, jobmatch.data.NonUniqueQueryException
public ProfileBDO[] getBDOArray() throws jobmatch.data.DataObjectException, jobmatch.data.NonUniqueQueryException
public ProfileBDO getNextBDO() throws jobmatch.data.DataObjectException, jobmatch.data.NonUniqueQueryException
public void setQueryOId(jobmatch.data.ObjectId oid)
Profile
has a column named "oid"
.
This method is called from the DO classes to retrieve an object by id.oid
- The object id to query.public void setQueryHandle(String handle) throws jobmatch.data.ObjectIdException
handle
- The string version of the id to query.public void requireUniqueInstance()
public void reset()
public ResultSet executeQuery(jobmatch.data.DBConnection conn) throws SQLException
conn
- Handle to database connection.public Object next(ResultSet rs) throws SQLException, jobmatch.data.ObjectIdException
rs
- JDBC result set from which the next object
will be instantiated.public void setQueryCompany(CompanyDO x, boolean exact) throws jobmatch.data.DataObjectException, jobmatch.data.QueryException
x
- The Company of the Profile to query.exact
- to use matches or notpublic void setQueryCompany(CompanyDO x) throws jobmatch.data.DataObjectException, jobmatch.data.QueryException
x
- The Company of the Profile to query.public void addOrderByCompany(boolean direction_flag)
direction_flag
- True for ascending order, false for descendingpublic void addOrderByCompany()
public void setQueryLastNotification(Timestamp x, boolean exact) throws jobmatch.data.DataObjectException, jobmatch.data.QueryException
x
- The LastNotification of the Profile to query.exact
- to use matches or notpublic void setQueryLastNotification(Timestamp x) throws jobmatch.data.DataObjectException, jobmatch.data.QueryException
x
- The LastNotification of the Profile to query.public void addOrderByLastNotification(boolean direction_flag)
direction_flag
- True for ascending order, false for descendingpublic void addOrderByLastNotification()
public void setQueryMatchTree(byte[] x, boolean exact) throws jobmatch.data.DataObjectException, jobmatch.data.QueryException
x
- The MatchTree of the Profile to query.exact
- to use matches or notpublic void setQueryMatchTree(byte[] x) throws jobmatch.data.DataObjectException, jobmatch.data.QueryException
x
- The MatchTree of the Profile to query.public void addOrderByMatchTree(boolean direction_flag)
direction_flag
- True for ascending order, false for descendingpublic void addOrderByMatchTree()
public void setQueryName(String x, boolean exact) throws jobmatch.data.DataObjectException, jobmatch.data.QueryException
x
- The Name of the Profile to query.exact
- to use matches or notpublic void setQueryName(String x) throws jobmatch.data.DataObjectException, jobmatch.data.QueryException
x
- The Name of the Profile to query.public void addOrderByName(boolean direction_flag)
direction_flag
- True for ascending order, false for descendingpublic void addOrderByName()
public void setQueryNeedsRematching(boolean x, boolean exact) throws jobmatch.data.DataObjectException, jobmatch.data.QueryException
x
- The NeedsRematching of the Profile to query.exact
- to use matches or notpublic void setQueryNeedsRematching(boolean x) throws jobmatch.data.DataObjectException, jobmatch.data.QueryException
x
- The NeedsRematching of the Profile to query.public void addOrderByNeedsRematching(boolean direction_flag)
direction_flag
- True for ascending order, false for descendingpublic void addOrderByNeedsRematching()
public void setQueryNotify(boolean x, boolean exact) throws jobmatch.data.DataObjectException, jobmatch.data.QueryException
x
- The Notify of the Profile to query.exact
- to use matches or notpublic void setQueryNotify(boolean x) throws jobmatch.data.DataObjectException, jobmatch.data.QueryException
x
- The Notify of the Profile to query.public void addOrderByNotify(boolean direction_flag)
direction_flag
- True for ascending order, false for descendingpublic void addOrderByNotify()
public void setQueryNotificationPeriod(int x, boolean exact) throws jobmatch.data.DataObjectException, jobmatch.data.QueryException
x
- The NotificationPeriod of the Profile to query.exact
- to use matches or notpublic void setQueryNotificationPeriod(int x) throws jobmatch.data.DataObjectException, jobmatch.data.QueryException
x
- The NotificationPeriod of the Profile to query.public void addOrderByNotificationPeriod(boolean direction_flag)
direction_flag
- True for ascending order, false for descendingpublic void addOrderByNotificationPeriod()
public jobmatch.data.QueryBuilder getQueryBuilder()
QueryBuilder
that this ProfileQuery
uses to construct and execute database queries.
ProfileQuery.setQueryXXX
methods use
the QueryBuilder
to
append SQL expressions to the "WHERE"
clause to be executed.
The QueryBuilder.addEndClause method.
can be used to
append freeform SQL expressions to the WHERE
clause,
e.g. "ORDER BY name".
Notes regarding cache-enabled DO classes:
DO classes can be cache-enabled.
If when using a ProfileQuery
, the application developer
does not call getQueryBuilder
,
then ProfileQuery.setQueryXXX
methods
simply prune the DO cache and return the remaining results.
However, a QueryBuilder
builds
SELECT
statements for execution by the actual database,
and never searches the built-in cache for the DO.
So, if the DO class is cache-enabled, and getQueryBuilder
is called, this ProfileQuery
object ignores the cache
and hits the actual database.public void or()
OR
between WHERE
clauses.
Example: find all the persons named Bob or Robert:
PersonQuery pq = new PersonQuery();
pq.setQueryFirstName( "Bob" );
pq.or();
pq.setQueryFirstName( "Robert" );
Note: Calls to setQueryXxx
methods
are implicitly AND
ed together,
so the following example will always return nothing:
PersonQuery pq = new PersonQuery();
pq.setQueryFirstName( "Bob" );
// AND automatically inserted here.
pq.setQueryFirstName( "Robert" );
public void openParen()
WHERE
clause.
Example usage: find all the Bobs and Roberts who are 5 or 50 years old:
PersonQuery pq = new PersonQuery();
pq.openParen();
pq.setQueryFirstName( "Bob" );
pq.or();
pq.setQueryFirstName( "Robert" );
pq.closeParen();
// AND automatically inserted here.
pq.openParen();
pq.setQueryAge( 5 );
pq.or();
pq.setQueryAge( 50 );
pq.closeParen();
public void closeParen()
WHERE
clause.openParen
|
PSE 2000 Group 4 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |