|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.ojb.broker.core.PersistenceBrokerAbstractImpl
org.apache.ojb.broker.core.PersistenceBrokerImpl
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.
for a sample application| 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)
|
void |
beginTransaction()
begin a transaction against the underlying RDBMS. |
void |
clearCache()
clears the brokers internal cache. |
boolean |
close()
Close this PersistenceBroker so that no further requests may be made on it. |
void |
commitTransaction()
Commit and close the transaction. |
void |
delete(java.lang.Object obj)
deletes the objects obj concrete representation in the underlying persistence system. |
void |
deleteByQuery(Query query)
Deletes all objects matching the query from the underlying persistence system. |
void |
deleteMtoNImplementor(MtoNImplementor m2nImpl)
Deletes and MtoN implementor (a row on a indirection table) As it is today, ojb doesn't handle collection inherence, so collections descriptors are written per class. |
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 count of elements a given query will return. |
DescriptorRepository |
getDescriptorRepository()
Returns the DescriptorRepository
associated with this broker. |
org.apache.ojb.broker.cache.InternalCache |
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 an Object 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. |
QueryReferenceBroker |
getReferenceBroker()
|
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 (extent) class to which the given class belongs. |
boolean |
hasClassDescriptor(java.lang.Class clazz)
same as getClassDescriptor, but does not throw. |
boolean |
isClosed()
|
boolean |
isInTransaction()
returns true if the broker is currently running a transaction. |
Query |
query()
factory method to create a new Query object. |
void |
refresh()
Lookup the current DescriptorRepository for
this class. |
void |
refreshRelationships(java.lang.Object obj,
ClassDescriptor cld)
Refresh Relationships |
void |
removeFromCache(java.lang.Object obj)
Removes the object from the brokers 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. |
org.apache.ojb.broker.util.BrokerHelper |
serviceBrokerHelper()
Returns the BrokerHelper instance associated with this broker. |
org.apache.ojb.broker.accesslayer.ConnectionManagerIF |
serviceConnectionManager()
Returns the ConnectionManagerIF instance associated with this broker. |
org.apache.ojb.broker.accesslayer.JdbcAccess |
serviceJdbcAccess()
Returns the JdbcAccess instance associated with this broker. |
org.apache.ojb.broker.cache.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. |
org.apache.ojb.broker.accesslayer.StatementManagerIF |
serviceStatementManager()
Returns the StatementManagerIF instance associated with this broker. |
void |
setClosed(boolean closed)
|
void |
setPBKey(PBKey key)
|
void |
store(java.lang.Object obj)
Store an Object |
void |
store(java.lang.Object obj,
org.apache.ojb.broker.util.ObjectModification mod)
makes object obj persistent in the underlying persistence system. |
| Methods inherited from class org.apache.ojb.broker.core.PersistenceBrokerAbstractImpl |
addListener, addListener, configure, fireBrokerEvent, fireBrokerEvent, fireBrokerEvent, removeAllListeners, removeAllListeners, removeListener |
| Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public PersistenceBrokerImpl(PBKey key,
PersistenceBrokerFactoryIF pbf)
PersistenceBrokerFactoryIF implementation.
| Method Detail |
public org.apache.ojb.broker.cache.InternalCache getInternalCache()
public org.apache.ojb.broker.accesslayer.sql.SqlGenerator serviceSqlGenerator()
PersistenceBrokerSqlGenerator instance associated with this broker.
serviceSqlGenerator in interface PersistenceBrokerpublic org.apache.ojb.broker.accesslayer.StatementManagerIF serviceStatementManager()
PersistenceBrokerStatementManagerIF instance associated with this broker.
serviceStatementManager in interface PersistenceBrokerpublic org.apache.ojb.broker.accesslayer.JdbcAccess serviceJdbcAccess()
PersistenceBrokerJdbcAccess instance associated with this broker.
serviceJdbcAccess in interface PersistenceBrokerpublic org.apache.ojb.broker.accesslayer.ConnectionManagerIF serviceConnectionManager()
PersistenceBrokerConnectionManagerIF instance associated with this broker.
serviceConnectionManager in interface PersistenceBrokerpublic SequenceManager serviceSequenceManager()
PersistenceBrokerSequenceManager instance associated with this broker.
serviceSequenceManager in interface PersistenceBrokerpublic org.apache.ojb.broker.util.BrokerHelper serviceBrokerHelper()
PersistenceBrokerBrokerHelper instance associated with this broker.
Makes some helper methods available.
serviceBrokerHelper in interface PersistenceBrokerpublic org.apache.ojb.broker.cache.ObjectCache serviceObjectCache()
PersistenceBrokerObjectCache instance associated
with this broker.
serviceObjectCache in interface PersistenceBrokerpublic QueryReferenceBroker getReferenceBroker()
public boolean isClosed()
isClosed in interface PersistenceBrokerpublic void setClosed(boolean closed)
setClosed in interface PBStatepublic void refresh()
DescriptorRepository for
this class. This method is responsible to keep this
PB instance in sync with MetadataManager.
public void destroy()
public PBKey getPBKey()
PersistenceBrokerPBKey for this broker.
getPBKey in interface PersistenceBrokerpublic void setPBKey(PBKey key)
public boolean close()
PersistenceBroker
close in interface PersistenceBrokerPersistenceBroker.close()
public void abortTransaction()
throws TransactionNotInProgressException
abortTransaction in interface PersistenceBrokerTransactionNotInProgressException
public void beginTransaction()
throws TransactionInProgressException,
TransactionAbortedException
beginTransaction multiple times,
without an intervening call to commitTransaction or abortTransaction,
causes the exception TransactionInProgressException to be thrown
on the second and subsequent calls.
beginTransaction in interface PersistenceBrokerTransactionInProgressException
TransactionAbortedException
public void commitTransaction()
throws TransactionNotInProgressException,
TransactionAbortedException
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.
commitTransaction in interface PersistenceBrokerTransactionNotInProgressException
TransactionAbortedException
public void delete(java.lang.Object obj)
throws PersistenceBrokerException
PersistenceBroker
delete in interface PersistenceBrokerPersistenceBrokerExceptionPersistenceBroker.delete(java.lang.Object)
public void deleteByQuery(Query query)
throws PersistenceBrokerException
PersistenceBroker
deleteByQuery in interface PersistenceBrokerPersistenceBrokerExceptionPersistenceBroker.deleteByQuery(Query)
public void store(java.lang.Object obj)
throws PersistenceBrokerException
store in interface PersistenceBrokerPersistenceBrokerExceptionPersistenceBroker.store(Object)
public void retrieveAllReferences(java.lang.Object pInstance)
throws PersistenceBrokerException
retrieveAllReferences in interface PersistenceBrokerpInstance - the persistent instance to work with
PersistenceBrokerException
public void retrieveReference(java.lang.Object pInstance,
java.lang.String pAttributeName)
throws PersistenceBrokerException
retrieveReference in interface PersistenceBrokerpInstance - the persistent instancepAttributeName - the name of the Attribute to load
PersistenceBrokerException
public void refreshRelationships(java.lang.Object obj,
ClassDescriptor cld)
obj - cld -
PersistenceBrokerException - if there is a error refreshing collections or references
public ManageableCollection getCollectionByQuery(java.lang.Class collectionClass,
Query query)
throws PersistenceBrokerException
getCollectionByQuery in interface PersistenceBrokerPersistenceBrokerExceptionPersistenceBroker.getCollectionByQuery(Class, Query)
public java.util.Collection getCollectionByQuery(Query query)
throws PersistenceBrokerException
getCollectionByQuery in interface PersistenceBrokerPersistenceBrokerException
public java.util.Iterator getIteratorByQuery(Query query)
throws PersistenceBrokerException
getIteratorByQuery in interface PersistenceBrokerPersistenceBrokerException
public java.lang.Object getObjectByIdentity(Identity id)
throws PersistenceBrokerException
PersistenceBroker
getObjectByIdentity in interface PersistenceBrokerPersistenceBrokerException
public java.lang.Object doGetObjectByIdentity(Identity id)
throws PersistenceBrokerException
id -
PersistenceBrokerException
public java.lang.Object getObjectByQuery(Query query)
throws PersistenceBrokerException
getObjectByQuery in interface PersistenceBrokerPersistenceBrokerException
public java.util.Enumeration getPKEnumerationByQuery(java.lang.Class primaryKeyClass,
Query query)
throws PersistenceBrokerException
getPKEnumerationByQuery in interface PersistenceBrokerprimaryKeyClass - the pk class for the searched objectsquery - the query
PersistenceBrokerException
public void store(java.lang.Object obj,
org.apache.ojb.broker.util.ObjectModification mod)
throws PersistenceBrokerException
store in interface PersistenceBrokerPersistenceBrokerExceptionpublic boolean isInTransaction()
isInTransaction in interface PersistenceBroker
public void removeFromCache(java.lang.Object obj)
throws PersistenceBrokerException
PersistenceBrokerIdentity,
the associated object was removed from cache.
removeFromCache in interface PersistenceBrokerPersistenceBrokerExceptionPersistenceBroker.removeFromCache(java.lang.Object)
public ClassDescriptor getClassDescriptor(java.lang.Class clazz)
throws PersistenceBrokerException
getClassDescriptor in interface PersistenceBrokerPersistenceBrokerExceptionpublic boolean hasClassDescriptor(java.lang.Class clazz)
PersistenceBroker
hasClassDescriptor in interface PersistenceBrokerclazz -
public void clearCache()
throws PersistenceBrokerException
clearCache in interface PersistenceBrokerPersistenceBrokerException
public java.lang.Class getTopLevelClass(java.lang.Class clazz)
throws PersistenceBrokerException
PersistenceBroker
getTopLevelClass in interface PersistenceBrokerPersistenceBrokerException - if clazz is not persistence capable,
i.e. if clazz is not defined in the DescriptorRepository.PersistenceBroker.getTopLevelClass(java.lang.Class)
public int getCount(Query query)
throws PersistenceBrokerException
PersistenceBroker
getCount in interface PersistenceBrokerPersistenceBrokerExceptionPersistenceBroker.getCount(Query)
public java.util.Iterator getReportQueryIteratorByQuery(Query query)
throws PersistenceBrokerException
getReportQueryIteratorByQuery in interface PersistenceBrokerquery -
PersistenceBrokerExceptionpublic Query query()
ObjectContainerQuery object.
query in interface ObjectContainerObjectContainer.query()public DescriptorRepository getDescriptorRepository()
PersistenceBrokerDescriptorRepository
associated with this broker.
getDescriptorRepository in interface PersistenceBroker
public void deleteMtoNImplementor(MtoNImplementor m2nImpl)
throws PersistenceBrokerException
PersistenceBroker
deleteMtoNImplementor in interface PersistenceBrokerm2nImpl -
PersistenceBrokerException - if an error occoursPersistenceBroker.deleteMtoNImplementor(org.apache.ojb.broker.MtoNImplementor)
public void addMtoNImplementor(MtoNImplementor m2n)
throws PersistenceBrokerException
addMtoNImplementor in interface PersistenceBrokerPersistenceBrokerExceptionPersistenceBroker.addMtoNImplementor(org.apache.ojb.broker.MtoNImplementor)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||