org.apache.ojb.broker.core
Class DelegatingPersistenceBroker

java.lang.Object
  extended by org.apache.ojb.broker.core.DelegatingPersistenceBroker
All Implemented Interfaces:
PBState, PersistenceBroker, PersistenceBrokerInternal, org.apache.ojb.broker.util.configuration.Configurable, ObjectContainer
Direct Known Subclasses:
PersistenceBrokerHandle, PoolablePersistenceBroker

public class DelegatingPersistenceBroker
extends java.lang.Object
implements PersistenceBrokerInternal, PBState

Delegating implementation of a PersistenceBroker.

Version:
$Id: DelegatingPersistenceBroker.java 364965 2005-09-05 23:37:26Z arminw $
Author:
Armin Waibel

Constructor Summary
DelegatingPersistenceBroker(PersistenceBrokerInternal broker)
           
 
Method Summary
 void abortTransaction()
          Aborts and closes the current transaction.
 void addListener(PBListener listener)
          Adds a temporary PBListener to this broker.
 void addListener(PBListener listener, boolean permanent)
          Adds a temporary or permanent PBListener to this broker, depending on the parameter value.
 void addMtoNImplementor(MtoNImplementor m2nImpl)
          Stores the given m:n implementor int the underlying persistence system.
 void beginTransaction()
          Begins a transaction against the underlying RDBMS.
 void checkRefreshRelationships(java.lang.Object obj, Identity oid, ClassDescriptor cld)
          Refreshes the references of the given object whose refresh is set to true.
 void clearCache()
          Clears the broker's internal cache.
 boolean close()
          Closes this broker so that no further requests may be made on it.
 void commitTransaction()
          Commits and closes the current transaction.
 void configure(org.apache.ojb.broker.util.configuration.Configuration pConfig)
          configure an object using the Configuration pConfig
 java.lang.Object createProxy(java.lang.Class proxyClass, Identity realSubjectsIdentity)
          Shortcut method for creating a proxy of the given type.
 void delete(java.lang.Object obj)
          Deletes the given object's persistent representation in the underlying persistence system.
 void delete(java.lang.Object obj, boolean ignoreReferences)
          Deletes the persistence representation of the given object in the underlying persistence system.
 void deleteByQuery(Query query)
          Deletes all objects matching the given query, from the underlying persistence system.
 void deleteMtoNImplementor(MtoNImplementor m2nImpl)
          Deletes an m:n implementor which defines the relationship between two persistent objects.
 void fireBrokerEvent(PBLifeCycleEvent event)
          Fires a life cycle event to inform all registered PBListener instances.
 void fireBrokerEvent(PBStateEvent event)
          Fires a state event to inform all registered PBListener instances.
 void fireBrokerEvent(PersistenceBrokerEvent event)
          Fires a broker event to inform all registered PBListener instances.
 ClassDescriptor getClassDescriptor(java.lang.Class clazz)
          Returns the class descriptor for the given persistence capable class.
 ManageableCollection getCollectionByQuery(java.lang.Class collectionClass, Query query)
          Retrieves the persistent objects matching the given query.
 java.util.Collection getCollectionByQuery(Query query)
          Retrieves the persistent objects matching the given query.
 int getCount(Query query)
          Returns the number of elements that the given query will return.
 PersistenceBrokerInternal getDelegate()
          Returns only the wrapped PersistenceBroker instance
 DescriptorRepository getDescriptorRepository()
          Returns the metadata descriptor repository associated with this broker.
 PersistenceBroker getInnermostDelegate()
          If my underlying PersistenceBroker is not a DelegatingPersistenceBroker, returns it, otherwise recursively invokes this method on my delegate.
 java.util.Iterator getIteratorByQuery(Query query)
          Retrieves the persistent objects matching the given query and returns them as an iterator which may, depending on the configured collection type, be reloading the objects from the database upon calling Iterator.next().
 java.lang.Object getObjectByIdentity(Identity id)
          Retrieve a persistent object from the underlying datastore by its identity.
 java.lang.Object getObjectByQuery(Query query)
          Retrieve the (first) persistent object from the underlying datastore that matches the given query.
 PBKey getPBKey()
          Get the PBKey for this broker.
 java.util.Enumeration getPKEnumerationByQuery(java.lang.Class primaryKeyClass, Query query)
          Returns an enumeration of objects representing the primary keys for the objects that match the given query.
 ProxyFactory getProxyFactory()
          Return the factory for creating proxies.
 QueryReferenceBroker getReferenceBroker()
          Returns the broker specifically for retrieving references via query.
 RelationshipPrefetcherFactory getRelationshipPrefetcherFactory()
          Return the factory for creating relationship prefetcher objects.
 java.util.Iterator getReportQueryIteratorByQuery(Query query)
          Retrieves the rows (as Object[] instances) matching the given query and returns them as an iterator which may, depending on the configured collection type, be reloading the objects from the database upon calling Iterator.next().
 java.lang.Class getTopLevelClass(java.lang.Class clazz)
          Returns the top level class (most abstract class in terms of extents) from which the given class extends.
 boolean hasClassDescriptor(java.lang.Class clazz)
          Determines whether the given class is persistence capable and thus has an associated class descriptor in the metadata.
 boolean isClosed()
          Determines whether this broker is closed.
 boolean isInTransaction()
          Determines whether there is currently a transaction in progress.
 boolean isManaged()
          Determines whether this instance is handled by a managed environment, i.e. whether it is registered within a JTA transaction.
 Query query()
          factory method to create a new Query object.
 void removeAllListeners()
          Removes all temporary listeners from this broker.
 void removeAllListeners(boolean permanent)
          Removes all temporary and, if desired, permanent listeners from this broker.
 void removeFromCache(java.lang.Object obj)
          Removes the given object or, if it is an instance of Identity, the object identified by it, from the broker's internal cache.
 void removeListener(PBListener listener)
          Removes the specified listener from this broker.
 void retrieveAllReferences(java.lang.Object pInstance)
          Retrieve all references and collections of the given object irrespective of the metadata settings defined for them.
 void retrieveReference(java.lang.Object pInstance, java.lang.String pAttributeName)
          Retrieve the specified reference or collection attribute for the given persistent object.
 BrokerHelper serviceBrokerHelper()
          Returns the BrokerHelper instance associated with this broker, which makes some additional helper methods available.
 ConnectionManagerIF serviceConnectionManager()
          Returns the ConnectionManagerIF instance associated with this broker.
 IdentityFactory serviceIdentity()
          Return the IdentityFactory instance associated with this broker.
 JdbcAccess serviceJdbcAccess()
          Returns the JdbcAccess instance associated with this broker.
 ObjectCache serviceObjectCache()
          Returns the ObjectCache instance associated with this broker.
 SequenceManager serviceSequenceManager()
          Returns the SequenceManager instance associated with this broker.
 org.apache.ojb.broker.accesslayer.sql.SqlGenerator serviceSqlGenerator()
          Returns the SqlGenerator instance associated with this broker.
 StatementManagerIF serviceStatementManager()
          Returns the StatementManagerIF instance associated with this broker.
 void setClosed(boolean closed)
          Is called when the persistence broker is activated or passivated (or closed).
 void setDelegate(PersistenceBrokerInternal broker)
           
 void setManaged(boolean managed)
          Specifies whether this instance is handled by a managed environment, i.e. whether it is registered within a JTA transaction.
 void store(java.lang.Object obj)
          Make the given object persistent in the underlying persistence system.
 void store(java.lang.Object obj, Identity oid, ClassDescriptor cld, boolean insert, boolean ignoreReferences)
          Performs the real store work (insert or update) and is intended for use by top-level apis internally.
 void store(java.lang.Object obj, ObjectModification modification)
          Makes the given object persistent in the underlying persistence system.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DelegatingPersistenceBroker

public DelegatingPersistenceBroker(PersistenceBrokerInternal broker)
Method Detail

getDelegate

public PersistenceBrokerInternal getDelegate()
Returns only the wrapped PersistenceBroker instance


setDelegate

public void setDelegate(PersistenceBrokerInternal broker)

getInnermostDelegate

public PersistenceBroker getInnermostDelegate()
If my underlying PersistenceBroker is not a DelegatingPersistenceBroker, returns it, otherwise recursively invokes this method on my delegate.

Hence this method will return the first delegate that is not a DelegatingPersistenceBroker, or null when no non-DelegatingPersistenceBroker delegate can be found by transversing this chain.

This method is useful when you may have nested DelegatingPersistenceBrokers, and you want to make sure to obtain a "genuine" PersistenceBroker implementaion instance.


isManaged

public boolean isManaged()
Description copied from interface: PersistenceBrokerInternal
Determines whether this instance is handled by a managed environment, i.e. whether it is registered within a JTA transaction.

Specified by:
isManaged in interface PersistenceBrokerInternal
Returns:
true if this broker is managed

setManaged

public void setManaged(boolean managed)
Description copied from interface: PersistenceBrokerInternal
Specifies whether this instance is handled by a managed environment, i.e. whether it is registered within a JTA transaction. Note that on PersistenceBroker.close() this will automatically be reset to false.

Specified by:
setManaged in interface PersistenceBrokerInternal
Parameters:
managed - true if this broker is managed

getReferenceBroker

public QueryReferenceBroker getReferenceBroker()
Description copied from interface: PersistenceBrokerInternal
Returns the broker specifically for retrieving references via query.

Specified by:
getReferenceBroker in interface PersistenceBrokerInternal
Returns:
The query reference broker

checkRefreshRelationships

public void checkRefreshRelationships(java.lang.Object obj,
                                      Identity oid,
                                      ClassDescriptor cld)
Description copied from interface: PersistenceBrokerInternal
Refreshes the references of the given object whose refresh is set to true.

Specified by:
checkRefreshRelationships in interface PersistenceBrokerInternal
Parameters:
obj - The object to check
oid - The identity of the object
cld - The class descriptor for the object

getRelationshipPrefetcherFactory

public RelationshipPrefetcherFactory getRelationshipPrefetcherFactory()
Description copied from interface: PersistenceBrokerInternal
Return the factory for creating relationship prefetcher objects.

Specified by:
getRelationshipPrefetcherFactory in interface PersistenceBrokerInternal
Returns:
The factory

store

public void store(java.lang.Object obj,
                  Identity oid,
                  ClassDescriptor cld,
                  boolean insert,
                  boolean ignoreReferences)
Description copied from interface: PersistenceBrokerInternal
Performs the real store work (insert or update) and is intended for use by top-level apis internally.

Specified by:
store in interface PersistenceBrokerInternal
Parameters:
obj - The object to store
oid - The identity of the object to store
cld - The class descriptor of the object
insert - If true an insert operation will be performed, else update operation
ignoreReferences - Whether automatic storing of contained references/collections (except super-references) shall be suppressed (independent of the auto-update setting in the metadata)

delete

public void delete(java.lang.Object obj,
                   boolean ignoreReferences)
            throws PersistenceBrokerException
Description copied from interface: PersistenceBrokerInternal
Deletes the persistence representation of the given object in the underlying persistence system. This method is intended for use in top-level apis internally.

Specified by:
delete in interface PersistenceBrokerInternal
Parameters:
obj - The object to delete
ignoreReferences - Whether automatic deletion of contained references/collections (except super-references) shall be suppressed (independent of the auto-delete setting in the metadata)
Throws:
PersistenceBrokerException

isInTransaction

public boolean isInTransaction()
                        throws PersistenceBrokerException
Description copied from interface: PersistenceBroker
Determines whether there is currently a transaction in progress.

Specified by:
isInTransaction in interface PersistenceBroker
Returns:
true if there is a transaction in progress
Throws:
PersistenceBrokerException

isClosed

public boolean isClosed()
Description copied from interface: PersistenceBroker
Determines whether this broker is closed.

Specified by:
isClosed in interface PersistenceBroker
Returns:
true if this instance is closed

setClosed

public void setClosed(boolean closed)
Description copied from interface: PBState
Is called when the persistence broker is activated or passivated (or closed).

Specified by:
setClosed in interface PBState
Parameters:
closed - Whether the broker is passivated (closed)

beginTransaction

public void beginTransaction()
                      throws TransactionInProgressException,
                             TransactionAbortedException
Description copied from interface: PersistenceBroker
Begins a transaction against the underlying RDBMS.

Specified by:
beginTransaction in interface PersistenceBroker
Throws:
TransactionInProgressException - If there is already a transaction in progress
TransactionAbortedException

commitTransaction

public void commitTransaction()
                       throws TransactionNotInProgressException,
                              TransactionAbortedException
Description copied from interface: PersistenceBroker
Commits and closes the current transaction. This commits all database-changing statements (e.g. UPDATE, INSERT and DELETE) issued within the transaction since the last commit to the database, and releases any locks held by the transaction.

Specified by:
commitTransaction in interface PersistenceBroker
Throws:
TransactionNotInProgressException - If there is no transaction currently in progress
TransactionAbortedException - If the transaction cannot be committed

abortTransaction

public void abortTransaction()
                      throws TransactionNotInProgressException
Description copied from interface: PersistenceBroker
Aborts and closes the current transaction. This abandons all persistent object modifications and releases the associated locks.

Specified by:
abortTransaction in interface PersistenceBroker
Throws:
TransactionNotInProgressException - If no transaction is currently in progress

close

public boolean close()
Description copied from interface: PersistenceBroker
Closes this broker so that no further requests may be made on it. Closing a broker might release it to the pool of available brokers, or might be garbage collected, at the option of the implementation.

Specified by:
close in interface PersistenceBroker
Returns:
true if the broker was successfully closed

serviceSqlGenerator

public org.apache.ojb.broker.accesslayer.sql.SqlGenerator serviceSqlGenerator()
Description copied from interface: PersistenceBroker
Returns the SqlGenerator instance associated with this broker.

Specified by:
serviceSqlGenerator in interface PersistenceBroker
Returns:
The SQL generator

serviceJdbcAccess

public JdbcAccess serviceJdbcAccess()
Description copied from interface: PersistenceBroker
Returns the JdbcAccess instance associated with this broker.

Specified by:
serviceJdbcAccess in interface PersistenceBroker
Returns:
The JDBC access object

delete

public void delete(java.lang.Object obj)
            throws PersistenceBrokerException
Description copied from interface: PersistenceBroker
Deletes the given object's persistent representation in the underlying persistence system. This is usually done by issuing a DELETE ... in an RDBMS

Specified by:
delete in interface PersistenceBroker
Parameters:
obj - The object to delete
Throws:
PersistenceBrokerException

store

public void store(java.lang.Object obj)
           throws PersistenceBrokerException
Description copied from interface: PersistenceBroker
Make the given object persistent in the underlying persistence system. This is usually done by issuing an INSERT ... or UPDATE ... in an RDBMS.

Specified by:
store in interface PersistenceBroker
Parameters:
obj - The object to store
Throws:
PersistenceBrokerException

store

public void store(java.lang.Object obj,
                  ObjectModification modification)
           throws PersistenceBrokerException
Description copied from interface: PersistenceBroker
Makes the given object persistent in the underlying persistence system. This is usually done by issuing an INSERT ... or UPDATE ... in an RDBMS.

Specified by:
store in interface PersistenceBroker
Parameters:
obj - The object to store
modification - Specifies what operation to perform (for generating optimized SQL)
Throws:
PersistenceBrokerException

getPBKey

public PBKey getPBKey()
Description copied from interface: PersistenceBroker
Get the PBKey for this broker.

Specified by:
getPBKey in interface PersistenceBroker
Returns:
The broker key

removeFromCache

public void removeFromCache(java.lang.Object obj)
                     throws PersistenceBrokerException
Description copied from interface: PersistenceBroker
Removes the given object or, if it is an instance of Identity, the object identified by it, from the broker's internal cache. Note that the removal is not recursive. This means, objects referenced by the removed object will not be automatically removed from the cache by this operation.

Specified by:
removeFromCache in interface PersistenceBroker
Parameters:
obj - The object to be removed from the cache or its identity
Throws:
PersistenceBrokerException

clearCache

public void clearCache()
                throws PersistenceBrokerException
Description copied from interface: PersistenceBroker
Clears the broker's internal cache.

Specified by:
clearCache in interface PersistenceBroker
Throws:
PersistenceBrokerException

getDescriptorRepository

public DescriptorRepository getDescriptorRepository()
Description copied from interface: PersistenceBroker
Returns the metadata descriptor repository associated with this broker.

Specified by:
getDescriptorRepository in interface PersistenceBroker
Returns:
The descriptor repository

removeAllListeners

public void removeAllListeners()
                        throws PersistenceBrokerException
Description copied from interface: PersistenceBroker
Removes all temporary listeners from this broker. Use with care, because some internals rely on this mechanism.

Specified by:
removeAllListeners in interface PersistenceBroker
Throws:
PersistenceBrokerException
See Also:
PersistenceBroker.removeListener(PBListener)

removeAllListeners

public void removeAllListeners(boolean permanent)
                        throws PersistenceBrokerException
Description copied from interface: PersistenceBroker
Removes all temporary and, if desired, permanent listeners from this broker. Use with care, because some internals rely on this mechanism.

Specified by:
removeAllListeners in interface PersistenceBroker
Parameters:
permanent - Whether the listener will stay registered after closing the broker
Throws:
PersistenceBrokerException
See Also:
PersistenceBroker.removeListener(PBListener)

retrieveReference

public void retrieveReference(java.lang.Object pInstance,
                              java.lang.String pAttributeName)
                       throws PersistenceBrokerException
Description copied from interface: PersistenceBroker
Retrieve the specified reference or collection attribute for the given persistent object.

Specified by:
retrieveReference in interface PersistenceBroker
Parameters:
pInstance - The persistent object
pAttributeName - The name of the attribute to retrieve
Throws:
PersistenceBrokerException

retrieveAllReferences

public void retrieveAllReferences(java.lang.Object pInstance)
                           throws PersistenceBrokerException
Description copied from interface: PersistenceBroker
Retrieve all references and collections of the given object irrespective of the metadata settings defined for them.

Specified by:
retrieveAllReferences in interface PersistenceBroker
Parameters:
pInstance - The persistent object
Throws:
PersistenceBrokerException

serviceConnectionManager

public ConnectionManagerIF serviceConnectionManager()
Description copied from interface: PersistenceBroker
Returns the ConnectionManagerIF instance associated with this broker.

Specified by:
serviceConnectionManager in interface PersistenceBroker
Returns:
The connection manager

serviceStatementManager

public StatementManagerIF serviceStatementManager()
Description copied from interface: PersistenceBroker
Returns the StatementManagerIF instance associated with this broker.

Specified by:
serviceStatementManager in interface PersistenceBroker
Returns:
The statement manager

serviceSequenceManager

public SequenceManager serviceSequenceManager()
Description copied from interface: PersistenceBroker
Returns the SequenceManager instance associated with this broker.

Specified by:
serviceSequenceManager in interface PersistenceBroker
Returns:
The sequence manager

serviceBrokerHelper

public BrokerHelper serviceBrokerHelper()
Description copied from interface: PersistenceBroker
Returns the BrokerHelper instance associated with this broker, which makes some additional helper methods available.

Specified by:
serviceBrokerHelper in interface PersistenceBroker
Returns:
The broker helper object

serviceObjectCache

public ObjectCache serviceObjectCache()
Description copied from interface: PersistenceBroker
Returns the ObjectCache instance associated with this broker.

Specified by:
serviceObjectCache in interface PersistenceBroker
Returns:
The object cache

serviceIdentity

public IdentityFactory serviceIdentity()
Description copied from interface: PersistenceBroker
Return the IdentityFactory instance associated with this broker.

Specified by:
serviceIdentity in interface PersistenceBroker
Returns:
The identity factory

fireBrokerEvent

public void fireBrokerEvent(PersistenceBrokerEvent event)
Description copied from interface: PersistenceBroker
Fires a broker event to inform all registered PBListener instances.

Specified by:
fireBrokerEvent in interface PersistenceBroker
Parameters:
event - The event to fire

fireBrokerEvent

public void fireBrokerEvent(PBLifeCycleEvent event)
Description copied from interface: PersistenceBroker
Fires a life cycle event to inform all registered PBListener instances.

Specified by:
fireBrokerEvent in interface PersistenceBroker
Parameters:
event - The event to fire

fireBrokerEvent

public void fireBrokerEvent(PBStateEvent event)
Description copied from interface: PersistenceBroker
Fires a state event to inform all registered PBListener instances.

Specified by:
fireBrokerEvent in interface PersistenceBroker
Parameters:
event - The event to fire

addListener

public void addListener(PBListener listener)
                 throws PersistenceBrokerException
Description copied from interface: PersistenceBroker
Adds a temporary PBListener to this broker. Note that temporary listeners will be removed upon closing a broker (returning it to the pool).

Specified by:
addListener in interface PersistenceBroker
Parameters:
listener - The listener to add
Throws:
PersistenceBrokerException
See Also:
PersistenceBroker.addListener(PBListener, boolean)

addListener

public void addListener(PBListener listener,
                        boolean permanent)
                 throws PersistenceBrokerException
Description copied from interface: PersistenceBroker
Adds a temporary or permanent PBListener to this broker, depending on the parameter value. Note that temporary listeners will be removed upon closing a broker (returning it to the pool).
NOTE: Handle carefully when using this method, keep in mind you don't know which broker instance will be returned next time from the pool! To guarantee that a listener is connect to every broker, the best way is to define your own implementation of PersistenceBrokerFactoryIF or extend the default one, PersistenceBrokerFactoryDefaultImpl. There you can add the listener at creation of the PersistenceBroker instances.

Specified by:
addListener in interface PersistenceBroker
Parameters:
listener - The listener to add
permanent - Whether the listener will stay registered after closing the broker
Throws:
PersistenceBrokerException

removeListener

public void removeListener(PBListener listener)
                    throws PersistenceBrokerException
Description copied from interface: PersistenceBroker
Removes the specified listener from this broker.

Specified by:
removeListener in interface PersistenceBroker
Parameters:
listener - The listener to remove
Throws:
PersistenceBrokerException

getTopLevelClass

public java.lang.Class getTopLevelClass(java.lang.Class clazz)
                                 throws PersistenceBrokerException
Description copied from interface: PersistenceBroker
Returns the top level class (most abstract class in terms of extents) from which the given class extends. This may be a (abstract) base-class, an interface or the given class itself, if no extent is defined.

Specified by:
getTopLevelClass in interface PersistenceBroker
Parameters:
clazz - The class to get the top level class for
Returns:
The top level class for it
Throws:
PersistenceBrokerException - If the class is not persistence capable, if no metadata was defined for this class

hasClassDescriptor

public boolean hasClassDescriptor(java.lang.Class clazz)
Description copied from interface: PersistenceBroker
Determines whether the given class is persistence capable and thus has an associated class descriptor in the metadata.

Specified by:
hasClassDescriptor in interface PersistenceBroker
Parameters:
clazz - The target class
Returns:
true if a class descriptor was found

getClassDescriptor

public ClassDescriptor getClassDescriptor(java.lang.Class clazz)
                                   throws PersistenceBrokerException
Description copied from interface: PersistenceBroker
Returns the class descriptor for the given persistence capable class.

Specified by:
getClassDescriptor in interface PersistenceBroker
Parameters:
clazz - The target class
Returns:
The class descriptor
Throws:
PersistenceBrokerException - If the class is not persistence capable, i.e. if no metadata was defined for this class and hence its class descriptor was not found

getPKEnumerationByQuery

public java.util.Enumeration getPKEnumerationByQuery(java.lang.Class primaryKeyClass,
                                                     Query query)
                                              throws PersistenceBrokerException
Description copied from interface: PersistenceBroker
Returns an enumeration of objects representing the primary keys for the objects that match the given query. Mainly useful for EJB Finder Methods.
Note: This method is not yet aware of extents!

Specified by:
getPKEnumerationByQuery in interface PersistenceBroker
Parameters:
primaryKeyClass - The class to use for the primary keys
query - The query
Returns:
The pk enumeration
Throws:
PersistenceBrokerException

getObjectByQuery

public java.lang.Object getObjectByQuery(Query query)
                                  throws PersistenceBrokerException
Description copied from interface: PersistenceBroker
Retrieve the (first) persistent object from the underlying datastore that matches the given query.

Specified by:
getObjectByQuery in interface PersistenceBroker
Parameters:
query - The query
Returns:
The persistent object
Throws:
PersistenceBrokerException

getObjectByIdentity

public java.lang.Object getObjectByIdentity(Identity id)
                                     throws PersistenceBrokerException
Description copied from interface: PersistenceBroker
Retrieve a persistent object from the underlying datastore by its identity. However, users are encouraged to use PersistenceBroker.getObjectByQuery(Query) instead, as this method is mainly intended to be used for internal handling of materialization by OID (e.g. in Proxies).

Specified by:
getObjectByIdentity in interface PersistenceBroker
Parameters:
id - The persistent object's id
Returns:
The persistent object
Throws:
PersistenceBrokerException

getReportQueryIteratorByQuery

public java.util.Iterator getReportQueryIteratorByQuery(Query query)
                                                 throws PersistenceBrokerException
Description copied from interface: PersistenceBroker
Retrieves the rows (as Object[] instances) matching the given query and returns them as an iterator which may, depending on the configured collection type, be reloading the objects from the database upon calling Iterator.next().

Specified by:
getReportQueryIteratorByQuery in interface PersistenceBroker
Parameters:
query - The report query
Returns:
The rows matching the query
Throws:
PersistenceBrokerException

getIteratorByQuery

public java.util.Iterator getIteratorByQuery(Query query)
                                      throws PersistenceBrokerException
Description copied from interface: PersistenceBroker
Retrieves the persistent objects matching the given query and returns them as an iterator which may, depending on the configured collection type, be reloading the objects from the database upon calling Iterator.next(). Note that if the Query has no criteria ALL persistent objects of the class targeted by the query will be returned.

Specified by:
getIteratorByQuery in interface PersistenceBroker
Parameters:
query - The query
Returns:
The persistent objects matching the query
Throws:
PersistenceBrokerException

getCollectionByQuery

public ManageableCollection getCollectionByQuery(java.lang.Class collectionClass,
                                                 Query query)
                                          throws PersistenceBrokerException
Description copied from interface: PersistenceBroker
Retrieves the persistent objects matching the given query. The resulting collection will be of the supplied collection type. Note that if the Query has no criteria ALL persistent objects of the class targeted by the query will be returned.

Specified by:
getCollectionByQuery in interface PersistenceBroker
Parameters:
collectionClass - The collection type which needs to implement ManageableCollection
query - The query
Returns:
The persistent objects matching the query
Throws:
PersistenceBrokerException

getCount

public int getCount(Query query)
             throws PersistenceBrokerException
Description copied from interface: PersistenceBroker
Returns the number of elements that the given query will return.

Specified by:
getCount in interface PersistenceBroker
Parameters:
query - The query
Returns:
The number of elements returned by the query
Throws:
PersistenceBrokerException

getCollectionByQuery

public java.util.Collection getCollectionByQuery(Query query)
                                          throws PersistenceBrokerException
Description copied from interface: PersistenceBroker
Retrieves the persistent objects matching the given query. Note that if the Query has no criteria ALL persistent objects of the class targeted by the query will be returned.

Specified by:
getCollectionByQuery in interface PersistenceBroker
Parameters:
query - The query
Returns:
The persistent objects matching the query
Throws:
PersistenceBrokerException

configure

public void configure(org.apache.ojb.broker.util.configuration.Configuration pConfig)
               throws org.apache.ojb.broker.util.configuration.ConfigurationException
Description copied from interface: org.apache.ojb.broker.util.configuration.Configurable
configure an object using the Configuration pConfig

Specified by:
configure in interface org.apache.ojb.broker.util.configuration.Configurable
Parameters:
pConfig - the Configuration object used to configure current instance
Throws:
org.apache.ojb.broker.util.configuration.ConfigurationException

query

public Query query()
Description copied from interface: ObjectContainer
factory method to create a new Query object.

Specified by:
query in interface ObjectContainer
Returns:
a new Query object

deleteByQuery

public void deleteByQuery(Query query)
                   throws PersistenceBrokerException
Description copied from interface: PersistenceBroker
Deletes all objects matching the given query, from the underlying persistence system. This is usually done via DELETE ... in an RDBMS.
Note: This method directly perform the delete statement ignoring any object references and does not synchronize the cache - take care!

Specified by:
deleteByQuery in interface PersistenceBroker
Parameters:
query - The query determining the objects to delete
Throws:
PersistenceBrokerException

deleteMtoNImplementor

public void deleteMtoNImplementor(MtoNImplementor m2nImpl)
                           throws PersistenceBrokerException
Description copied from interface: PersistenceBroker
Deletes an m:n implementor which defines the relationship between two persistent objects. This is usually a row in an indirection table.
Note that OJB currently doesn't handle collection inheritance, so collections descriptors are written per class. We try to match one of these collection descriptors, iterating from the left side and looking for possible for classes on the right side using isAssignableFrom(rightClass). TODO: handle cache problems TODO: delete more than one row if possible

Specified by:
deleteMtoNImplementor in interface PersistenceBroker
Parameters:
m2nImpl - The m:n implementor to delete
Throws:
PersistenceBrokerException
See Also:
PersistenceBroker.deleteMtoNImplementor(org.apache.ojb.broker.MtoNImplementor)

addMtoNImplementor

public void addMtoNImplementor(MtoNImplementor m2nImpl)
                        throws PersistenceBrokerException
Description copied from interface: PersistenceBroker
Stores the given m:n implementor int the underlying persistence system. This is usually done by inserting a row in an indirection table.
Note that OJB currently doesn't handle collection inheritance, so collections descriptors are written per class. We try to match one of these collection descriptors, iterating from the left side and looking for possible for classes on the right side using isAssignableFrom(rightClass).

Specified by:
addMtoNImplementor in interface PersistenceBroker
Parameters:
m2nImpl - The m:n implementor to delete
Throws:
PersistenceBrokerException
See Also:
PersistenceBroker.addMtoNImplementor(org.apache.ojb.broker.MtoNImplementor)

getProxyFactory

public ProxyFactory getProxyFactory()
Description copied from interface: PersistenceBrokerInternal
Return the factory for creating proxies.

Specified by:
getProxyFactory in interface PersistenceBrokerInternal
Returns:
The factory

createProxy

public java.lang.Object createProxy(java.lang.Class proxyClass,
                                    Identity realSubjectsIdentity)
Description copied from interface: PersistenceBrokerInternal
Shortcut method for creating a proxy of the given type.

Specified by:
createProxy in interface PersistenceBrokerInternal
Parameters:
proxyClass - The proxy type
realSubjectsIdentity - The identity of the real subject
Returns:
The proxy


(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