Field currentIdPropertyField = currentIdProperty.getField(); + "as explicit id. Check your mapping configuration!", property.getField(), currentIdPropertyField)); throw new MappingException( String.format("Attempt to add id property %s but already have an property %s registered " + "as id. Check your mapping configuration!", property.getField(), currentIdPropertyField));
@Override public void partialUpdate(T t) { ID id = getEntityInformation().getId(t); if (null == id) { throw new IllegalArgumentException("ID property should not be null"); } Update update = new Update(); final MongoPersistentEntity<?> persistentEntity = mongoOperations .getConverter().getMappingContext().getPersistentEntity(getEntityInformation().getJavaType()); persistentEntity.doWithProperties((PropertyHandler<MongoPersistentProperty>) persistentProperty -> { if (!persistentEntity.isIdProperty(persistentProperty)) { Object value = Accessible.on(t).field(persistentProperty.getField()).getValue(); if (null != value) { update.set(persistentProperty.getFieldName(), value); } } }); WriteResult writeResult = mongoOperations .updateFirst(query(where(persistentEntity.getIdProperty().getFieldName()).is(id)), update, getEntityInformation().getCollectionName()); if (1 != writeResult.getN()) { throw new IncorrectResultSizeDataAccessException(1, writeResult.getN()); } }
private static void potentiallyAssertDBRefTargetType(MongoPersistentProperty persistentProperty) { if (persistentProperty.isDbReference() && persistentProperty.getDBRef().lazy()) { if (persistentProperty.isArray() || Modifier.isFinal(persistentProperty.getActualType().getModifiers())) { throw new MappingException(String.format( "Invalid lazy DBRef property for %s. Found %s which must not be an array nor a final class.", persistentProperty.getField(), persistentProperty.getActualType())); } } }
private static void assertPropertyType(MongoPersistentProperty persistentProperty, Class<?>... validMatches) { for (Class<?> potentialMatch : validMatches) { if (ClassUtils.isAssignable(potentialMatch, persistentProperty.getActualType())) { return; } } throw new MappingException( String.format("Missmatching types for %s. Found %s expected one of %s.", persistentProperty.getField(), persistentProperty.getActualType(), StringUtils.arrayToCommaDelimitedString(validMatches))); } }
private static void potentiallyAssertDBRefTargetType(MongoPersistentProperty persistentProperty) { if (persistentProperty.isDbReference() && persistentProperty.getDBRef().lazy()) { if (persistentProperty.isArray() || Modifier.isFinal(persistentProperty.getActualType().getModifiers())) { throw new MappingException(String.format( "Invalid lazy DBRef property for %s. Found %s which must not be an array nor a final class.", persistentProperty.getField(), persistentProperty.getActualType())); } } }
Field currentIdPropertyField = currentIdProperty.getField(); + "as explicit id. Check your mapping configuration!", property.getField(), currentIdPropertyField)); throw new MappingException( String.format("Attempt to add id property %s but already have an property %s registered " + "as id. Check your mapping configuration!", property.getField(), currentIdPropertyField));
private static void assertPropertyType(MongoPersistentProperty persistentProperty, Class<?>... validMatches) { for (Class<?> potentialMatch : validMatches) { if (ClassUtils.isAssignable(potentialMatch, persistentProperty.getActualType())) { return; } } throw new MappingException( String.format("Missmatching types for %s. Found %s expected one of %s.", persistentProperty.getField(), persistentProperty.getActualType(), StringUtils.arrayToCommaDelimitedString(validMatches))); } }