|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Object | +--uk.ac.ebi.intact.persistence.ObjectBridgeDAO
This class provides an ObjectBridge-specific Data Access Object, which effectively wraps up an ObjectBridge broker object. Note that this DAO only provides a wrapped object from the ObjectBridge kernel, NOT the ODMG interface.
| Field Summary | |
static java.lang.String |
OJB_LOGGER_NAME
|
| Constructor Summary | |
ObjectBridgeDAO(org.apache.ojb.broker.PersistenceBroker broker)
|
|
| Method Summary | |
void |
addCachedClass(java.lang.Class clazz)
adds a class to a set of classes that should be cached. |
void |
begin(int txType)
Used to begin a transaction. |
void |
clearCache()
wipe the whole cache. |
void |
close()
closes a DAO (connection). |
void |
closeResults(java.util.Iterator itemIterator)
Method to release result resources (eg result set). |
void |
commit()
Commits (finishes) a transaction. |
void |
create(java.lang.Object obj)
creates a single object in persistent store. |
java.util.Collection |
find(java.lang.Object obj)
This method performs an object-based search. |
java.util.Collection |
find(java.lang.String type,
java.lang.String col,
java.lang.String val)
This method searches the DB based on the information in the parameters. |
java.util.Collection |
findBySQL(java.lang.String type,
java.lang.String sqlString)
This method allows submission of a query by straight SQL string. |
java.util.Iterator |
findColumnValues(java.lang.String type,
java.lang.String[] cols)
This method provides a means of obtaining particular values of a persistent object without retrieving the whole object itself. |
java.lang.String |
getDbName()
Provides the database name that is being connected to. |
java.lang.String |
getDbUserName()
Provides the user name that is connecting to the DB. |
java.sql.Connection |
getJDBCConnection()
Method to get a direct SQL connection which can be used by JDBC |
boolean |
isActive()
checks to see if a transaction is currently in progress. |
boolean |
isAutoSave()
checks to see if object saving automatically is turned on |
boolean |
isCachedClass(java.lang.Class clazz)
|
boolean |
isClosed()
checks to see if a transaction is closed. |
boolean |
isPersistent(java.lang.Object obj)
checks to determine if a given object is persistent or not |
boolean |
isUserValid(java.lang.String userName,
java.lang.String password)
validates a username and password against the datastore. |
java.util.Iterator |
iteratorFind(java.lang.String type,
java.lang.String col,
java.lang.String val)
This method provides a means to obtain an Iterator for search results. |
void |
lock(java.lang.Object obj)
Locks the specified object to a transaction for WRITE. |
void |
makePersistent(java.util.Collection objs)
This method performs a simple creation for a number of objects. |
void |
open()
opens a DAO (connection). |
void |
remove(java.lang.Object obj)
removes an object from persistent store. |
void |
removeFromCache(java.lang.Object obj)
Removes the given object from the cachce; hence, cancelling any changes to the object. |
void |
resetUserInfo(java.lang.String user,
java.lang.String password)
changes the username and password details used for connection. |
void |
rollback()
rollback a transaction. |
void |
setAutoSave(boolean val)
sets whether or not auto saving is turned on |
void |
setLogger(org.apache.log4j.Logger p)
allows a logging destination to be specified |
void |
update(java.lang.Object obj)
updates a given object which was oroginally obtained in another transaction. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
public static final java.lang.String OJB_LOGGER_NAME
| Constructor Detail |
public ObjectBridgeDAO(org.apache.ojb.broker.PersistenceBroker broker)
| Method Detail |
public void closeResults(java.util.Iterator itemIterator)
closeResults in interface DAOitemIterator - The iterator over the results (should be obtained from iteratorFind)
java.lang.IllegalArgumentException - thrown if the Iterator is an invalid type
public void resetUserInfo(java.lang.String user,
java.lang.String password)
user - the new usernamepassword - the new user passwordpublic void addCachedClass(java.lang.Class clazz)
DAO
addCachedClass in interface DAOclazz - class to be cachedpublic boolean isCachedClass(java.lang.Class clazz)
public void clearCache()
throws org.apache.ojb.broker.PersistenceBrokerException
DAO
clearCache in interface DAOorg.apache.ojb.broker.PersistenceBrokerExceptionpublic void setLogger(org.apache.log4j.Logger p)
DAO
setLogger in interface DAOp - A PrintWriter for logging output
public boolean isUserValid(java.lang.String userName,
java.lang.String password)
isUserValid in interface DAO
public java.lang.String getDbName()
throws org.apache.ojb.broker.accesslayer.LookupException,
java.sql.SQLException
getDbName in interface DAOorg.apache.ojb.broker.accesslayer.LookupException - thrown on error
getting the Connection
java.sql.SQLException - thrown if the metatdata can't be obtained
public java.lang.String getDbUserName()
throws org.apache.ojb.broker.accesslayer.LookupException,
java.sql.SQLException
getDbUserName in interface DAOorg.apache.ojb.broker.accesslayer.LookupException - thrown on error
getting the Connection
java.sql.SQLException - thrown if the metatdata can't be obtained
public java.sql.Connection getJDBCConnection()
throws org.apache.ojb.broker.accesslayer.LookupException
org.apache.ojb.broker.accesslayer.LookupException
public void begin(int txType)
throws TransactionException
begin in interface DAOtxType - The type of transaction to begin (JDBC or object)
TransactionException - - can be thrown if a transaction is already in progressBusinessConstants
public void lock(java.lang.Object obj)
throws org.odmg.TransactionNotInProgressException
lock in interface DAOobj - The object to lock for write.
org.odmg.TransactionNotInProgressException - thrown if no object TX is running
public void close()
throws DataSourceException
close in interface DAODataSourceException - - thrown if the DAO cannot be closed (details in specific errors)
public void open()
throws DataSourceException
open in interface DAODataSourceException - - thrown if the DAO cannot be closed (details in specific errors)
public void commit()
throws TransactionException
commit in interface DAOTransactionException - - thrown if, say, a transaction was not in progress for example
public void create(java.lang.Object obj)
throws CreateException
create in interface DAOobj - - the object to be saved
CreateExceptionpublic void removeFromCache(java.lang.Object obj)
DAO
removeFromCache in interface DAOobj - the object to remove from the cache.
public void update(java.lang.Object obj)
throws UpdateException
DAOupdates a given object which was oroginally obtained in
another transaction. This allows, for example, objects to be read
from persistent store in one transaction, modified elsewhere (eg via
a user interface object) and then have the changes reflected in persistent
store within the context of a
update in interface DAOobj - - the object to be updated
UpdateException - - thrown if the object could not me modified
(eg called outside a transaction scope) or hasn't been persisted previously (
DAO.isPersistent(Object) must return true).DAO.update(Object)public boolean isActive()
isActive in interface DAOpublic boolean isAutoSave()
isAutoSave in interface DAOpublic void setAutoSave(boolean val)
setAutoSave in interface DAOval - - true to turn on, false for offpublic boolean isClosed()
isClosed in interface DAOpublic boolean isPersistent(java.lang.Object obj)
isPersistent in interface DAOobj - - the object to be checked
public void remove(java.lang.Object obj)
throws TransactionException
remove in interface DAOobj - - the object to be removed
TransactionException - - thrown usually if the operation is called outside a transaction
public void rollback()
throws TransactionException
rollback in interface DAOTransactionException - - thrown if the transaction couldn't be rolled back
public void makePersistent(java.util.Collection objs)
throws CreateException,
TransactionException
makePersistent in interface DAOobjs - - the collection of objects to be persisted
CreateException - - thrown if an object could not be stored
TransactionException - - thrown if errors resulted from invalid transaction operations or errors
public java.util.Collection find(java.lang.String type,
java.lang.String col,
java.lang.String val)
throws SearchException
This method searches the DB based on the information in the parameters. Note that this only supports a single parameter (simple) search at present - bulk searches are TBD
find in interface DAOtype - - the class name (ie table) to be searchedcol - - the parameter (column name) to search on (usually ac number or name)val - - the value of the search parameter. If null, then all items matching the class name will be returned
SearchException - - thrown for errors during the search process, eg query problems
java.lang.NullPointerException - thrown if the type is not specified
public java.util.Collection find(java.lang.Object obj)
throws SearchException
DAOThis method performs an object-based search. Specifically it provides a way to search for a "complete" object given a partially defined object, ie an object which does not have all fields filled. It provides equivalent functionality to the simple text-based search when only a single (String) field is filled in. Searches may be performed using an example object which only has a single object reference set, or even an example object containing a Collection that has only a single element set.
NOTE - RESTRICTIONS ON CURRENT USE
find in interface DAOobj - - the object search "value"
SearchException - - thrown if there were problems during the search process itselfNote: the local cache of non-PK fields is not currently used in this method (to do)
public java.util.Iterator findColumnValues(java.lang.String type,
java.lang.String[] cols)
throws SearchException
findColumnValues in interface DAOtype - the object type you want details of (must be specified)cols - the table columns (NOT attribute names) you are interested in (null
will retrieve all of them)
closeResults method of this class. Null is returned if no results found
SearchException - trhown if a problem occurs whilst searching the data store
java.lang.NullPointerException - thrown if the type is null
public java.util.Collection findBySQL(java.lang.String type,
java.lang.String sqlString)
throws SearchException
findBySQL in interface DAOtype - the object type you want details of (must be specified)sqlString - the string to be used for the query
SearchException - thrown if a problem occurs whilst searching the data store
java.lang.NullPointerException - thrown if the type is null
public java.util.Iterator iteratorFind(java.lang.String type,
java.lang.String col,
java.lang.String val)
throws SearchException
This method provides a means to obtain an Iterator for search results. This
can be useful if you need direct control over a result set, because OJB iterators have access to
result sets which may then be closed by passing the iterator back to the
closeResults method. Note that this approach will not tidy up
open cursors on an oracle server - the only way to do this seems to be
to close the connection, which is done automatically via the find
method (this is OK if oracle connection pooling is used).
iteratorFind in interface DAOtype - - the class name (ie table) to be searchedcol - - the parameter (column name) to search on (usually ac number or name)val - - the value of the search parameter
java.lang.NullPointerException - thrown if the type is null
SearchException - - thrown for errors during the search process, eg query problems
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||