|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.ibatis.db.sqlmap.MappedStatement
One of the core classes in the iBATIS database framework, the MappedStatement represents an SQL statement that will have a parameter bean and/or result beans mapped to it.
Nested Class Summary | |
private static class |
MappedStatement.CacheKey
A key for results in the cache. |
private static class |
MappedStatement.ErrorField
This is a value holder class for the very limited use of passing error information around. |
private static class |
MappedStatement.ResultSetAutoMapper
Class for automatically mapping resultsets to columns, and caching the relevant mappings. |
Field Summary | |
private CacheModel |
cache
|
private static java.lang.String |
CHECK_PARAMETER_MAP
|
private static java.lang.String |
CHECK_RESULT_MAP
|
private static java.lang.String |
CHECK_SQL_STATEMENT
|
private static java.lang.String |
ELEMENT_TOKEN
|
private java.util.List |
executeListeners
|
private boolean |
isInline
|
private static org.apache.commons.logging.Log |
log
|
private java.lang.String |
name
|
static int |
NO_MAXIMUM_RESULTS
Magic number used to set the the maximum number of rows returned to 'all'. |
static int |
NO_SKIPPED_RESULTS
Magic number used to set the the number of rows skipped to 'none'. |
private java.lang.String |
parameterClass
|
private java.lang.Class |
parameterClassType
|
private java.lang.String |
parameterMapName
|
private java.lang.String |
resourceName
|
private java.lang.String |
resultClass
|
private java.lang.String |
resultMapName
|
private MappedStatement.ResultSetAutoMapper |
resultSetAutoMapper
|
private java.lang.String |
sql
|
private SqlMap |
sqlMap
|
private StatementFactory |
statementFactory
|
private boolean |
storedProcedure
|
Constructor Summary | |
MappedStatement()
Default constructor. |
Method Summary | |
void |
addExecuteListener(ExecuteListener listener)
Adds an instance of a class that implements the ExecuteListener interface to a list of objects that will be notified after an execute method is run. |
private void |
applyParameterMap(SqlStatement localSql,
java.sql.PreparedStatement ps,
java.lang.Object parameterObject,
MappedStatement.ErrorField errorField)
|
private java.lang.Object |
applyResultMap(java.sql.Connection conn,
java.sql.ResultSet rs,
java.lang.Object resultObject,
MappedStatement.ErrorField errorField)
|
protected void |
assertParameterClass(java.lang.Object parameterObject)
|
private void |
autoMapResultSet(java.sql.Connection conn,
java.sql.ResultSet rs,
java.lang.Object object,
MappedStatement.ErrorField errorField)
|
private void |
closeResultSet(java.sql.ResultSet rs)
|
private void |
closeStatement(java.sql.PreparedStatement ps)
|
private java.sql.PreparedStatement |
createStatement(java.sql.Connection conn,
SqlStatement localSql,
java.lang.Object parameterObject)
|
java.util.List |
executeQueryForList(java.sql.Connection conn,
java.lang.Object parameterObject)
Executes the SQL and retuns all rows selected. |
java.util.List |
executeQueryForList(java.sql.Connection conn,
java.lang.Object parameterObject,
int skipResults,
int maxResults)
Executes the SQL and retuns a subset of the rows selected. |
java.util.Map |
executeQueryForMap(java.sql.Connection conn,
java.lang.Object parameterObject,
java.lang.String keyProperty)
Executes the SQL and retuns all rows selected in a map that is keyed on the property named in the keyProperty parameter. |
java.util.Map |
executeQueryForMap(java.sql.Connection conn,
java.lang.Object parameterObject,
java.lang.String keyProperty,
java.lang.String valueProperty)
Executes the SQL and retuns all rows selected in a map that is keyed on the property named in the keyProperty parameter. |
java.lang.Object |
executeQueryForObject(java.sql.Connection conn,
java.lang.Object parameterObject)
Executes an SQL statement that returns a single row as an Object. |
java.lang.Object |
executeQueryForObject(java.sql.Connection conn,
java.lang.Object parameterObject,
java.lang.Object resultObject)
Executes an SQL statement that returns a single row as an Object of the type of the resultObject passed in as a parameter. |
PaginatedList |
executeQueryForPaginatedList(java.lang.Object parameterObject,
int pageSize)
Executes the SQL and retuns a subset of the results in a dynamic PaginatedList that can be used to automatically scroll through results from a database table. |
void |
executeQueryWithRowHandler(java.sql.Connection conn,
java.lang.Object parameterObject,
RowHandler rowHandler)
Runs a query with a custom object that gets a chance to deal with each row as it is processed. |
int |
executeUpdate(java.sql.Connection conn,
java.lang.Object parameterObject)
Executes an SQL statement that could change the database. |
CacheModel |
getCache()
Getter for the cache object used by this object |
java.lang.Double |
getDataCacheHitRatio()
Gets a percentage of successful cache hits achieved |
java.lang.String |
getName()
Getter for name property |
java.lang.String |
getParameterClass()
Getter for the class name of the parameter object (if any) related to this MappedStatement. |
java.lang.String |
getParameterMapName()
Getter for the name of the parameter map object (if any) related to this MappedStatement. |
java.lang.String |
getResourceName()
Getter for resourceName property |
java.lang.String |
getResultClass()
Getter for the class name of the result object (if any) related to this MappedStatement. |
java.lang.String |
getResultMapName()
Getter for the name of the result map object (if any) related to this MappedStatement. |
java.lang.String |
getSql(java.lang.Object parameterObject)
Returns the SQL statement for the object |
SqlMap |
getSqlMap()
Getter for the SqlMap object that contains this MappedStatement |
protected SqlStatement |
getSqlStatement(java.lang.Object parameterObject)
|
private java.lang.Object |
instantiate(java.lang.String className)
|
boolean |
isDynamic()
Getter for flag that indicates if this MappedStatement is 'dynamic' |
private boolean |
isEqualToNullValue(java.lang.String nullValue,
java.lang.Object realValue)
|
boolean |
isInline()
Getter for inline property |
private static boolean |
isSimpleType(java.lang.Class type)
|
boolean |
isStoredProcedure()
Getter for a flag that indicates that this MappedStatement represents a stored procedure. |
private void |
notifyListeners()
|
private java.lang.String |
processDynamicElements(java.lang.String sql,
java.lang.Object parameterObject)
|
private java.util.List |
runQueryForList(SqlStatement localSql,
java.sql.Connection conn,
java.lang.Object parameterObject,
int skipResults,
int maxResults,
RowHandler rowHandler)
|
private java.util.Map |
runQueryForMap(java.sql.Connection conn,
java.lang.Object parameterObject,
java.lang.String keyProperty,
java.lang.String valueProperty)
|
private java.lang.Object |
runQueryForObject(SqlStatement localSql,
java.sql.Connection conn,
java.lang.Object parameterObject,
java.lang.Object resultObject)
|
private void |
setBeanProperty(ResultMapping mapping,
java.lang.Object object,
java.sql.Connection conn,
java.sql.ResultSet rs,
MappedStatement.ErrorField errorField)
|
void |
setCache(CacheModel cache)
Setter for the cache object used by this object |
void |
setInline(boolean inline)
Setter for inline property |
void |
setName(java.lang.String name)
Setter for name property |
private void |
setNullParameter(ParameterMapping mapping,
int index,
java.sql.PreparedStatement ps)
|
private void |
setParameter(java.sql.PreparedStatement ps,
int index,
java.lang.Object object,
ParameterMap map,
MappedStatement.ErrorField errorField)
|
void |
setParameterClass(java.lang.String parameterClass)
Setter for the class name of the parameter object (if any) related to this MappedStatement. |
void |
setParameterMapName(java.lang.String parameterMapName)
Setter for the name of the parameter map object (if any) related to this MappedStatement. |
void |
setResourceName(java.lang.String resourceName)
Setter for resourceName property |
void |
setResultClass(java.lang.String resultClass)
Setter for the class name of the result object (if any) related to this MappedStatement. |
void |
setResultMapName(java.lang.String resultMapName)
Setter for the name of the result map object (if any) related to this MappedStatement. |
void |
setSql(java.lang.String sql)
Sets the SQL statement for the object |
void |
setSqlMap(SqlMap sqlMap)
Setter for the SqlMap object that contains this MappedStatement |
void |
setStoredProcedure(boolean storedProcedure)
Setter for a flag that indicates that this MappedStatement represents a stored procedure. |
java.lang.String |
toString()
Simple toString implementation |
private java.lang.Throwable |
unwrapProxyException(java.lang.Throwable t)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
private static final org.apache.commons.logging.Log log
public static final int NO_MAXIMUM_RESULTS
public static final int NO_SKIPPED_RESULTS
private static final java.lang.String CHECK_SQL_STATEMENT
private static final java.lang.String CHECK_PARAMETER_MAP
private static final java.lang.String CHECK_RESULT_MAP
private static final java.lang.String ELEMENT_TOKEN
private java.util.List executeListeners
private java.lang.String resourceName
private java.lang.String name
private java.lang.String sql
private java.lang.String parameterClass
private java.lang.Class parameterClassType
private java.lang.String resultClass
private java.lang.String parameterMapName
private java.lang.String resultMapName
private SqlMap sqlMap
private boolean isInline
private boolean storedProcedure
private CacheModel cache
private StatementFactory statementFactory
private MappedStatement.ResultSetAutoMapper resultSetAutoMapper
Constructor Detail |
public MappedStatement()
Method Detail |
public java.lang.String getName()
public void setName(java.lang.String name)
name
- The new name of the objectpublic java.lang.String getResourceName()
public void setResourceName(java.lang.String resourceName)
resourceName
- The new resourceName of the objectpublic boolean isInline()
public void setInline(boolean inline)
inline
- The new inline setting for the objectpublic java.lang.String getSql(java.lang.Object parameterObject)
parameterObject
- The bean containing the parameters for the SQL statement
public void setSql(java.lang.String sql)
sql
- The new SQL statement for the objectpublic SqlMap getSqlMap()
public void setSqlMap(SqlMap sqlMap)
sqlMap
- The new SqlMap objectpublic java.lang.String getParameterClass()
public void setParameterClass(java.lang.String parameterClass)
parameterClass
- The new class namepublic java.lang.String getResultClass()
public void setResultClass(java.lang.String resultClass)
resultClass
- The new class namepublic java.lang.String getParameterMapName()
public void setParameterMapName(java.lang.String parameterMapName)
parameterMapName
- The new name of the parameter mappublic java.lang.String getResultMapName()
public void setResultMapName(java.lang.String resultMapName)
resultMapName
- The new name of the result mappublic CacheModel getCache()
public void setCache(CacheModel cache)
cache
- The new cache to usepublic boolean isStoredProcedure()
public void setStoredProcedure(boolean storedProcedure)
storedProcedure
- True if this MappedStatement is for a stored procedurepublic boolean isDynamic()
public java.lang.Double getDataCacheHitRatio()
public void addExecuteListener(ExecuteListener listener)
listener
- The object to add to the listpublic java.lang.String toString()
private void notifyListeners()
private java.lang.String processDynamicElements(java.lang.String sql, java.lang.Object parameterObject)
private java.sql.PreparedStatement createStatement(java.sql.Connection conn, SqlStatement localSql, java.lang.Object parameterObject) throws java.sql.SQLException
java.sql.SQLException
protected void assertParameterClass(java.lang.Object parameterObject) throws java.sql.SQLException
java.sql.SQLException
public int executeUpdate(java.sql.Connection conn, java.lang.Object parameterObject) throws java.sql.SQLException
conn
- The connection to use to execute the updateparameterObject
- The parameter object that will be mapped to the SQL
java.sql.SQLException
- If an exception occurs in the databasepublic void executeQueryWithRowHandler(java.sql.Connection conn, java.lang.Object parameterObject, RowHandler rowHandler) throws java.sql.SQLException
conn
- The connection used to execute the queryparameterObject
- The parameter object mapped the the statementrowHandler
- The custom row handler object
java.sql.SQLException
- If an exception occurs in the databasepublic java.util.Map executeQueryForMap(java.sql.Connection conn, java.lang.Object parameterObject, java.lang.String keyProperty) throws java.sql.SQLException
conn
- The connection used to execute the statementparameterObject
- The object used to set the parameters in the SQLkeyProperty
- The property of the result object to be used as the key
java.sql.SQLException
- If an exception occurs in the databasepublic java.util.Map executeQueryForMap(java.sql.Connection conn, java.lang.Object parameterObject, java.lang.String keyProperty, java.lang.String valueProperty) throws java.sql.SQLException
conn
- The connection used to execute the statementparameterObject
- The object used to set the parameters in the SQLkeyProperty
- The property of the result object to be used as the keyvalueProperty
- The property of the result object to be used as the value (or null)
java.sql.SQLException
- If an exception occurs in the databaseprivate java.util.Map runQueryForMap(java.sql.Connection conn, java.lang.Object parameterObject, java.lang.String keyProperty, java.lang.String valueProperty) throws java.sql.SQLException
java.sql.SQLException
public PaginatedList executeQueryForPaginatedList(java.lang.Object parameterObject, int pageSize) throws java.sql.SQLException
parameterObject
- The object used to set the parameters in the SQLpageSize
- The maximum number of objects to store in each page
java.sql.SQLException
- If an exception occurs in the databasepublic java.util.List executeQueryForList(java.sql.Connection conn, java.lang.Object parameterObject) throws java.sql.SQLException
conn
- The connection used to execute the statementparameterObject
- The object used to set the parameters in the SQL
java.sql.SQLException
- If an exception occurs in the databasepublic java.util.List executeQueryForList(java.sql.Connection conn, java.lang.Object parameterObject, int skipResults, int maxResults) throws java.sql.SQLException
conn
- The connection used to execute the statementparameterObject
- The object used to set the parameters in the SQLskipResults
- The number of rows to skipmaxResults
- The number of rows to return
java.sql.SQLException
- If an exception occurs in the databaseprivate java.util.List runQueryForList(SqlStatement localSql, java.sql.Connection conn, java.lang.Object parameterObject, int skipResults, int maxResults, RowHandler rowHandler) throws java.sql.SQLException
java.sql.SQLException
public java.lang.Object executeQueryForObject(java.sql.Connection conn, java.lang.Object parameterObject) throws java.sql.SQLException
conn
- The connection used to execute the statementparameterObject
- The object used to set the parameters in the SQL
java.sql.SQLException
- If an exception occurs in the databasepublic java.lang.Object executeQueryForObject(java.sql.Connection conn, java.lang.Object parameterObject, java.lang.Object resultObject) throws java.sql.SQLException
conn
- The connection used to execute the statementparameterObject
- The object used to set the parameters in the SQLresultObject
- The
java.sql.SQLException
- If an exception occurs in the databaseprivate java.lang.Object runQueryForObject(SqlStatement localSql, java.sql.Connection conn, java.lang.Object parameterObject, java.lang.Object resultObject) throws java.sql.SQLException
java.sql.SQLException
private java.lang.Throwable unwrapProxyException(java.lang.Throwable t)
private void applyParameterMap(SqlStatement localSql, java.sql.PreparedStatement ps, java.lang.Object parameterObject, MappedStatement.ErrorField errorField) throws java.sql.SQLException
java.sql.SQLException
protected SqlStatement getSqlStatement(java.lang.Object parameterObject) throws java.sql.SQLException
java.sql.SQLException
private boolean isEqualToNullValue(java.lang.String nullValue, java.lang.Object realValue)
private static boolean isSimpleType(java.lang.Class type)
private void setParameter(java.sql.PreparedStatement ps, int index, java.lang.Object object, ParameterMap map, MappedStatement.ErrorField errorField) throws java.sql.SQLException
java.sql.SQLException
private void setNullParameter(ParameterMapping mapping, int index, java.sql.PreparedStatement ps) throws java.sql.SQLException
java.sql.SQLException
private java.lang.Object applyResultMap(java.sql.Connection conn, java.sql.ResultSet rs, java.lang.Object resultObject, MappedStatement.ErrorField errorField) throws java.sql.SQLException
java.sql.SQLException
private void autoMapResultSet(java.sql.Connection conn, java.sql.ResultSet rs, java.lang.Object object, MappedStatement.ErrorField errorField) throws java.sql.SQLException
java.sql.SQLException
private void setBeanProperty(ResultMapping mapping, java.lang.Object object, java.sql.Connection conn, java.sql.ResultSet rs, MappedStatement.ErrorField errorField) throws java.sql.SQLException
java.sql.SQLException
private void closeStatement(java.sql.PreparedStatement ps)
private void closeResultSet(java.sql.ResultSet rs)
private java.lang.Object instantiate(java.lang.String className)
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |