|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
This interface defines the methods available from a Data Access Object (DAO) implementation. It therefore allows clients of this interface to use typical operations usually provided by a connection class, such as submitting queries etc without knowing the details of the specific DAO implementing this interface. Each implementation of the interface will therefore be a wrapper object around a particular DAO type (eg Castor, XML etc).
Note that methods are included to either perform "encapsulated transactions" (for example bulk object creation or simple searching), or to manage transactions at the client level as one might usually do with, say, JDBC.
| 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 performs a simple search based on the object type to search over, the parameter name and the search value. |
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. |
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 |
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 given object for write access. |
void |
makePersistent(java.util.Collection objs)
This method performs an object creation operation for a collection of objects provided as parameters. |
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 |
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. |
| Method Detail |
public boolean isUserValid(java.lang.String userName,
java.lang.String password)
public void closeResults(java.util.Iterator itemIterator)
itemIterator - The iterator over the results (should be obtained from iteratorFind)
java.lang.IllegalArgumentException - thrown if the Iterator is an invalid type
public java.lang.String getDbName()
throws org.apache.ojb.broker.accesslayer.LookupException,
java.sql.SQLException
org.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
org.apache.ojb.broker.accesslayer.LookupException - thrown on error
getting the Connection
java.sql.SQLException - thrown if the metatdata can't be obtained
public void begin(int txType)
throws TransactionException
txType - the Transaction type (eg object or JDBC level)
TransactionException - - can be thrown if a transaction is already in progress
public void lock(java.lang.Object obj)
throws org.odmg.TransactionNotInProgressException
begin(int) must
be called to prior to this method.
obj - the object to lock for write access.
org.odmg.TransactionNotInProgressException - thrown if no object TX is running
public void close()
throws DataSourceException
DataSourceException - - thrown if the DAO cannot be closed (details in specific errors)
public void open()
throws DataSourceException
DataSourceException - - thrown if the DAO cannot be closed (details in specific errors)
public void commit()
throws TransactionException
TransactionException - - thrown if, say, a transaction was not in progress for example
public void create(java.lang.Object obj)
throws CreateException
obj - - the object to be saved
CreateExceptionpublic boolean isActive()
public boolean isAutoSave()
public void setAutoSave(boolean val)
val - - true to turn on, false for offpublic boolean isClosed()
public boolean isPersistent(java.lang.Object obj)
obj - - the object to be checked
public void remove(java.lang.Object obj)
throws TransactionException
obj - - the object to be removed
TransactionException - - thrown usually if the operation is called outside a transaction
public void rollback()
throws TransactionException
TransactionException - - thrown if the transaction couldn't be rolled back
public void makePersistent(java.util.Collection objs)
throws CreateException,
TransactionException
objs - - 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 performs a simple search based on the object type to search over, the parameter name and the search value. This method will begin a new transaction and commit it before returning if it is not called from within the caller's own transaction
Note that at present this only performs very simple "single" text queries - and may be updated later..
type - - the persistent object type to be searchedcol - - the parameter to be searched through - NB assumed to be a DB column nameval - - the value to be used for the search (all items for the type returned if null)
SearchException - - thrown if there were problems during the search process itself
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).
type - - 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 (all items for the type returned if null)
SearchException - - thrown for errors during the search process, eg query problems
java.lang.NullPointerException - thrown if the type is null
public java.util.Collection find(java.lang.Object obj)
throws SearchException
This 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
obj - - the object search "value"
SearchException - - thrown if there were problems during the search process itself
public java.util.Iterator findColumnValues(java.lang.String type,
java.lang.String[] cols)
throws SearchException
type - 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 - thrown 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
type - 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 nullpublic void removeFromCache(java.lang.Object obj)
obj - the object to remove from the cache.
public void update(java.lang.Object obj)
throws UpdateException
updates 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
obj - - 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 (
isPersistent(Object) must return true).isPersistent(Object)public void setLogger(org.apache.log4j.Logger p)
p - A PrintWriter for logging outputpublic void addCachedClass(java.lang.Class clazz)
clazz - class to be cached
public void clearCache()
throws org.apache.ojb.broker.PersistenceBrokerException
org.apache.ojb.broker.PersistenceBrokerException
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||