org.apache.ojb.broker.core
Class QueryReferenceBroker

java.lang.Object
  extended by org.apache.ojb.broker.core.QueryReferenceBroker

public class QueryReferenceBroker
extends java.lang.Object

Encapsulates 1:1 and 1:n references and collection references stuff. TODO: Should we made this class independend from PB implementation class and only use PB interface methods?

Version:
$Id: QueryReferenceBroker.java 365270 2005-12-31 19:07:20Z arminw $
Author:
Armin Waibel

Constructor Summary
QueryReferenceBroker(PersistenceBrokerImpl pb)
           
 
Method Summary
 java.lang.Class getClassToPrefetch()
           
 ManageableCollection getCollectionByQuery(java.lang.Class collectionClass, Query query, boolean lazy)
          retrieve a collection of type collectionClass matching the Query query if lazy = true return a CollectionProxy
 java.util.Collection getCollectionByQuery(Query query, boolean lazy)
          retrieve a collection of itemClass Objects matching the Query query
 Query getPKQuery(Identity oid)
          Answer the primary key query to retrieve an Object
 void performRetrievalTasks()
          Perform the stored retrieval tasks BRJ: made it public to access it from BasePrefetcher TODO: this is a quick fix !
 void removePrefetchingListeners()
          remove all prefetching listeners
 void retrieveCollection(java.lang.Object obj, ClassDescriptor cld, CollectionDescriptor cds, boolean forced)
          Retrieve a single Collection on behalf of obj.
 void retrieveCollections(java.lang.Object newObj, ClassDescriptor cld, boolean forced)
          Retrieve all Collection attributes of a given instance
 void retrieveProxyCollection(java.lang.Object obj, ClassDescriptor cld, CollectionDescriptor cds, boolean forced)
          Retrieve a single Proxied Collection on behalf of obj.
 void retrieveProxyCollections(java.lang.Object newObj, ClassDescriptor cld, boolean forced)
          Retrieve all Collection attributes of a given instance, and make all of the Proxy Collections
 void retrieveProxyReference(java.lang.Object obj, ClassDescriptor cld, ObjectReferenceDescriptor rds, boolean forced)
          Retrieve a single Reference.
 void retrieveProxyReferences(java.lang.Object newObj, ClassDescriptor cld, boolean forced)
          Retrieve all References
 void retrieveReference(java.lang.Object obj, ClassDescriptor cld, ObjectReferenceDescriptor rds, boolean forced)
          Retrieve a single Reference.
 void retrieveReferences(java.lang.Object newObj, ClassDescriptor cld, boolean forced)
          Retrieve all References
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

QueryReferenceBroker

public QueryReferenceBroker(PersistenceBrokerImpl pb)
Method Detail

getCollectionByQuery

public ManageableCollection getCollectionByQuery(java.lang.Class collectionClass,
                                                 Query query,
                                                 boolean lazy)
                                          throws PersistenceBrokerException
retrieve a collection of type collectionClass matching the Query query if lazy = true return a CollectionProxy

Parameters:
collectionClass -
query -
lazy -
Returns:
ManageableCollection
Throws:
PersistenceBrokerException

getCollectionByQuery

public java.util.Collection getCollectionByQuery(Query query,
                                                 boolean lazy)
                                          throws PersistenceBrokerException
retrieve a collection of itemClass Objects matching the Query query

Throws:
PersistenceBrokerException

performRetrievalTasks

public void performRetrievalTasks()
Perform the stored retrieval tasks BRJ: made it public to access it from BasePrefetcher TODO: this is a quick fix !


retrieveReference

public void retrieveReference(java.lang.Object obj,
                              ClassDescriptor cld,
                              ObjectReferenceDescriptor rds,
                              boolean forced)
Retrieve a single Reference. This implementation retrieves a referenced object from the data backend if cascade-retrieve is true or if forced is true.

Parameters:
obj - - object that will have it's field set with a referenced object.
cld - - the ClassDescriptor describring obj
rds - - the ObjectReferenceDescriptor of the reference attribute to be loaded
forced - - if set to true, the reference is loaded even if the rds differs.

retrieveProxyReference

public void retrieveProxyReference(java.lang.Object obj,
                                   ClassDescriptor cld,
                                   ObjectReferenceDescriptor rds,
                                   boolean forced)
Retrieve a single Reference. This implementation retrieves a referenced object from the data backend if cascade-retrieve is true or if forced is true.

Parameters:
obj - - object that will have it's field set with a referenced object.
cld - - the ClassDescriptor describring obj
rds - - the ObjectReferenceDescriptor of the reference attribute to be loaded
forced - - if set to true, the reference is loaded even if the rds differs.

retrieveReferences

public void retrieveReferences(java.lang.Object newObj,
                               ClassDescriptor cld,
                               boolean forced)
                        throws PersistenceBrokerException
Retrieve all References

Parameters:
newObj - the instance to be loaded or refreshed
cld - the ClassDescriptor of the instance
forced - if set to true loading is forced even if cld differs.
Throws:
PersistenceBrokerException

retrieveProxyReferences

public void retrieveProxyReferences(java.lang.Object newObj,
                                    ClassDescriptor cld,
                                    boolean forced)
                             throws PersistenceBrokerException
Retrieve all References

Parameters:
newObj - the instance to be loaded or refreshed
cld - the ClassDescriptor of the instance
forced - if set to true loading is forced even if cld differs.
Throws:
PersistenceBrokerException

retrieveCollection

public void retrieveCollection(java.lang.Object obj,
                               ClassDescriptor cld,
                               CollectionDescriptor cds,
                               boolean forced)
Retrieve a single Collection on behalf of obj. The Collection is retrieved only if cascade.retrieve is true or if forced is set to true. *

Parameters:
obj - - the object to be updated
cld - - the ClassDescriptor describing obj
cds - - the CollectionDescriptor describing the collection attribute to be loaded
forced - - if set to true loading is forced, even if cds differs.

retrieveProxyCollection

public void retrieveProxyCollection(java.lang.Object obj,
                                    ClassDescriptor cld,
                                    CollectionDescriptor cds,
                                    boolean forced)
Retrieve a single Proxied Collection on behalf of obj. The Collection is retrieved only if cascade.retrieve is true or if forced is set to true. *

Parameters:
obj - - the object to be updated
cld - - the ClassDescriptor describing obj
cds - - the CollectionDescriptor describing the collection attribute to be loaded
forced - - if set to true a proxy will be placed, even if cds differs.

getPKQuery

public Query getPKQuery(Identity oid)
Answer the primary key query to retrieve an Object

Parameters:
oid - the Identity of the Object to retrieve
Returns:
The resulting query

retrieveCollections

public void retrieveCollections(java.lang.Object newObj,
                                ClassDescriptor cld,
                                boolean forced)
                         throws PersistenceBrokerException
Retrieve all Collection attributes of a given instance

Parameters:
newObj - the instance to be loaded or refreshed
cld - the ClassDescriptor of the instance
forced - if set to true, loading is forced even if cld differs
Throws:
PersistenceBrokerException

retrieveProxyCollections

public void retrieveProxyCollections(java.lang.Object newObj,
                                     ClassDescriptor cld,
                                     boolean forced)
                              throws PersistenceBrokerException
Retrieve all Collection attributes of a given instance, and make all of the Proxy Collections

Parameters:
newObj - the instance to be loaded or refreshed
cld - the ClassDescriptor of the instance
forced - if set to true, loading is forced even if cld differs
Throws:
PersistenceBrokerException

removePrefetchingListeners

public void removePrefetchingListeners()
remove all prefetching listeners


getClassToPrefetch

public java.lang.Class getClassToPrefetch()


(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