svn commit: r547853 - in /ibatis/trunk/java/mapper/mapper2/src/com/ibatis/sqlmap/engine: builder/xml/SqlStatementParser.java conifg/MappedStatementConfig.java conifg/SqlMapConfiguration.java
Author: cbegin Date: Fri Jun 15 20:23:18 2007 New Revision: 547853 URL: http://svn.apache.org/viewvc?view=rev&rev=547853 Log: Improved type safety of MappedStatementConfig Modified: ibatis/trunk/java/mapper/mapper2/src/com/ibatis/sqlmap/engine/builder/xml/SqlStatementParser.java ibatis/trunk/java/mapper/mapper2/src/com/ibatis/sqlmap/engine/conifg/MappedStatementConfig.java ibatis/trunk/java/mapper/mapper2/src/com/ibatis/sqlmap/engine/conifg/SqlMapConfiguration.java Modified: ibatis/trunk/java/mapper/mapper2/src/com/ibatis/sqlmap/engine/builder/xml/SqlStatementParser.java URL: http://svn.apache.org/viewvc/ibatis/trunk/java/mapper/mapper2/src/com/ibatis/sqlmap/engine/builder/xml/SqlStatementParser.java?view=diff&rev=547853&r1=547852&r2=547853 == --- ibatis/trunk/java/mapper/mapper2/src/com/ibatis/sqlmap/engine/builder/xml/SqlStatementParser.java (original) +++ ibatis/trunk/java/mapper/mapper2/src/com/ibatis/sqlmap/engine/builder/xml/SqlStatementParser.java Fri Jun 15 20:23:18 2007 @@ -1,8 +1,10 @@ package com.ibatis.sqlmap.engine.builder.xml; import com.ibatis.common.xml.*; +import com.ibatis.common.resources.*; import com.ibatis.sqlmap.engine.conifg.*; import com.ibatis.sqlmap.engine.mapping.statement.*; +import com.ibatis.sqlmap.client.*; import org.w3c.dom.CharacterData; import org.w3c.dom.*; @@ -45,14 +47,47 @@ } } -String[] additionalResultClasses = null; +String[] additionalResultClassNames = null; if (resultClassName != null) { - additionalResultClasses = state.getAllButFirstToken(resultClassName); + additionalResultClassNames = state.getAllButFirstToken(resultClassName); resultClassName = state.getFirstToken(resultClassName); } -MappedStatementConfig statementConf = state.getConfig().newMappedStatementConfig(id, statement, new XMLSqlSource(state, node), parameterMapName, parameterClassName, resultMapName, additionalResultMapNames, resultClassName, additionalResultClasses, resultSetType, fetchSize, allowRemapping, timeout, cacheModelName, xmlResultName); +Class[] additionalResultClasses = null; +if (additionalResultClassNames != null) { + additionalResultClasses = new Class[additionalResultClassNames.length]; + for (int i = 0; i < additionalResultClassNames.length; i++) { +additionalResultClasses[i] = resolveClass(additionalResultClassNames[i]); + } +} + +state.getConfig().getErrorContext().setMoreInfo("Check the parameter class."); +Class parameterClass = resolveClass(parameterClassName); + +state.getConfig().getErrorContext().setMoreInfo("Check the result class."); +Class resultClass = resolveClass(resultClassName); + +Integer timeoutInt = timeout == null ? null : new Integer(timeout); +Integer fetchSizeInt = fetchSize == null ? null : new Integer(fetchSize); +boolean allowRemappingBool = "true".equals(allowRemapping); + +MappedStatementConfig statementConf = state.getConfig().newMappedStatementConfig(id, statement, +new XMLSqlSource(state, node), parameterMapName, parameterClass, resultMapName, additionalResultMapNames, +resultClass, additionalResultClasses, resultSetType, fetchSizeInt, allowRemappingBool, timeoutInt, cacheModelName, +xmlResultName); findAndParseSelectKey(node, statementConf); + } + + private Class resolveClass(String resultClassName) { +try { + if (resultClassName != null) { +return Resources.classForName(state.getConfig().getTypeHandlerFactory().resolveAlias(resultClassName)); + } else { +return null; + } +} catch (ClassNotFoundException e) { + throw new SqlMapException("Error. Could not initialize class. Cause: " + e, e); +} } private void findAndParseSelectKey(Node node, MappedStatementConfig config) { Modified: ibatis/trunk/java/mapper/mapper2/src/com/ibatis/sqlmap/engine/conifg/MappedStatementConfig.java URL: http://svn.apache.org/viewvc/ibatis/trunk/java/mapper/mapper2/src/com/ibatis/sqlmap/engine/conifg/MappedStatementConfig.java?view=diff&rev=547853&r1=547852&r2=547853 == --- ibatis/trunk/java/mapper/mapper2/src/com/ibatis/sqlmap/engine/conifg/MappedStatementConfig.java (original) +++ ibatis/trunk/java/mapper/mapper2/src/com/ibatis/sqlmap/engine/conifg/MappedStatementConfig.java Fri Jun 15 20:23:18 2007 @@ -23,30 +23,33 @@ private static final InlineParameterMapParser PARAM_PARSER = new InlineParameterMapParser(); private ErrorContext errorContext; private ExtendedSqlMapClient client; - private SqlMapExecutorDelegate delegate; private TypeHandlerFactory typeHandlerFactory; private MappedStatement mappedStatement; private MappedStatement rootStatement; - MappedStatementConfig(SqlMapConfiguration config, String id, GeneralStatement stat
svn commit: r547854 - /ibatis/trunk/java/mapper/mapper2/src/com/ibatis/sqlmap/engine/conifg/MappedStatementConfig.java
Author: cbegin Date: Fri Jun 15 20:23:50 2007 New Revision: 547854 URL: http://svn.apache.org/viewvc?view=rev&rev=547854 Log: removed some comments Modified: ibatis/trunk/java/mapper/mapper2/src/com/ibatis/sqlmap/engine/conifg/MappedStatementConfig.java Modified: ibatis/trunk/java/mapper/mapper2/src/com/ibatis/sqlmap/engine/conifg/MappedStatementConfig.java URL: http://svn.apache.org/viewvc/ibatis/trunk/java/mapper/mapper2/src/com/ibatis/sqlmap/engine/conifg/MappedStatementConfig.java?view=diff&rev=547854&r1=547853&r2=547854 == --- ibatis/trunk/java/mapper/mapper2/src/com/ibatis/sqlmap/engine/conifg/MappedStatementConfig.java (original) +++ ibatis/trunk/java/mapper/mapper2/src/com/ibatis/sqlmap/engine/conifg/MappedStatementConfig.java Fri Jun 15 20:23:50 2007 @@ -63,23 +63,12 @@ } } if (fetchSize != null) { - // TODO statement.setFetchSize(new Integer(fetchSize)); statement.setFetchSize(fetchSize); } // set parameter class either from attribute or from map (make sure to match) ParameterMap parameterMap = statement.getParameterMap(); if (parameterMap == null) { -// TODO -// try { -//if (parameterClassName != null) { -// errorContext.setMoreInfo("Check the parameter class."); -// parameterClassName = typeHandlerFactory.resolveAlias(parameterClassName); -// Class parameterClass = Resources.classForName(parameterClassName); -//} -// } catch (ClassNotFoundException e) { -//throw new SqlMapException("Error. Could not set parameter class. Cause: " + e, e); -// } statement.setParameterClass(parameterClass); } else { statement.setParameterClass(parameterMap.getParameterClass());
svn commit: r547856 [2/2] - in /ibatis/trunk/java/mapper/mapper2/src/com/ibatis/sqlmap/engine: conifg/ exchange/ execution/ impl/ mapping/result/ mapping/result/loader/ mapping/statement/
Modified: ibatis/trunk/java/mapper/mapper2/src/com/ibatis/sqlmap/engine/mapping/statement/MappedStatement.java URL: http://svn.apache.org/viewvc/ibatis/trunk/java/mapper/mapper2/src/com/ibatis/sqlmap/engine/mapping/statement/MappedStatement.java?view=diff&rev=547856&r1=547855&r2=547856 == --- ibatis/trunk/java/mapper/mapper2/src/com/ibatis/sqlmap/engine/mapping/statement/MappedStatement.java (original) +++ ibatis/trunk/java/mapper/mapper2/src/com/ibatis/sqlmap/engine/mapping/statement/MappedStatement.java Fri Jun 15 20:53:30 2007 @@ -1,391 +1,391 @@ -/* - * Copyright 2004 Clinton Begin - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.ibatis.sqlmap.engine.mapping.statement; - -import com.ibatis.common.jdbc.exception.NestedSQLException; -import com.ibatis.common.io.ReaderInputStream; - -import com.ibatis.sqlmap.client.event.RowHandler; -import com.ibatis.sqlmap.client.*; -import com.ibatis.sqlmap.engine.execution.SqlExecutor; -import com.ibatis.sqlmap.engine.mapping.parameter.ParameterMap; -import com.ibatis.sqlmap.engine.mapping.result.ResultMap; -import com.ibatis.sqlmap.engine.mapping.sql.Sql; -import com.ibatis.sqlmap.engine.scope.ErrorContext; -import com.ibatis.sqlmap.engine.scope.StatementScope; -import com.ibatis.sqlmap.engine.transaction.Transaction; -import com.ibatis.sqlmap.engine.transaction.TransactionException; -import com.ibatis.sqlmap.engine.type.*; -import com.ibatis.sqlmap.engine.cache.*; -import com.ibatis.sqlmap.engine.impl.*; -import org.w3c.dom.Document; - -import javax.xml.parsers.*; -import java.sql.Connection; -import java.sql.SQLException; -import java.util.*; -import java.io.*; - -public class MappedStatement { - private String id; - private Integer resultSetType; - private Integer fetchSize; - private ResultMap resultMap; - private ParameterMap parameterMap; - private Class parameterClass; - private Sql sql; - private int baseCacheKey; - private ExtendedSqlMapClient sqlMapClient; - private Integer timeout; - private ResultMap[] additionalResultMaps = new ResultMap[0]; - private List executeListeners = new ArrayList(); - private String resource; - - public StatementType getStatementType() { -return StatementType.UNKNOWN; - } - - public int executeUpdate(StatementScope statementScope, Transaction trans, Object parameterObject) - throws SQLException { -ErrorContext errorContext = statementScope.getErrorContext(); -errorContext.setActivity("preparing the mapped statement for execution"); -errorContext.setObjectId(this.getId()); -errorContext.setResource(this.getResource()); - -statementScope.getSession().setCommitRequired(true); - -try { - parameterObject = validateParameter(parameterObject); - - Sql sql = getSql(); - - errorContext.setMoreInfo("Check the parameter map."); - ParameterMap parameterMap = sql.getParameterMap(statementScope, parameterObject); - - errorContext.setMoreInfo("Check the result map."); - ResultMap resultMap = sql.getResultMap(statementScope, parameterObject); - - statementScope.setResultMap(resultMap); - statementScope.setParameterMap(parameterMap); - - int rows = 0; - - errorContext.setMoreInfo("Check the parameter map."); - Object[] parameters = parameterMap.getParameterObjectValues(statementScope, parameterObject); - - errorContext.setMoreInfo("Check the SQL statement."); - String sqlString = sql.getSql(statementScope, parameterObject); - - errorContext.setActivity("executing mapped statement"); - errorContext.setMoreInfo("Check the statement or the result map."); - rows = sqlExecuteUpdate(statementScope, trans.getConnection(), sqlString, parameters); - - errorContext.setMoreInfo("Check the output parameters."); - if (parameterObject != null) { -postProcessParameterObject(statementScope, parameterObject, parameters); - } - - errorContext.reset(); - sql.cleanup(statementScope); - notifyListeners(); - return rows; -} catch (SQLException e) { - errorContext.setCause(e); - throw new NestedSQLException(errorContext.toString(), e.getSQLState(), e.getErrorCode(), e); -} catch (Exception e) { - errorContext.setCause(e); - throw new NestedSQLException(errorContext.toString(), e); -} - } - - public Object executeQueryForObject(StatementScope
svn commit: r547857 - in /ibatis/trunk/java/mapper/mapper2/src/com/ibatis/common: jdbc/exception/RuntimeSQLException.java util/Stopwatch.java util/Throttle.java util/ThrottledPool.java
Author: cbegin Date: Fri Jun 15 21:02:22 2007 New Revision: 547857 URL: http://svn.apache.org/viewvc?view=rev&rev=547857 Log: removed useless classes and comments Removed: ibatis/trunk/java/mapper/mapper2/src/com/ibatis/common/util/Stopwatch.java ibatis/trunk/java/mapper/mapper2/src/com/ibatis/common/util/Throttle.java ibatis/trunk/java/mapper/mapper2/src/com/ibatis/common/util/ThrottledPool.java Modified: ibatis/trunk/java/mapper/mapper2/src/com/ibatis/common/jdbc/exception/RuntimeSQLException.java Modified: ibatis/trunk/java/mapper/mapper2/src/com/ibatis/common/jdbc/exception/RuntimeSQLException.java URL: http://svn.apache.org/viewvc/ibatis/trunk/java/mapper/mapper2/src/com/ibatis/common/jdbc/exception/RuntimeSQLException.java?view=diff&rev=547857&r1=547856&r2=547857 == --- ibatis/trunk/java/mapper/mapper2/src/com/ibatis/common/jdbc/exception/RuntimeSQLException.java (original) +++ ibatis/trunk/java/mapper/mapper2/src/com/ibatis/common/jdbc/exception/RuntimeSQLException.java Fri Jun 15 21:02:22 2007 @@ -32,7 +32,6 @@ /** * Constructor to pass along a message - * @see com.ibatis.common.exception.RuntimeException * @param msg - the message */ public RuntimeSQLException(String msg) { @@ -41,7 +40,6 @@ /** * Constructor to pass along another exception - * @see com.ibatis.common.exception.RuntimeException * @param sqlException - the exception */ public RuntimeSQLException(SQLException sqlException) { @@ -50,7 +48,6 @@ /** * Constructor to pass along a message and an exception - * @see com.ibatis.common.exception.RuntimeException * @param msg - the message * @param sqlException - the exception */