|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object | +--test.tester.model.Query
This class encapsulate a SQL prepared statement.
You can execute the query, and then get the result as a Collection of
one MappedTable. Look at the following example:
Query q = new Query(connection, "select * from tableX");
q.execute();
Collection c = q.getResultAs(TableX.class);
You will get a Collection with all the rows returned by the sql query.
And it will be a Collection of TableX instances.
Everytime that you call a method inside TableXBroker class, it creates a query, bind some valued to it, than return the result in a appropriate format.
| Constructor Summary | |
Query(java.sql.Connection conn,
java.lang.String query)
Creates a new query, given a Connection and a string with the query. |
|
| Method Summary | |
void |
execute()
Execute the query. |
protected void |
finalize()
Do a basic cleanup. |
java.util.Collection |
getResultAs(java.lang.Class c)
Gets the result of the query as an Collection of Class c objects. |
java.sql.ResultSet |
getResultSet()
Simply returns the ResultSet, if any. |
void |
setObject(int id,
java.lang.Object o)
Binds one object to one variable inside this query. |
java.lang.String |
toString()
|
| Methods inherited from class java.lang.Object |
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
public Query(java.sql.Connection conn,
java.lang.String query)
throws DAOException
| Method Detail |
protected void finalize()
throws java.lang.Throwable
finalize in class java.lang.Objectjava.lang.Throwable
public void setObject(int id,
java.lang.Object o)
throws DAOException
DAOException
public void execute()
throws DAOException
DAOException
public java.util.Collection getResultAs(java.lang.Class c)
throws DAOException
Never returns null, but can return an empty ArrayList. This method relies on the set() method implemention in the MappedTable implementations.
DAOExceptionMappedTable
public java.sql.ResultSet getResultSet()
throws DAOException
DAOExceptionpublic java.lang.String toString()
toString in class java.lang.Object
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||