Package org.g4studio.core.orm.xibatis.sqlmap.client

Examples of org.g4studio.core.orm.xibatis.sqlmap.client.SqlMapException


            if (impl instanceof TypeHandlerCallback) {
              mapping.setTypeHandler(new CustomTypeHandler((TypeHandlerCallback) impl));
            } else if (impl instanceof TypeHandler) {
              mapping.setTypeHandler((TypeHandler) impl);
            } else {
              throw new SqlMapException("The class " + value
                  + " is not a valid implementation of TypeHandler or TypeHandlerCallback");
            }
          } catch (Exception e) {
            throw new SqlMapException("Error loading class specified by handler field in " + token
                + ".  Cause: " + e, e);
          }
        } else if ("numericScale".equals(field)) {
          try {
            Integer numericScale = Integer.valueOf(value);
            if (numericScale.intValue() < 0) {
              throw new SqlMapException(
                  "Value specified for numericScale must be greater than or equal to zero");
            }
            mapping.setNumericScale(numericScale);
          } catch (NumberFormatException e) {
            throw new SqlMapException("Value specified for numericScale is not a valid Integer");
          }
        } else {
          throw new SqlMapException("Unrecognized parameter mapping field: '" + field + "' in " + token);
        }
      } else {
        throw new SqlMapException("Incorrect inline parameter map format (missmatched name=value pairs): "
            + token);
      }
    }

    if (mapping.getTypeHandler() == null) {
View Full Code Here


          handler = resolveTypeHandler(typeHandlerFactory, parameterClass, name, null, type);
        }
        mapping.setTypeHandler(handler);
        return mapping;
      } else {
        throw new SqlMapException("Incorrect inline parameter map format: " + token);
      }
    } else {
      mapping.setPropertyName(token);
      TypeHandler handler;
      if (parameterClass == null) {
View Full Code Here

        try {
          javaType = typeHandlerFactory.resolveAlias(javaType);
          Class javaClass = Resources.classForName(javaType);
          handler = typeHandlerFactory.getTypeHandler(javaClass, jdbcType);
        } catch (Exception e) {
          throw new SqlMapException("Error.  Could not set TypeHandler.  Cause: " + e, e);
        }
      }
    } else if (typeHandlerFactory.getTypeHandler(clazz, jdbcType) != null) {
      // Primitive
      handler = typeHandlerFactory.getTypeHandler(clazz, jdbcType);
    } else {
      // JavaBean
      if (javaType == null) {

        Class type = PROBE.getPropertyTypeForGetter(clazz, propertyName);
        handler = typeHandlerFactory.getTypeHandler(type, jdbcType);

      } else {
        try {
          javaType = typeHandlerFactory.resolveAlias(javaType);
          Class javaClass = Resources.classForName(javaType);
          handler = typeHandlerFactory.getTypeHandler(javaClass, jdbcType);
        } catch (Exception e) {
          throw new SqlMapException("Error.  Could not set TypeHandler.  Cause: " + e, e);
        }
      }
    }
    return handler;
  }
View Full Code Here

        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);
    }
  }
View Full Code Here

    return super.setResultObjectValues(statementScope, resultObject, values);
  }

  private void initialize(ResultSet rs) {
    if (getResultClass() == null) {
      throw new SqlMapException("The automatic ResultMap named " + this.getId()
          + " had a null result class (not allowed).");
    } else if (Map.class.isAssignableFrom(getResultClass())) {
      initializeMapResults(rs);
    } else if (getDelegate().getTypeHandlerFactory().getTypeHandler(getResultClass()) != null) {
      initializePrimitiveResults(rs);
View Full Code Here

    }
  }

  public void setDiscriminator(Discriminator discriminator) {
    if (this.discriminator != null) {
      throw new SqlMapException("A discriminator may only be set once per result map.");
    }
    this.discriminator = discriminator;
  }
View Full Code Here

    for (int i = 0; i < getResultMappings().length; i++) {
      ResultMapping mapping = (ResultMapping) 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

          if (Collection.class.isAssignableFrom(type)) {
            obj = ResultObjectFactoryUtil.createObjectThroughFactory(type);
            PROBE.setObject(resultObject, propertyName, obj);
          }
        } catch (Exception e) {
          throw new SqlMapException("Error instantiating collection property for mapping '"
              + mapping.getPropertyName() + "'.  Cause: " + e, e);
        }
      }

      // JIRA 375
      // "Provide a way for not creating items from nested ResultMaps when the items contain only null values"
      boolean subResultObjectAbsent = false;
      if (mapping.getNotNullColumn() != null) {
        if (statementScope.getResultSet().getObject(mapping.getNotNullColumn()) == null) {
          subResultObjectAbsent = true;
        }
      }
      if (!subResultObjectAbsent) {
        values = resultMap.getResults(statementScope, statementScope.getResultSet());
        if (statementScope.isRowDataFound()) {
          Object o = resultMap.setResultObjectValues(statementScope, 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

TOP

Related Classes of org.g4studio.core.orm.xibatis.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.