Package com.ibatis.sqlmap.client

Examples of com.ibatis.sqlmap.client.SqlMapException


    for (int i = 0; i < getResultMappings().length; i++) {
      BasicResultMapping mapping = (BasicResultMapping) getResultMappings()[i];
      errorContext.setMoreInfo(mapping.getErrorString());
      if (mapping.getStatementName() != null) {
        if (resultClass == null) {
          throw new SqlMapException("The result class was null when trying to get results for ResultMap named " + getId() + ".");
        } else if (Map.class.isAssignableFrom(resultClass)) {
          Class javaType = mapping.getJavaType();
          if (javaType == null) {
            javaType = Object.class;
          }
View Full Code Here


            obj = ResultObjectFactoryUtil.createObjectThroughFactory(client.getResultObjectFactory(),
                request.getStatement().getId(), type);
            PROBE.setObject(resultObject, propertyName, obj);
          }
        } catch (Exception e) {
          throw new SqlMapException("Error instantiating collection property for mapping '" + mapping.getPropertyName() + "'.  Cause: " + e, e);
        }
      }

      values = resultMap.getResults(request, request.getResultSet());
      if (request.isRowDataFound()) {
        Object o = resultMap.setResultObjectValues(request, null, values);
        if (o != NO_VALUE) {
          if (obj != null && obj instanceof Collection) {
            ((Collection) obj).add(o);
          } else {
            PROBE.setObject(resultObject, propertyName, o);
          }
        }
      }
    } catch (SQLException e) {
      throw new SqlMapException("Error getting nested result map values for '" + mapping.getPropertyName() + "'.  Cause: " + e, e);
    }
  }
View Full Code Here

        value = typeHandler.getResult(rs, columnIndex);
      } else {
        value = typeHandler.getResult(rs, columnName);
      }
    } else {
      throw new SqlMapException("No type handler could be found to map the property '" + mapping.getPropertyName() + "' to the column '" + mapping.getColumnName() + "'.  One or both of the types, or the combination of types is not supported.");
    }
    return value;
  }
View Full Code Here

            String nullValue = mapping.getNullValue();
            if ( nullValue != null )
              value = typeHandler.valueOf(nullValue);
            return value;
          } else {
            throw new SqlMapException("No type handler could be found to map the property '" + mapping.getPropertyName() + "' to the column '" + mapping.getColumnName() + "'.  One or both of the types, or the combination of types is not supported.");
          }
      }
      else  {
        return value;
      }
View Full Code Here

  private void validateStatement() {
    try {
      delegate.getMappedStatement(statementName);
    } catch (Exception e) {
      throw new SqlMapException("Invalid bound statement (not found): " + statementName);
    }

    if (StatementType.UNKNOWN == type || StatementType.PROCEDURE == type) {
      throw new SqlMapException("Unkown statement type for statement: " + statementName);
    }
  }
View Full Code Here

//        }
      }
    }
    if (argCount > 1 && type != StatementType.SELECT) {
      // Only select statements can have multiple parameters
      throw new SqlMapException("Too many parameters for statement (must be 1 or 0): " + statementName);
    }
  }
View Full Code Here

        result = executeForMap(args);
      } else {
        result = executeForObject(args);
      }
    } else {
      throw new SqlMapException("Unkown execution method for: " + statementName);
    }

    return result;
  }
View Full Code Here

        Context ctx = (Context) initCtx.lookup((String) properties.get("DBInitialContext"));
        dataSource = (DataSource) ctx.lookup((String) properties.get("DBLookup"));
      }

    } catch (NamingException e) {
      throw new SqlMapException("There was an error configuring JndiDataSourceDaoTransactionPool. Cause: " + e, e);
    }
  }
View Full Code Here

          parameterClassName = vars.typeHandlerFactory.resolveAlias(parameterClassName);
          Class parameterClass = Resources.classForName(parameterClassName);
          statement.setParameterClass(parameterClass);
        }
      } catch (ClassNotFoundException e) {
        throw new SqlMapException("Error.  Could not set parameter class.  Cause: " + e, e);
      }
    } else {
      statement.setParameterClass(parameterMap.getParameterClass());
    }

    // process SQL statement, including inline parameter maps
    vars.errorCtx.setMoreInfo("Check the SQL statement.");
    processSqlStatement(node, statement);

    // set up either null result map or automatic result mapping
    BasicResultMap resultMap = (BasicResultMap)statement.getResultMap();
    if (resultMap == null && resultClassName == null) {
      statement.setResultMap(null);
    } else if (resultMap == null) {
      String firstResultClass = getFirstToken(resultClassName);
      resultMap = buildAutoResultMap(allowRemapping, statement, firstResultClass, xmlResultName);
      statement.setResultMap(resultMap);
      String[] additionalResultClasses = getAllButFirstToken(resultClassName);
      for (int i=0; i<additionalResultClasses.length; i++) {
        statement.addResultMap(buildAutoResultMap(allowRemapping, statement, additionalResultClasses[i],xmlResultName));
      }
     
    }

    statement.setTimeout(vars.defaultStatementTimeout);
    if (timeout != null) {
      try {
        statement.setTimeout(Integer.valueOf(timeout));
      } catch (NumberFormatException e) {
        throw new SqlMapException("Specified timeout value for statement "
            + statement.getId() + " is not a valid integer");
      }
    }

    vars.errorCtx.setMoreInfo(null);
View Full Code Here

        return Resources.classForName(vars.typeHandlerFactory.resolveAlias(resultClassName));
      } else {
        return null;
      }
    } catch (ClassNotFoundException e) {
      throw new SqlMapException("Error.  Could not set result class.  Cause: " + e, e);
    }
  }
View Full Code Here

TOP

Related Classes of com.ibatis.sqlmap.client.SqlMapException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.