com.j256.ormlite.stmt
Class StatementExecutor<T,ID>

java.lang.Object
  extended by com.j256.ormlite.stmt.StatementExecutor<T,ID>

public class StatementExecutor<T,ID>
extends Object

Executes SQL statements for a particular table in a particular database. Basically a call through to various mapped statement methods.

Author:
graywatson

Constructor Summary
StatementExecutor(DatabaseType databaseType, TableInfo<T> tableInfo)
          Provides statements for various SQL operations.
 
Method Summary
 SelectIterator<T,ID> buildIterator(BaseJdbcDao<T,ID> classDao, DatabaseAccess jdbcTemplate)
          Create and return an SelectIterator for the class with a jdbcTemplate an the default mapped query for all statement.
 SelectIterator<T,ID> buildIterator(BaseJdbcDao<T,ID> classDao, DatabaseAccess jdbcTemplate, PreparedQuery<T> preparedQuery)
          Create and return an SelectIterator for the class with a jdbcTemplate and mapped statement.
 RawResults buildIterator(DatabaseAccess jdbcTemplate, String query)
          Return a RawResults object associated with an internal iterator that matches the query argument.
 int create(DatabaseAccess template, T data)
          Create a new entry in the database from an object.
 int delete(DatabaseAccess template, T data)
          Delete an object from the database.
 int deleteIds(DatabaseAccess template, Collection<ID> ids)
          Delete a collection of objects from the database.
 int deleteObjects(DatabaseAccess template, Collection<T> datas)
          Delete a collection of objects from the database.
 List<T> query(DatabaseAccess jdbcTemplate, PreparedQuery<T> preparedQuery)
          Return a list of all of the data in the table that matches the PreparedQuery.
 List<T> queryForAll(DatabaseAccess jdbcTemplate)
          Return a list of all of the data in the table.
 T queryForFirst(DatabaseAccess jdbcTemplate, PreparedQuery<T> preparedQuery)
          Return the first object that matches the PreparedQuery or null if none.
 T queryForId(DatabaseAccess template, ID id)
          Return the object associated with the id or null if none.
 RawResults queryRaw(DatabaseAccess jdbcTemplate, String query)
          Return a list of all of the data in the table that matches the PreparedQuery.
 int refresh(DatabaseAccess template, T data)
          Does a query for the object's Id and copies in each of the field values from the database to refresh the data parameter.
 int update(DatabaseAccess template, T data)
          Update an object in the database.
 int updateId(DatabaseAccess template, T data, ID newId)
          Update an object in the database to change its id to the newId parameter.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StatementExecutor

public StatementExecutor(DatabaseType databaseType,
                         TableInfo<T> tableInfo)
                  throws SQLException
Provides statements for various SQL operations.

Throws:
SQLException
Method Detail

queryForId

public T queryForId(DatabaseAccess template,
                    ID id)
             throws SQLException
Return the object associated with the id or null if none. This does a SQL select col1,col2,... from ... where ... = id type query.

Throws:
SQLException

queryForFirst

public T queryForFirst(DatabaseAccess jdbcTemplate,
                       PreparedQuery<T> preparedQuery)
                throws SQLException
Return the first object that matches the PreparedQuery or null if none.

Throws:
SQLException

queryForAll

public List<T> queryForAll(DatabaseAccess jdbcTemplate)
                    throws SQLException
Return a list of all of the data in the table. Should be used carefully if the table is large. Consider using the Dao.iterator() if this is the case.

Throws:
SQLException

query

public List<T> query(DatabaseAccess jdbcTemplate,
                     PreparedQuery<T> preparedQuery)
              throws SQLException
Return a list of all of the data in the table that matches the PreparedQuery. Should be used carefully if the table is large. Consider using the Dao.iterator() if this is the case.

Throws:
SQLException

queryRaw

public RawResults queryRaw(DatabaseAccess jdbcTemplate,
                           String query)
                    throws SQLException
Return a list of all of the data in the table that matches the PreparedQuery. Should be used carefully if the table is large. Consider using the Dao.iterator() if this is the case.

Throws:
SQLException

buildIterator

public SelectIterator<T,ID> buildIterator(BaseJdbcDao<T,ID> classDao,
                                          DatabaseAccess jdbcTemplate)
                                   throws SQLException
Create and return an SelectIterator for the class with a jdbcTemplate an the default mapped query for all statement.

Throws:
SQLException

buildIterator

public SelectIterator<T,ID> buildIterator(BaseJdbcDao<T,ID> classDao,
                                          DatabaseAccess jdbcTemplate,
                                          PreparedQuery<T> preparedQuery)
                                   throws SQLException
Create and return an SelectIterator for the class with a jdbcTemplate and mapped statement.

Throws:
SQLException

buildIterator

public RawResults buildIterator(DatabaseAccess jdbcTemplate,
                                String query)
                         throws SQLException
Return a RawResults object associated with an internal iterator that matches the query argument.

Throws:
SQLException

create

public int create(DatabaseAccess template,
                  T data)
           throws SQLException
Create a new entry in the database from an object.

Throws:
SQLException

update

public int update(DatabaseAccess template,
                  T data)
           throws SQLException
Update an object in the database.

Throws:
SQLException

updateId

public int updateId(DatabaseAccess template,
                    T data,
                    ID newId)
             throws SQLException
Update an object in the database to change its id to the newId parameter.

Throws:
SQLException

refresh

public int refresh(DatabaseAccess template,
                   T data)
            throws SQLException
Does a query for the object's Id and copies in each of the field values from the database to refresh the data parameter.

Throws:
SQLException

delete

public int delete(DatabaseAccess template,
                  T data)
           throws SQLException
Delete an object from the database.

Throws:
SQLException

deleteObjects

public int deleteObjects(DatabaseAccess template,
                         Collection<T> datas)
                  throws SQLException
Delete a collection of objects from the database.

Throws:
SQLException

deleteIds

public int deleteIds(DatabaseAccess template,
                     Collection<ID> ids)
              throws SQLException
Delete a collection of objects from the database.

Throws:
SQLException


Copyright © 2010. All Rights Reserved.