|
2.17.2: 2011-06-17 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sf.basedb.core.hibernate.ResultSetWork<R>
public abstract class ResultSetWork<R>
A work implementation that executes an SQL query on the connection,
and returns a value that is picked by a subclass from the resulting
ResultSet
. This class needs to be subclassed and implementors
should provide an implementation of the getResult(ResultSet)
method. By overridding the setParameters(PreparedStatement)
method it is possible to set parameters on the prepared statement before
the SQL is executed.
Field Summary | |
---|---|
private R |
result
|
private SessionControl |
sc
|
private String |
sql
|
Constructor Summary | |
---|---|
ResultSetWork(SessionControl sc,
String sql)
Create a new work item. |
Method Summary | |
---|---|
void |
execute(Connection connection)
From the Work interface ----------------------- |
R |
getResult()
Get the result of the work. |
protected abstract R |
getResult(ResultSet rs)
This method needs to be overridden by subclasses to extract the result from the ResultSet . |
protected void |
setParameters(PreparedStatement ps)
This method should be overridden by subclasses that needs to set parameters on the statement that is going to be executed. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private SessionControl sc
private String sql
private R result
Constructor Detail |
---|
public ResultSetWork(SessionControl sc, String sql)
sc
- The session control to keep alive during the execution
of the sql, or nullsql
- The sql to executeMethod Detail |
---|
public void execute(Connection connection) throws SQLException
execute
in interface org.hibernate.jdbc.Work
SQLException
public R getResult()
JdbcWork
getResult
in interface JdbcWork<R>
getResult(ResultSet)
method.protected void setParameters(PreparedStatement ps) throws SQLException
Connection.prepareStatement(String)
and before it is executed
with PreparedStatement.executeUpdate()
.
ps
- The prepared statement
SQLException
protected abstract R getResult(ResultSet rs) throws SQLException
ResultSet
. The result set will be closed
after the call to this method.
rs
- The result set to get the result from
SQLException
|
2.17.2: 2011-06-17 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |