org.apache.ojb.broker.query
Class QueryByIdentity
java.lang.Object
org.apache.ojb.broker.query.AbstractQueryImpl
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
Constructor Summary |
QueryByIdentity(Object example_or_identity)
QueryByIdentity can be generated from example Objects or by Identity Objects |
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 |
QueryByIdentity
public QueryByIdentity(Object example_or_identity)
- QueryByIdentity can be generated from example Objects or by Identity Objects
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.