Package org.springframework.data.mapping.model

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


      return dbDoc;
    } else {
      try {
        return (DBObject) JSON.parse((String) objectToSave);
      } catch (JSONParseException e) {
        throw new MappingException("Could not parse given String to save into a JSON document!", e);
      }
    }
  }
View Full Code Here


    MongoPersistentEntity<?> entity = mappingContext.getPersistentEntity(objectType);
    MongoPersistentProperty idProp = entity == null ? null : entity.getIdProperty();

    if (idProp == null) {
      throw new MappingException("No id property found for object of type " + objectType);
    }

    Object idValue = BeanWrapper.create(object, mongoConverter.getConversionService())
        .getProperty(idProp, Object.class);
    return Collections.singletonMap(idProp.getFieldName(), idValue).entrySet().iterator().next();
View Full Code Here

    }

    String fieldName = fieldNamingStrategy.getFieldName(this);

    if (!StringUtils.hasText(fieldName)) {
      throw new MappingException(String.format("Invalid (null or empty) field name returned for property %s by %s!",
          this, fieldNamingStrategy.getClass()));
    }

    return fieldName;
  }
View Full Code Here

  public <T, ID extends Serializable> MongoEntityInformation<T, ID> getEntityInformation(Class<T> domainClass) {

    MongoPersistentEntity<?> entity = mappingContext.getPersistentEntity(domainClass);

    if (entity == null) {
      throw new MappingException(String.format("Could not lookup mapping metadata for domain class %s!",
          domainClass.getName()));
    }

    return new MappingMongoEntityInformation<T, ID>((MongoPersistentEntity<T>) entity);
  }
View Full Code Here

  public static void validateBindParametersCount(Parameters parameters,
      Object... parameterValues) {
    int numOfParameters = parameters.getNumberOfParameters();

    if (numOfParameters != parameterValues.length) {
      throw new MappingException(
          "Wrong Number of Parameters to bind in Query! Parameter Values size="
              + parameterValues.length
              + ", Method Bind Parameters size="
              + numOfParameters);
    }
View Full Code Here

        result = " IN ? ";
        break;
      }
     
      default: {
        throw new MappingException("No matching simpleDB operator for " + type);
      }
    }
   
    return result;
  }
View Full Code Here

        }
        try {
          wrapper.setProperty(persistentProperty, value);
        }
        catch (Exception e) {
          throw new MappingException("Could not read value " + value.toString(), e);
        }
      }
    });

    return wrapper.getBean();
View Full Code Here

          } else {
            writer.writeField(persistentProperty.getName(), propertyValue, (Class) persistentProperty.getType());
          }
        }
        catch (Exception e) {
          throw new MappingException("Could not write value for property " + persistentProperty.toString(), e);
        }
      }
    });

    GemfirePersistentProperty idProperty = entity.getIdProperty();
View Full Code Here

    }

    private Node createUniqueNode(Neo4jPersistentEntityImpl<?> persistentEntity, Object entity) {
        Neo4jPersistentProperty uniqueProperty = persistentEntity.getUniqueProperty();
        final Object value = getSerializedUniqueValue(entity, uniqueProperty);
        if (value==null) throw new MappingException("Error creating "+uniqueProperty.getOwner().getName()+" with "+entity+" unique property "+uniqueProperty.getName()+" has null value");
        final IndexInfo indexInfo = uniqueProperty.getIndexInfo();
        if (indexInfo.isLabelBased()) {
            return (indexInfo.isFailOnDuplicate())
                    ? graphDatabase.createNode(map(uniqueProperty.getName(),value),persistentEntity.getAllLabels())
                    : graphDatabase.merge(indexInfo.getIndexName(), indexInfo.getIndexKey(), value, Collections.<String,Object>emptyMap(), persistentEntity.getAllLabels());
View Full Code Here

        if (persistentEntity.isUnique()) {
            final Neo4jPersistentProperty uniqueProperty = persistentEntity.getUniqueProperty();
            final IndexInfo indexInfo = uniqueProperty.getIndexInfo();
            final Object value = uniqueProperty.getValueFromEntity(entity, MappingPolicy.MAP_FIELD_DIRECT_POLICY);
            if (value == null) {
                throw new MappingException("Error creating "+uniqueProperty.getOwner().getName()+" with "+entity+" unique property "+uniqueProperty.getName()+" has null value");
            }
            return (S) graphDatabase.getOrCreateRelationship(indexInfo.getIndexName(),indexInfo.getIndexKey(), value, startNode,endNode,relationshipType.name(), Collections.<String,Object>emptyMap());
        }
        return (S) graphDatabase.createRelationship(startNode, endNode, relationshipType, Collections.<String,Object>emptyMap());
    }
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.