com.hs.mail.imap.dao
Class AbstractDao

java.lang.Object
  extended by org.springframework.dao.support.DaoSupport
      extended by org.springframework.jdbc.core.support.JdbcDaoSupport
          extended by com.hs.mail.imap.dao.AbstractDao
All Implemented Interfaces:
org.springframework.beans.factory.InitializingBean
Direct Known Subclasses:
MySqlMailboxDao, MySqlMessageDao, MySqlSearchDao, MySqlUserDao

public abstract class AbstractDao
extends org.springframework.jdbc.core.support.JdbcDaoSupport

Convenient super class for JDBC-based data access objects.

Since:
Feb 11, 2010
Author:
Won Chul Doh

Field Summary
 
Fields inherited from class org.springframework.dao.support.DaoSupport
logger
 
Constructor Summary
AbstractDao()
           
 
Method Summary
protected static String duplicate(String[] fields, Object[] params, int start)
           
protected static String escape(String param)
           
protected  int queryForInt(String sql, Object[] args)
          Query given SQL to create a prepared statement from SQL and a list of arguments to bind to the query, resulting in an int value.
protected  long queryForLong(String sql, Object[] args)
          Query given SQL to create a prepared statement from SQL and a list of arguments to bind to the query, resulting in a long value.
protected  Object queryForObject(String sql, Object[] args, org.springframework.jdbc.core.RowMapper rowMapper)
          Query given SQL to create a prepared statement from SQL and a list of arguments to bind to the query, mapping a single result row to a Java object via a RowMapper.
 
Methods inherited from class org.springframework.jdbc.core.support.JdbcDaoSupport
checkDaoConfig, createJdbcTemplate, getConnection, getDataSource, getExceptionTranslator, getJdbcTemplate, initTemplateConfig, releaseConnection, setDataSource, setJdbcTemplate
 
Methods inherited from class org.springframework.dao.support.DaoSupport
afterPropertiesSet, initDao
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractDao

public AbstractDao()
Method Detail

queryForObject

protected Object queryForObject(String sql,
                                Object[] args,
                                org.springframework.jdbc.core.RowMapper rowMapper)
                         throws org.springframework.dao.DataAccessException
Query given SQL to create a prepared statement from SQL and a list of arguments to bind to the query, mapping a single result row to a Java object via a RowMapper.

Parameters:
sql - SQL query to execute
args - arguments to bind to the query (leaving it to the PreparedStatement to guess the corresponding SQL type)
rowMapper - object that will map one object per row
Returns:
the single mapped object or null if the query does not return any row
Throws:
org.springframework.dao.DataAccessException - if the query fails

queryForLong

protected long queryForLong(String sql,
                            Object[] args)
                     throws org.springframework.dao.DataAccessException
Query given SQL to create a prepared statement from SQL and a list of arguments to bind to the query, resulting in a long value. The query is expected to be a single row/single column query that results in a long value.

Parameters:
sql - SQL query to execute
args - arguments to bind to the query (leaving it to the PreparedStatement to guess the corresponding SQL type)
Returns:
the long value, or 0 in case of SQL NULL or if the query does not return any row
Throws:
org.springframework.dao.DataAccessException - if query fails

queryForInt

protected int queryForInt(String sql,
                          Object[] args)
                   throws org.springframework.dao.DataAccessException
Query given SQL to create a prepared statement from SQL and a list of arguments to bind to the query, resulting in an int value. The query is expected to be a single row/single column query that results in an int value.

Parameters:
sql - SQL query to execute
args - arguments to bind to the query (leaving it to the PreparedStatement to guess the corresponding SQL type)
Returns:
the int value, or 0 in case of SQL NULL or if the query does not
Throws:
org.springframework.dao.DataAccessException - if query fails

escape

protected static String escape(String param)

duplicate

protected static String duplicate(String[] fields,
                                  Object[] params,
                                  int start)


Copyright © 2011. All Rights Reserved.