|
|||||||||
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
Field Summary | |
protected BrokerHelper |
brokerHelper
|
protected MtoNBroker |
mtoNBroker
|
protected PersistenceBrokerFactoryIF |
pbf
|
protected QueryReferenceBroker |
referencesBroker
|
Fields inherited from class org.apache.ojb.broker.core.PersistenceBrokerAbstractImpl |
AFTER_BEGIN_EVENT, AFTER_COMMIT_EVENT, AFTER_DELETE_EVENT, AFTER_LOOKUP_EVENT, AFTER_OPEN_EVENT, AFTER_ROLLBACK_EVENT, AFTER_STORE_EVENT, AFTER_UPDATE_EVENT, BEFORE_BEGIN_EVENT, BEFORE_CLOSE_EVENT, BEFORE_COMMIT_EVENT, BEFORE_DELETE_EVENT, BEFORE_ROLLBACK_EVENT, BEFORE_STORE_EVENT, BEFORE_UPDATE_EVENT |
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. |
protected void |
finalize()
|
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. |
InternalCache |
getInternalCache()
|
java.util.Iterator |
getIteratorByQuery(Query query)
returns an Iterator that iterates Objects of class c if calling the .next() method. |
protected OJBIterator |
getIteratorFromQuery(Query query,
ClassDescriptor cld)
Get an extent aware Iterator based on the Query |
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. |
BrokerHelper |
serviceBrokerHelper()
Returns the BrokerHelper instance associated with this broker. |
ConnectionManagerIF |
serviceConnectionManager()
Returns the ConnectionManagerIF 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. |
SqlGenerator |
serviceSqlGenerator()
Returns the SqlGenerator instance associated with this broker. |
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,
ObjectModification mod)
makes object obj persistent in the underlying persistence system. |
Methods inherited from class org.apache.ojb.broker.core.PersistenceBrokerAbstractImpl |
addListener, addListener, configure, contains, fireBrokerEvent, fireBrokerEvent, fireBrokerEvent, removeAllListeners, removeAllListeners, removeListener |
Methods inherited from class java.lang.Object |
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected PersistenceBrokerFactoryIF pbf
protected BrokerHelper brokerHelper
protected MtoNBroker mtoNBroker
protected QueryReferenceBroker referencesBroker
Constructor Detail |
public PersistenceBrokerImpl(PBKey key, PersistenceBrokerFactoryIF pbf)
PersistenceBrokerFactoryIF
implementation.
Method Detail |
public InternalCache getInternalCache()
public SqlGenerator serviceSqlGenerator()
PersistenceBroker
SqlGenerator
instance associated with this broker.
serviceSqlGenerator
in interface PersistenceBroker
public StatementManagerIF serviceStatementManager()
PersistenceBroker
StatementManagerIF
instance associated with this broker.
serviceStatementManager
in interface PersistenceBroker
public JdbcAccess serviceJdbcAccess()
PersistenceBroker
JdbcAccess
instance associated with this broker.
serviceJdbcAccess
in interface PersistenceBroker
public ConnectionManagerIF serviceConnectionManager()
PersistenceBroker
ConnectionManagerIF
instance associated with this broker.
serviceConnectionManager
in interface PersistenceBroker
public SequenceManager serviceSequenceManager()
PersistenceBroker
SequenceManager
instance associated with this broker.
serviceSequenceManager
in interface PersistenceBroker
public BrokerHelper serviceBrokerHelper()
PersistenceBroker
BrokerHelper
instance associated with this broker.
Makes some helper methods available.
serviceBrokerHelper
in interface PersistenceBroker
public ObjectCache serviceObjectCache()
PersistenceBroker
ObjectCache
instance associated
with this broker.
serviceObjectCache
in interface PersistenceBroker
public QueryReferenceBroker getReferenceBroker()
public boolean isClosed()
isClosed
in interface PersistenceBroker
public void setClosed(boolean closed)
setClosed
in interface PBState
public 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()
PersistenceBroker
PBKey
for this broker.
getPBKey
in interface PersistenceBroker
public void setPBKey(PBKey key)
public boolean close()
PersistenceBroker
close
in interface PersistenceBroker
PersistenceBroker.close()
public void abortTransaction() throws TransactionNotInProgressException
abortTransaction
in interface PersistenceBroker
TransactionNotInProgressException
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 PersistenceBroker
TransactionInProgressException
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 PersistenceBroker
TransactionNotInProgressException
TransactionAbortedException
public void delete(java.lang.Object obj) throws PersistenceBrokerException
PersistenceBroker
delete
in interface PersistenceBroker
PersistenceBrokerException
PersistenceBroker.delete(java.lang.Object)
public void deleteByQuery(Query query) throws PersistenceBrokerException
PersistenceBroker
deleteByQuery
in interface PersistenceBroker
PersistenceBrokerException
PersistenceBroker.deleteByQuery(Query)
public void store(java.lang.Object obj) throws PersistenceBrokerException
store
in interface PersistenceBroker
PersistenceBrokerException
PersistenceBroker.store(Object)
public void retrieveAllReferences(java.lang.Object pInstance) throws PersistenceBrokerException
retrieveAllReferences
in interface PersistenceBroker
pInstance
- the persistent instance to work with
PersistenceBrokerException
public void retrieveReference(java.lang.Object pInstance, java.lang.String pAttributeName) throws PersistenceBrokerException
retrieveReference
in interface PersistenceBroker
pInstance
- 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 referencespublic ManageableCollection getCollectionByQuery(java.lang.Class collectionClass, Query query) throws PersistenceBrokerException
getCollectionByQuery
in interface PersistenceBroker
PersistenceBrokerException
PersistenceBroker.getCollectionByQuery(Class, Query)
public java.util.Collection getCollectionByQuery(Query query) throws PersistenceBrokerException
getCollectionByQuery
in interface PersistenceBroker
PersistenceBrokerException
public java.util.Iterator getIteratorByQuery(Query query) throws PersistenceBrokerException
getIteratorByQuery
in interface PersistenceBroker
PersistenceBrokerException
protected OJBIterator getIteratorFromQuery(Query query, ClassDescriptor cld) throws PersistenceBrokerException
query
- cld
- the ClassDescriptor
PersistenceBrokerException
public java.lang.Object getObjectByIdentity(Identity id) throws PersistenceBrokerException
PersistenceBroker
getObjectByIdentity
in interface PersistenceBroker
PersistenceBrokerException
public java.lang.Object doGetObjectByIdentity(Identity id) throws PersistenceBrokerException
id
-
PersistenceBrokerException
public java.lang.Object getObjectByQuery(Query query) throws PersistenceBrokerException
getObjectByQuery
in interface PersistenceBroker
PersistenceBrokerException
public java.util.Enumeration getPKEnumerationByQuery(java.lang.Class primaryKeyClass, Query query) throws PersistenceBrokerException
getPKEnumerationByQuery
in interface PersistenceBroker
primaryKeyClass
- the pk class for the searched objectsquery
- the query
PersistenceBrokerException
public void store(java.lang.Object obj, ObjectModification mod) throws PersistenceBrokerException
store
in interface PersistenceBroker
PersistenceBrokerException
public boolean isInTransaction()
isInTransaction
in interface PersistenceBroker
public void removeFromCache(java.lang.Object obj) throws PersistenceBrokerException
PersistenceBroker
Identity
,
the associated object was removed from cache.
removeFromCache
in interface PersistenceBroker
PersistenceBrokerException
PersistenceBroker.removeFromCache(java.lang.Object)
public ClassDescriptor getClassDescriptor(java.lang.Class clazz) throws PersistenceBrokerException
getClassDescriptor
in interface PersistenceBroker
PersistenceBrokerException
public boolean hasClassDescriptor(java.lang.Class clazz)
PersistenceBroker
hasClassDescriptor
in interface PersistenceBroker
clazz
-
public void clearCache() throws PersistenceBrokerException
clearCache
in interface PersistenceBroker
PersistenceBrokerException
public java.lang.Class getTopLevelClass(java.lang.Class clazz) throws PersistenceBrokerException
PersistenceBroker
getTopLevelClass
in interface PersistenceBroker
PersistenceBrokerException
- 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 PersistenceBroker
PersistenceBrokerException
PersistenceBroker.getCount(Query)
public java.util.Iterator getReportQueryIteratorByQuery(Query query) throws PersistenceBrokerException
getReportQueryIteratorByQuery
in interface PersistenceBroker
query
-
PersistenceBrokerException
public Query query()
ObjectContainer
Query
object.
query
in interface ObjectContainer
ObjectContainer.query()
public DescriptorRepository getDescriptorRepository()
PersistenceBroker
DescriptorRepository
associated with this broker.
getDescriptorRepository
in interface PersistenceBroker
protected void finalize()
public void deleteMtoNImplementor(MtoNImplementor m2nImpl) throws PersistenceBrokerException
PersistenceBroker
deleteMtoNImplementor
in interface PersistenceBroker
m2nImpl
-
PersistenceBrokerException
- if an error occoursPersistenceBroker.deleteMtoNImplementor(org.apache.ojb.broker.MtoNImplementor)
public void addMtoNImplementor(MtoNImplementor m2n) throws PersistenceBrokerException
addMtoNImplementor
in interface PersistenceBroker
PersistenceBrokerException
PersistenceBroker.addMtoNImplementor(org.apache.ojb.broker.MtoNImplementor)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |