| |
|
| java.lang.Object org.apache.ojb.broker.query.AbstractQueryImpl org.apache.ojb.broker.query.QueryByIdentity
QueryByIdentity | public class QueryByIdentity extends AbstractQueryImpl (Code) | | 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);
author: Thomas Mahler version: $Id: QueryByIdentity.java,v 1.9.2.3 2005/12/21 22:27:09 tomdz Exp $ |
QueryByIdentity | public QueryByIdentity(Object example_or_identity)(Code) | | QueryByIdentity can be generated from example Objects or by Identity Objects
|
getExampleObject | public Object getExampleObject()(Code) | | Answer the example Object
the example Object or an Identity |
getSearchClass | public Class getSearchClass()(Code) | | Answer the search class.
This is the class of the example object or
the class represented by Identity.
Class |
|
|
|