@Override public boolean isIdProperty() { if (this.isIdProperty == null) { this.isIdProperty = super.isIdProperty(); } return this.isIdProperty; }
/** * Creates a new {@link BasicMongoPersistentProperty}. * * @param property * @param owner * @param simpleTypeHolder * @param fieldNamingStrategy */ public BasicMongoPersistentProperty(Property property, MongoPersistentEntity<?> owner, SimpleTypeHolder simpleTypeHolder, @Nullable FieldNamingStrategy fieldNamingStrategy) { super(property, owner, simpleTypeHolder); this.fieldNamingStrategy = fieldNamingStrategy == null ? PropertyNameFieldNamingStrategy.INSTANCE : fieldNamingStrategy; if (isIdProperty() && getFieldName() != ID_FIELD_NAME) { LOG.warn("Customizing field name for id property not allowed! Custom name will not be considered!"); } }
/** * Returns the key to be used to store the value of the property inside a Mongo {@link org.bson.Document}. * * @return */ public String getFieldName() { if (isIdProperty()) { if (getOwner().getIdProperty() == null) { return ID_FIELD_NAME; } if (getOwner().isIdProperty(this)) { return ID_FIELD_NAME; } } if (hasExplicitFieldName()) { return getAnnotatedFieldName(); } 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; }
@Override public Class<?> getFieldType() { if (!isIdProperty()) { return getType(); } MongoId idAnnotation = findAnnotation(MongoId.class); if (idAnnotation == null) { return FieldType.OBJECT_ID.getJavaClass(); } FieldType fieldType = idAnnotation.targetType(); if (fieldType == FieldType.IMPLICIT) { return getType(); } return fieldType.getJavaClass(); }
@Override public boolean isIdProperty() { if (this.isIdProperty == null) { this.isIdProperty = super.isIdProperty(); } return this.isIdProperty; }
/** * Creates a new {@link BasicMongoPersistentProperty}. * * @param field * @param propertyDescriptor * @param owner * @param simpleTypeHolder * @param fieldNamingStrategy */ public BasicMongoPersistentProperty(Property property, MongoPersistentEntity<?> owner, SimpleTypeHolder simpleTypeHolder, @Nullable FieldNamingStrategy fieldNamingStrategy) { super(property, owner, simpleTypeHolder); this.fieldNamingStrategy = fieldNamingStrategy == null ? PropertyNameFieldNamingStrategy.INSTANCE : fieldNamingStrategy; if (isIdProperty() && getFieldName() != ID_FIELD_NAME) { LOG.warn("Customizing field name for id property not allowed! Custom name will not be considered!"); } }
/** * Returns the key to be used to store the value of the property inside a Mongo {@link org.bson.Document}. * * @return */ public String getFieldName() { if (isIdProperty()) { if (getOwner().getIdProperty() == null) { return ID_FIELD_NAME; } if (getOwner().isIdProperty(this)) { return ID_FIELD_NAME; } } if (hasExplicitFieldName()) { return getAnnotatedFieldName(); } 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; }