@Override public boolean isIdField() { MongoPersistentProperty idProperty = (property != null && property.isIdProperty()) ? property : entity.getIdProperty(); if (idProperty != null) { return name.equals(idProperty.getName()) || name.equals(idProperty.getFieldName()) || name.endsWith("." + idProperty.getName()) || name.endsWith("." + idProperty.getFieldName()); } return DEFAULT_ID_NAMES.contains(name); }
private boolean isIdField(Field documentField) { return documentField.getProperty() != null && documentField.getProperty().isIdProperty(); }
@Override protected String asDBKey(@Nullable Operation<?> expr, int index) { Expression<?> arg = expr.getArg(index); String key = super.asDBKey(expr, index); if (!(arg instanceof Path)) { return key; } Path<?> path = (Path<?>) arg; if (!isReference(path)) { return key; } MongoPersistentProperty property = getPropertyFor(path); return property.isIdProperty() ? key.replaceAll("." + ID_KEY + "$", "") : key; }
if (associationDetected && !property.isIdProperty()) { throw new MappingException(String.format(INVALID_ASSOCIATION_REFERENCE, pathExpression));
protected Object convert(@Nullable Path<?> path, @Nullable Constant<?> constant) { if (!isReference(path)) { return super.convert(path, constant); } MongoPersistentProperty property = getPropertyFor(path); return property.isIdProperty() ? asReference(constant.getConstant(), path.getMetadata().getParent()) : asReference(constant.getConstant(), path); }
/** * Checks the given {@literal path} for referencing the {@literal id} property of a {@link DBRef} referenced object. * If so it returns the referenced {@link MongoPersistentProperty} of the {@link DBRef} instead of the {@literal id} * property. * * @param path * @return */ private MongoPersistentProperty getPropertyForPotentialDbRef(Path<?> path) { if (path == null) { return null; } MongoPersistentProperty property = getPropertyFor(path); PathMetadata metadata = path.getMetadata(); if (property != null && property.isIdProperty() && metadata != null && metadata.getParent() != null) { return getPropertyFor(metadata.getParent()); } return property; } }
if (!property.isIdProperty()) { return null;
property != null && property.isIdProperty() ? property.getFieldType() : ObjectId.class);
@Override public boolean isIdField() { MongoPersistentProperty idProperty = (property != null && property.isIdProperty()) ? property : entity.getIdProperty(); if (idProperty != null) { return name.equals(idProperty.getName()) || name.equals(idProperty.getFieldName()) || name.endsWith("." + idProperty.getName()) || name.endsWith("." + idProperty.getFieldName()); } return DEFAULT_ID_NAMES.contains(name); }
@Override protected String asDBKey(@Nullable Operation<?> expr, int index) { Expression<?> arg = expr.getArg(index); String key = super.asDBKey(expr, index); if (!(arg instanceof Path)) { return key; } Path<?> path = (Path<?>) arg; if (!isReference(path)) { return key; } MongoPersistentProperty property = getPropertyFor(path); return property.isIdProperty() ? key.replaceAll("." + ID_KEY + "$", "") : key; }
if (associationDetected && !property.isIdProperty()) { throw new MappingException(String.format(INVALID_ASSOCIATION_REFERENCE, pathExpression));
protected Object convert(@Nullable Path<?> path, @Nullable Constant<?> constant) { if (!isReference(path)) { return super.convert(path, constant); } MongoPersistentProperty property = getPropertyFor(path); return property.isIdProperty() ? asReference(constant.getConstant(), path.getMetadata().getParent()) : asReference(constant.getConstant(), path); }
if (!property.isIdProperty()) { return null;
/** * Checks the given {@literal path} for referencing the {@literal id} property of a {@link DBRef} referenced object. * If so it returns the referenced {@link MongoPersistentProperty} of the {@link DBRef} instead of the {@literal id} * property. * * @param path * @return */ private MongoPersistentProperty getPropertyForPotentialDbRef(Path<?> path) { if (path == null) { return null; } MongoPersistentProperty property = getPropertyFor(path); PathMetadata metadata = path.getMetadata(); if (property != null && property.isIdProperty() && metadata != null && metadata.getParent() != null) { return getPropertyFor(metadata.getParent()); } return property; } }