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:
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,v 1.1 2007-08-24 22:17:36 ewestfal Exp $
Author:
Thomas Mahler
See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.apache.ojb.broker.query.AbstractQueryImpl
m_baseClass, m_searchClass
 
Fields inherited from interface org.apache.ojb.broker.query.Query
NO_END_AT_INDEX, NO_START_AT_INDEX, NOT_SCROLLABLE, SCROLLABLE
 
Constructor Summary
QueryByIdentity(Object example_or_identity)
          QueryByIdentity can be generated from example Objects or by Identity Objects
 
Method Summary
 Object getExampleObject()
          Answer the example Object
 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
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

QueryByIdentity

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

Method Detail

getExampleObject

public 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 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


Copyright © 2004-2012 The Kuali Foundation. All Rights Reserved.