org.apache.ojb.broker.core
Class PersistenceBrokerImpl

java.lang.Object
  extended by org.apache.ojb.broker.core.PersistenceBrokerAbstractImpl
      extended by org.apache.ojb.broker.core.PersistenceBrokerImpl
All Implemented Interfaces:
PBState, PersistenceBroker, PersistenceBrokerInternal, org.apache.ojb.broker.util.configuration.Configurable, ObjectContainer

public class PersistenceBrokerImpl
extends PersistenceBrokerAbstractImpl
implements PBState

The PersistenceBrokerImpl is an implementation of the PersistenceBroker Interface that specifies a persistence mechanism for Java objects. This Concrete implementation provides an object relational mapping and allows to store and retrieve arbitrary objects in/from relational databases accessed by JDBC.

Version:
$Id: PersistenceBrokerImpl.java 365269 2005-12-31 19:03:43Z arminw $
Author:
Thomas Mahler, Leandro Rodrigo Saad Cruz, Matthew Baird, Jakob Braeuchi

Constructor Summary
PersistenceBrokerImpl(PBKey key, PersistenceBrokerFactoryIF pbf)
          Constructor used by PersistenceBrokerFactoryIF implementation.
 
Method Summary
 void abortTransaction()
          Abort and close the transaction.
 void addMtoNImplementor(MtoNImplementor m2n)
          Stores the given m:n implementor int the underlying persistence system.
 void beginTransaction()
          begin a transaction against the underlying RDBMS.
 void checkRefreshRelationships(java.lang.Object obj, Identity oid, ClassDescriptor cld)
          Check if the references of the specified object have enabled the refresh attribute and refresh the reference if set true.
 void clearCache()
          clears the brokers internal cache.
 boolean close()
          Closes this broker so that no further requests may be made on it.
 void commitTransaction()
          Commit and close the transaction.
 java.lang.Object createProxy(java.lang.Class baseClassForProxy, Identity realSubjectsIdentity)
          Creates a proxy instance.
 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 concrete representation of the specified 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 destroy()
          Release all resources used by this class - CAUTION: No further operations can be done with this instance after calling this method.
 java.lang.Object doGetObjectByIdentity(Identity id)
          Internal used method to retrieve object based on Identity.
 ClassDescriptor getClassDescriptor(java.lang.Class clazz)
          returns a ClassDescriptor for the persistence capable class clazz.
 ManageableCollection getCollectionByQuery(java.lang.Class collectionClass, Query query)
          retrieve a collection of type collectionClass matching the Query query
 java.util.Collection getCollectionByQuery(Query query)
          retrieve a collection of itemClass Objects matching the Query query
 int getCount(Query query)
          Returns the number of elements that the given query will return.
 DescriptorRepository getDescriptorRepository()
          Returns the metadata descriptor repository associated with this broker.
 MaterializationCache getInternalCache()
           
 java.util.Iterator getIteratorByQuery(Query query)
          returns an Iterator that iterates Objects of class c if calling the .next() method.
 java.lang.Object getObjectByIdentity(Identity id)
          Retrieve a persistent object from the underlying datastore by its identity.
 java.lang.Object getObjectByQuery(Query query)
          retrieve an Object by query I.e perform a SELECT ...
 PBKey getPBKey()
          Get the PBKey for this broker.
 java.util.Enumeration getPKEnumerationByQuery(java.lang.Class primaryKeyClass, Query query)
          returns an Enumeration of PrimaryKey Objects for objects of class DataClass.
 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)
          Get an Iterator based on the ReportQuery
 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()
          returns true if the broker is currently running a transaction.
 boolean isManaged()
          If true this instance is handled by a managed environment - registered within a JTA transaction.
 void link(java.lang.Object targetObject, ClassDescriptor cld, ObjectReferenceDescriptor rds, java.lang.Object referencedObject, boolean insert)
          Assign FK value to target object by reading PK values of referenced object.
 void linkMtoN(java.lang.Object obj, CollectionDescriptor cod, boolean insert)
          Assign FK values and store entries in indirection table for all objects referenced by given object.
 void linkOneToMany(java.lang.Object obj, CollectionDescriptor cod, boolean insert)
          Assign FK value to all n-side objects referenced by given object.
 void linkOneToOne(java.lang.Object obj, ClassDescriptor cld, ObjectReferenceDescriptor rds, boolean insert)
          Assign FK value of main object with PK values of the reference object.
 Query query()
          factory method to create a new Query object.
 void refresh()
          Lookup the current DescriptorRepository for this class.
 void removeFromCache(java.lang.Object objectOrIdentity)
          Removes the given object or, if it is an instance of Identity, the object identified by it, from the broker's internal cache.
 void retrieveAllReferences(java.lang.Object pInstance)
          Retrieve all References (also Collection-attributes) of a given instance.
 void retrieveReference(java.lang.Object pInstance, java.lang.String pAttributeName)
          retrieve a single reference- or collection attribute of a persistent instance.
 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 setInTransaction(boolean inTransaction)
           
 void setManaged(boolean managed)
          Set true if this instance is registered within a JTA transaction.
 void setPBKey(PBKey key)
           
 void store(java.lang.Object obj)
          Store an Object.
 void store(java.lang.Object obj, Identity oid, ClassDescriptor cld, boolean insert, boolean ignoreReferences)
          Method which start the real store work (insert or update) and is intended for use by top-level api or internal calls.
 void store(java.lang.Object obj, ObjectModification mod)
          Makes object obj persistent in the underlying persistence system.
 void unlinkFK(java.lang.Object targetObject, ClassDescriptor cld, ObjectReferenceDescriptor rds)
          Unkink FK fields of target object.
 void unlinkXtoN(java.lang.Object obj, CollectionDescriptor col)
           
 
Methods inherited from class org.apache.ojb.broker.core.PersistenceBrokerAbstractImpl
addListener, addListener, configure, fireBrokerEvent, fireBrokerEvent, fireBrokerEvent, isTxCheck, removeAllListeners, removeAllListeners, removeListener, setTxCheck
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PersistenceBrokerImpl

public PersistenceBrokerImpl(PBKey key,
                             PersistenceBrokerFactoryIF pbf)
Constructor used by PersistenceBrokerFactoryIF implementation.

Method Detail

getInternalCache

public MaterializationCache getInternalCache()

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

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

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

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

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

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

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

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

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)

isManaged

public boolean isManaged()
If true this instance is handled by a managed environment - registered within a JTA transaction.

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

setManaged

public void setManaged(boolean managed)
Set true if this instance is registered within a JTA transaction. On close() call this flag was reset to false automatic.

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

refresh

public void refresh()
Lookup the current DescriptorRepository for this class. This method is responsible to keep this PB instance in sync with MetadataManager.


destroy

public void destroy()
Release all resources used by this class - CAUTION: No further operations can be done with this instance after calling this method.


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

setPBKey

public void setPBKey(PBKey key)

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
See Also:
PersistenceBroker.close()

abortTransaction

public void abortTransaction()
                      throws TransactionNotInProgressException
Abort and close the transaction. Calling abort abandons all persistent object modifications and releases the associated locks. If transaction is not in progress a TransactionNotInProgressException is thrown

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

beginTransaction

public void beginTransaction()
                      throws TransactionInProgressException,
                             TransactionAbortedException
begin a transaction against the underlying RDBMS. Calling beginTransaction multiple times, without an intervening call to commitTransaction or abortTransaction, causes the exception TransactionInProgressException to be thrown on the second and subsequent calls.

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

commitTransaction

public void commitTransaction()
                       throws TransactionNotInProgressException,
                              TransactionAbortedException
Commit and close the transaction. Calling commit commits to the database all UPDATE, INSERT and DELETE statements called within the transaction and releases any locks held by the transaction. If beginTransaction() has not been called before a TransactionNotInProgressException exception is thrown. If the transaction cannot be commited a TransactionAbortedException exception is thrown.

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

delete

public void delete(java.lang.Object obj,
                   boolean ignoreReferences)
            throws PersistenceBrokerException
Deletes the concrete representation of the specified object in the underlying persistence system. This method is intended for use in top-level api or by internal calls.

Specified by:
delete in interface PersistenceBrokerInternal
Parameters:
obj - The object to delete.
ignoreReferences - With this flag the automatic deletion/unlinking of references can be suppressed (independent of the used auto-delete setting in metadata), except SuperReferenceDescriptor these kind of reference (descriptor) will always be performed. If true all "normal" referenced objects will be ignored, only the specified object is handled.
Throws:
PersistenceBrokerException

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
See Also:
PersistenceBroker.delete(java.lang.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
See Also:
PersistenceBroker.deleteByQuery(Query)

store

public void store(java.lang.Object obj)
           throws PersistenceBrokerException
Store an Object.

Specified by:
store in interface PersistenceBroker
Parameters:
obj - The object to store
Throws:
PersistenceBrokerException
See Also:
PersistenceBroker.store(Object)

store

public void store(java.lang.Object obj,
                  Identity oid,
                  ClassDescriptor cld,
                  boolean insert,
                  boolean ignoreReferences)
Method which start the real store work (insert or update) and is intended for use by top-level api or internal calls.

Specified by:
store in interface PersistenceBrokerInternal
Parameters:
obj - The object to store.
oid - The Identity of the object to store.
cld - The ClassDescriptor of the object.
insert - If true an insert operation will be performed, else update operation.
ignoreReferences - With this flag the automatic storing/linking of references can be suppressed (independent of the used auto-update setting in metadata), except SuperReferenceDescriptor these kind of reference (descriptor) will always be performed. If true all "normal" referenced objects will be ignored, only the specified object is handled.

link

public void link(java.lang.Object targetObject,
                 ClassDescriptor cld,
                 ObjectReferenceDescriptor rds,
                 java.lang.Object referencedObject,
                 boolean insert)
Assign FK value to target object by reading PK values of referenced object.

Parameters:
targetObject - real (non-proxy) target object
cld - ClassDescriptor of the real target object
rds - An ObjectReferenceDescriptor or CollectionDescriptor associated with the real object.
referencedObject - referenced object or proxy
insert - Show if "linking" is done while insert or update.

unlinkFK

public void unlinkFK(java.lang.Object targetObject,
                     ClassDescriptor cld,
                     ObjectReferenceDescriptor rds)
Unkink FK fields of target object.

Parameters:
targetObject - real (non-proxy) target object
cld - ClassDescriptor of the real target object
rds - An ObjectReferenceDescriptor or CollectionDescriptor associated with the real object.

linkOneToOne

public void linkOneToOne(java.lang.Object obj,
                         ClassDescriptor cld,
                         ObjectReferenceDescriptor rds,
                         boolean insert)
Assign FK value of main object with PK values of the reference object.

Parameters:
obj - real object with reference (proxy) object (or real object with set FK values on insert)
cld - ClassDescriptor of the real object
rds - An ObjectReferenceDescriptor of real object.
insert - Show if "linking" is done while insert or update.

linkOneToMany

public void linkOneToMany(java.lang.Object obj,
                          CollectionDescriptor cod,
                          boolean insert)
Assign FK value to all n-side objects referenced by given object.

Parameters:
obj - real object with 1:n reference
cod - CollectionDescriptor of referenced 1:n objects
insert - flag signal insert operation, false signals update operation

linkMtoN

public void linkMtoN(java.lang.Object obj,
                     CollectionDescriptor cod,
                     boolean insert)
Assign FK values and store entries in indirection table for all objects referenced by given object.

Parameters:
obj - real object with 1:n reference
cod - CollectionDescriptor of referenced 1:n objects
insert - flag signal insert operation, false signals update operation

unlinkXtoN

public void unlinkXtoN(java.lang.Object obj,
                       CollectionDescriptor col)

retrieveAllReferences

public void retrieveAllReferences(java.lang.Object pInstance)
                           throws PersistenceBrokerException
Retrieve all References (also Collection-attributes) of a given instance. Loading is forced, even if the collection- and reference-descriptors differ.

Specified by:
retrieveAllReferences in interface PersistenceBroker
Parameters:
pInstance - the persistent instance to work with
Throws:
PersistenceBrokerException

retrieveReference

public void retrieveReference(java.lang.Object pInstance,
                              java.lang.String pAttributeName)
                       throws PersistenceBrokerException
retrieve a single reference- or collection attribute of a persistent instance.

Specified by:
retrieveReference in interface PersistenceBroker
Parameters:
pInstance - the persistent instance
pAttributeName - the name of the Attribute to load
Throws:
PersistenceBrokerException

checkRefreshRelationships

public void checkRefreshRelationships(java.lang.Object obj,
                                      Identity oid,
                                      ClassDescriptor cld)
Check if the references of the specified object have enabled the refresh attribute and refresh the reference if set true.

Specified by:
checkRefreshRelationships in interface PersistenceBrokerInternal
Parameters:
obj - The object to check.
oid - The Identity of the object.
cld - The ClassDescriptor of the object.
Throws:
PersistenceBrokerException - if there is a error refreshing collections or references

getCollectionByQuery

public ManageableCollection getCollectionByQuery(java.lang.Class collectionClass,
                                                 Query query)
                                          throws PersistenceBrokerException
retrieve a collection of type collectionClass matching the Query query

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
See Also:
PersistenceBroker.getCollectionByQuery(Class, Query)

getCollectionByQuery

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

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

getIteratorByQuery

public java.util.Iterator getIteratorByQuery(Query query)
                                      throws PersistenceBrokerException
returns an Iterator that iterates Objects of class c if calling the .next() method. The Elements returned come from a SELECT ... WHERE Statement that is defined by the Query query. If itemProxy is null, no proxies are used.

Specified by:
getIteratorByQuery in interface PersistenceBroker
Parameters:
query - The query
Returns:
The persistent objects matching the query
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

doGetObjectByIdentity

public java.lang.Object doGetObjectByIdentity(Identity id)
                                       throws PersistenceBrokerException
Internal used method to retrieve object based on Identity.

Parameters:
id -
Returns:
Throws:
PersistenceBrokerException

getObjectByQuery

public java.lang.Object getObjectByQuery(Query query)
                                  throws PersistenceBrokerException
retrieve an Object by query I.e perform a SELECT ... FROM ... WHERE ... in an RDBMS

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

getPKEnumerationByQuery

public java.util.Enumeration getPKEnumerationByQuery(java.lang.Class primaryKeyClass,
                                                     Query query)
                                              throws PersistenceBrokerException
returns an Enumeration of PrimaryKey Objects for objects of class DataClass. The Elements returned come from a SELECT ... WHERE Statement that is defined by the fields and their coresponding values of listFields and listValues. Useful for EJB Finder Methods...

Specified by:
getPKEnumerationByQuery in interface PersistenceBroker
Parameters:
primaryKeyClass - the pk class for the searched objects
query - the query
Returns:
The pk enumeration
Throws:
PersistenceBrokerException

store

public void store(java.lang.Object obj,
                  ObjectModification mod)
           throws PersistenceBrokerException
Makes object obj persistent in the underlying persistence system. E.G. by INSERT INTO ... or UPDATE ... in an RDBMS. The ObjectModification parameter can be used to determine whether INSERT or update is to be used. This functionality is typically called from transaction managers, that track which objects have to be stored. If the object is an unmaterialized proxy the method return immediately.

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

isInTransaction

public boolean isInTransaction()
returns true if the broker is currently running a transaction.

Specified by:
isInTransaction in interface PersistenceBroker
Returns:
boolean

setInTransaction

public void setInTransaction(boolean inTransaction)

removeFromCache

public void removeFromCache(java.lang.Object objectOrIdentity)
                     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:
objectOrIdentity - The object to be removed from the cache or its identity
Throws:
PersistenceBrokerException
See Also:
PersistenceBroker.removeFromCache(java.lang.Object)

getClassDescriptor

public ClassDescriptor getClassDescriptor(java.lang.Class clazz)
                                   throws PersistenceBrokerException
returns a ClassDescriptor for the persistence capable class clazz. throws a PersistenceBrokerException if clazz is not persistence capable, i.e. if clazz is not defined in the DescriptorRepository.

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

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

clearCache

public void clearCache()
                throws PersistenceBrokerException
clears the brokers internal cache. removing is recursive. That is referenced Objects are also removed from the cache, if the auto-retrieve flag is set for obj.getClass() in the metadata repository.

Specified by:
clearCache in interface PersistenceBroker
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
See Also:
PersistenceBroker.getTopLevelClass(java.lang.Class)

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
See Also:
PersistenceBroker.getCount(Query)

getReportQueryIteratorByQuery

public java.util.Iterator getReportQueryIteratorByQuery(Query query)
                                                 throws PersistenceBrokerException
Get an Iterator based on the ReportQuery

Specified by:
getReportQueryIteratorByQuery in interface PersistenceBroker
Parameters:
query -
Returns:
Iterator
Throws:
PersistenceBrokerException

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
See Also:
ObjectContainer.query()

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:
DescriptorRepository

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 m2n)
                        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:
m2n - 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 baseClassForProxy,
                                    Identity realSubjectsIdentity)
Creates a proxy instance.

Specified by:
createProxy in interface PersistenceBrokerInternal
Parameters:
baseClassForProxy - The base class that the Proxy should extend. For dynamic Proxies, the method of generation is dependent on the ProxyFactory implementation.
realSubjectsIdentity - The identity of the subject
Returns:
An instance of the proxy subclass
Throws:
PersistenceBrokerException - If there is an error creating the proxy object


(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