org.nuiton.topia.framework
Class TopiaSQLQuery<O>

java.lang.Object
  extended by org.nuiton.topia.framework.TopiaSQLQuery<O>
Type Parameters:
O - the type of result data

public abstract class TopiaSQLQuery<O>
extends Object

An executor of sql query which permits to obtain a single result via the method findSingleResult(TopiaContextImplementor) or a multiple result with method findMultipleResult(TopiaContextImplementor).

Since:
2.5

Constructor Summary
TopiaSQLQuery()
           
 
Method Summary
 List<O> findMultipleResult(TopiaContextImplementor tx)
          Obtain a multiple results fro the builded sql query.
 O findSingleResult(TopiaContextImplementor tx)
          Obtain a single result from the builded sql query.
protected abstract  PreparedStatement prepareQuery(Connection connection)
          Prepare the statement used to do the sql query.
protected abstract  O prepareResult(ResultSet set)
          given a result set, extract the data.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TopiaSQLQuery

public TopiaSQLQuery()
Method Detail

prepareQuery

protected abstract PreparedStatement prepareQuery(Connection connection)
                                           throws SQLException
Prepare the statement used to do the sql query.

Parameters:
connection - jdbc connection to use
Returns:
the statement containing the query to execute
Throws:
SQLException - if any problem

prepareResult

protected abstract O prepareResult(ResultSet set)
                            throws SQLException
given a result set, extract the data.

Parameters:
set - the result set
Returns:
the data extracted from the current set, or null
Throws:
SQLException - if any prob

findSingleResult

public O findSingleResult(TopiaContextImplementor tx)
                   throws TopiaException
Obtain a single result from the builded sql query.

Parameters:
tx - the transaction used to execute the query.
Returns:
the single result or null if none found.
Throws:
TopiaException - for any pb

findMultipleResult

public List<O> findMultipleResult(TopiaContextImplementor tx)
                           throws TopiaException
Obtain a multiple results fro the builded sql query.

Parameters:
tx - the transaction used to execute the query.
Returns:
the list of results (the list is empty if non result is found).
Throws:
TopiaException - for any pb


Copyright © 2004-2011 CodeLutin. All Rights Reserved.