/** * Also considers fields as id that are of supported id type and name. * * @see #SUPPORTED_ID_PROPERTY_NAMES * @see #SUPPORTED_ID_TYPES */ @Override public boolean isIdProperty() { if (super.isIdProperty()) { return true; } // We need to support a wider range of ID types than just the ones that can be converted to an ObjectId // but still we need to check if there happens to be an explicit name set return SUPPORTED_ID_PROPERTY_NAMES.contains(getName()) && !hasExplicitFieldName(); }
/** * 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; }
/** * Also considers fields as id that are of supported id type and name. * * @see #SUPPORTED_ID_PROPERTY_NAMES * @see #SUPPORTED_ID_TYPES */ @Override public boolean isIdProperty() { if (super.isIdProperty()) { return true; } // We need to support a wider range of ID types than just the ones that can be converted to an ObjectId // but still we need to check if there happens to be an explicit name set return SUPPORTED_ID_PROPERTY_NAMES.contains(getName()) && !hasExplicitFieldName(); }
/** * 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; }