|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectcom.marringtons.object.Search
Search is used to create a database search instance for finding persistent objects by their indexes.
Search search = Database.search( new MyDAO());
for ( MyDAO dao = (MyDAO) search.first("my key"); dao != null; dao = (MyDAO) search.next())
processDAO(dao);
Method first() has overloaded methods to accept an int, String or an Index.
The first two look for the first DAO index with one field of type int or
String. For more complex indexes, or for any but the first int or String,
provide an instance of the index class from your DAO.
MyDAO.PrimaryIndex index = new MyDAO.PrimaryIndex; index.integer = 32; index.string = "my key"; if (dao = (MyDAO) search.first( index)) gotIt( dao);
Search search = new Search().readOnly().lazyLoad(); daoWithField = (TestDAOfield) search.first(2001, true, true); assertTrue(daoWithField.testDAO.string == null); TestDAO innerDAO = (TestDAO) daoWithField.testDAO.load(); assertTrue(innerDAO.equals(daoWithField.testDAO)); // both have same currentRecord assertTrue(innerDAO.string == "test DAO fields");
| Nested Class Summary | |
static class |
Search.Access
Static fields in this class are used as part of Search initialisation to define whether data retrieved is only for perusal or whether it can be updated. |
static class |
Search.Load
Static fields in this class are used as part of Search initialisation to define whether loading from the search is to be lazy or eager. |
| Constructor Summary | |
Search(Class daoClass,
Search.Load load,
Search.Access access)
Create a search object for retrieving specified objects from the database. |
|
Search(DAO dao,
Search.Load load,
Search.Access access)
Create a search object for retrieving specified objects from the database. |
|
| Method Summary | |
DAO |
first(Index index)
Retrieve the first of a list of objects that match the provided index. |
DAO |
first(int integerIndex)
Retrieve the first of a list of objects that match the provided integer index. |
DAO |
first(String stringIndex)
Retrieve the first of a list of objects that match the provided string index. |
DAO |
next()
Retrieve the next matching record. |
| Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public Search(DAO dao,
Search.Load load,
Search.Access access)
dao - instanceof the DAO we will be searching for.load - Use Search.Load.lazy to not load sub-DAOs (until load() called).
Otherwise use Search.Load.eager and all DAOs in the tree will be loaded at the same time.
The first is more efficient with deep data structures, but requires code that calls load()
before accessing DAO data. The latter is way more convenient - and should be used in
most cases without a large data tree.access - Use Search.Access.readOnly where possible. There is a minor performance benefit
- but the main gain is confidence that the database copy cannot be changed. For data that
you expect change, use Search.Access.readWrite.
public Search(Class daoClass,
Search.Load load,
Search.Access access)
daoClass - Class for the DAO we will be searching for.load - Use Search.Load.lazy to not load sub-DAOs (until load() called).
Otherwise use Search.Load.eager and all DAOs in the tree will be loaded at the same time.
The first is more efficient with deep data structures, but requires code that calls load()
before accessing DAO data. The latter is way more convenient - and should be used in
most cases without a large data tree.access - Use Search.Access.readOnly where possible. There is a minor performance benefit
- but the main gain is confidence that the database copy cannot be changed. For data that
you expect change, use Search.Access.readWrite.| Method Detail |
public DAO first(Index index)
throws IOException
index - being inner class of objectClass
IOExceptionnext()
public DAO first(int integerIndex)
throws IOException
integerIndex - integer to key item on.
IOExceptionnext()
public DAO first(String stringIndex)
throws IOException
stringIndex - string to key item on in index.
IOExceptionnext()
public DAO next()
throws IOException
IOException
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||