Package org.springframework.data.mapping.model

Examples of org.springframework.data.mapping.model.MappingException


    wrappedNestedEntity = new EntityWrapper<T, ID>(entityMetadata, true);

    try {
      getField().set(getParentEntity(), wrappedNestedEntity.getItem());
    } catch(IllegalArgumentException e) {
      throw new MappingException("Could not instantiate object", e);
    } catch(IllegalAccessException e) {
      throw new MappingException("Could not instantiate object", e);
    }
  }
View Full Code Here


  public <T> T unmarshall(String jsonString, Class<?> objectType) {
    Assert.notNull(jsonString);
    try {
      return (T) jsonMapper.readValue(jsonString, objectType);
    } catch(IOException e) {
      throw new MappingException("Could not unmarshall object : " + jsonString, e);
    }
  }
View Full Code Here

    jsonMapper = new ObjectMapper().setVisibility(JsonMethod.FIELD, JsonAutoDetect.Visibility.ANY);
    jsonMapper.enableDefaultTypingAsProperty(ObjectMapper.DefaultTyping.NON_FINAL, "@class");
    try {
      return jsonMapper.writeValueAsString(input);
    } catch(Exception e) {
      throw new MappingException(e.getMessage(), e);
    }
  }
View Full Code Here

    if(idField != null) {
      try {
        idField.setAccessible(true);
        return (String) idField.get(object);
      } catch(IllegalAccessException e) {
        throw new MappingException("Could not read simpleDb id field", e);
      }
    }

    return null;
  }
View Full Code Here

    for(Field f : ReflectionUtils.getDeclaredFieldsInHierarchy(clazz)) {
      // named id or annotated with Id
      if(f.getName().equals(FIELD_NAME_DEFAULT_ID) || f.getAnnotation(Id.class) != null) {
        if(idField != null) {
          throw new MappingException("Multiple id fields detected for class " + clazz.getName());
        }
        idField = f;
      }

    }
View Full Code Here

    Object newInstance;
    try {
      newInstance = getField().getType().newInstance();
      getField().set(getParentEntity(), newInstance);
    } catch(InstantiationException e) {
      throw new MappingException("Could not instantiate object", e);
    } catch(IllegalAccessException e) {
      throw new MappingException("Could not instantiate object", e);
    }
  }
View Full Code Here

    this.entityInformation = entityInformation;
    try {
      this.item = entityInformation.getJavaType().newInstance();
      createFieldWrappers(true, isNested);
    } catch(InstantiationException e) {
      throw new MappingException("Could not instantiate object", e);
    } catch(IllegalAccessException e) {
      throw new MappingException("Could not instantiate object", e);
    }
  }
View Full Code Here

          item.getClass(),
          entityInformation.getItemNameFieldName(item));
      idField.setAccessible(Boolean.TRUE);
      idField.set(item, itemName);
    } catch(NoSuchFieldException e) {
      throw new MappingException("Could not set id field", e);
    } catch(IllegalAccessException e) {
      throw new MappingException("Could not set id field", e);
    }
  }
View Full Code Here

  /**
   * Unsed to encode a Not Integer {@link Number}.
   */
  public static String encodeAsRealNumber(Object ob) {
    if(AmazonSimpleDBUtil.isNaN(ob) || AmazonSimpleDBUtil.isInfinite(ob)) {
      throw new MappingException("Could not serialize NaN or Infinity values");
    }

    BigDecimal realBigDecimal = AmazonSimpleDBUtil.tryToStoreAsRealBigDecimal(ob);
    if(realBigDecimal != null) {
      return AmazonSimpleDBUtil.encodeRealNumberRange(realBigDecimal, AmazonSimpleDBUtil.LONG_DIGITS,
View Full Code Here

    return null;
  }

  public static BigDecimal decodeRealNumber(String value) {
    if(value.matches(".*Infinity|NaN")) {
      throw new MappingException("Could not serialize NaN or Infinity values");
    }

    return AmazonSimpleDBUtil.decodeRealNumberRange(value, AmazonSimpleDBUtil.LONG_DIGITS, OFFSET_VALUE);
  }
View Full Code Here

TOP

Related Classes of org.springframework.data.mapping.model.MappingException

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.