org.apache.ojb.broker.query
Class QueryByIdentity

java.lang.Object
  extended by org.apache.ojb.broker.query.AbstractQueryImpl
      extended by org.apache.ojb.broker.query.QueryByIdentity
All Implemented Interfaces:
java.io.Serializable, Query

public class QueryByIdentity
extends AbstractQueryImpl

Represents a search by identity. "find the article with id 7" could be represented as:

Article example = new Article();
example.setId(7);
Query qry = new QueryByIdentity(example);

The PersistenceBroker can retrieve Objects by examples as follows:

PersistenceBroker broker = PersistenceBrokerFactory.createPersistenceBroker();
Collection col = broker.getObjectByQuery(qry);

This Class can also handle working with OJB Identity objects: "find the article with Identity xyz" could be represnted as

Article example = new Article();
example.setId(7);
Identity xyz = broker.serviceIdentity().buildIdentity(example);
Query qry = new QueryByIdentity(xyz);
Collection col = broker.getObjectByQuery(qry);

But in this case a smarter solution will be

Identity xyz = broker.serviceIdentity().buildIdentity(Article.class, new Integer(7));
Collection col = broker.getObjectByIdentity(xyz);

Version:
$Id: QueryByIdentity.java 365232 2005-12-21 22:36:07Z tomdz $
Author:
Thomas Mahler
See Also:
Serialized Form

Field Summary
 
Fields inherited from interface org.apache.ojb.broker.query.Query
NO_END_AT_INDEX, NO_START_AT_INDEX, NOT_SCROLLABLE, SCROLLABLE
 
Constructor Summary
QueryByIdentity(java.lang.Object example_or_identity)
          QueryByIdentity can be generated from example Objects or by Identity Objects
 
Method Summary
 java.lang.Object getExampleObject()
          Answer the example Object
 java.lang.Class getSearchClass()
          Answer the search class.
 
Methods inherited from class org.apache.ojb.broker.query.AbstractQueryImpl
fullSize, fullSize, getBaseClass, getCriteria, getEndAtIndex, getFetchSize, getGroupBy, getHavingCriteria, getOrderBy, getPrefetchedRelationships, getStartAtIndex, getWithExtents, isDistinct, setEndAtIndex, setFetchSize, setStartAtIndex, setWithExtents, usePaging
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

QueryByIdentity

public QueryByIdentity(java.lang.Object example_or_identity)
QueryByIdentity can be generated from example Objects or by Identity Objects

Method Detail

getExampleObject

public java.lang.Object getExampleObject()
Answer the example Object

Specified by:
getExampleObject in interface Query
Overrides:
getExampleObject in class AbstractQueryImpl
Returns:
the example Object or an Identity

getSearchClass

public java.lang.Class getSearchClass()
Answer the search class. This is the class of the example object or the class represented by Identity.

Specified by:
getSearchClass in interface Query
Overrides:
getSearchClass in class AbstractQueryImpl
Returns:
Class


(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