private void verifyFieldUniqueness() { AssertFieldNameUniquenessHandler handler = new AssertFieldNameUniquenessHandler(); doWithProperties(handler); doWithAssociations(handler); }
@Nullable @Override public MongoPersistentProperty getTextScoreProperty() { return getPersistentProperty(TextScore.class); }
@Override protected <T> BasicMongoPersistentEntity<T> createPersistentEntity(TypeInformation<T> typeInformation) { return new BasicMongoPersistentEntity<T>(typeInformation); }
/** * Creates a new {@link BasicMongoPersistentEntity} with the given {@link TypeInformation}. Will default the * collection name to the entities simple type name. * * @param typeInformation must not be {@literal null}. */ public BasicMongoPersistentEntity(TypeInformation<T> typeInformation) { super(typeInformation, MongoPersistentPropertyComparator.INSTANCE); Class<?> rawType = typeInformation.getType(); String fallback = MongoCollectionUtils.getPreferredCollectionName(rawType); if (this.isAnnotationPresent(Document.class)) { Document document = this.getRequiredAnnotation(Document.class); this.collection = StringUtils.hasText(document.collection()) ? document.collection() : fallback; this.language = StringUtils.hasText(document.language()) ? document.language() : ""; this.expression = detectExpression(document); } else { this.collection = fallback; this.language = ""; this.expression = null; } }
@Override public void doWithPersistentProperty(PersistentProperty<?> parentPersistentProperty) { String propertyName = parentPersistentProperty.getName(); IPropertyDescriptor propertyDescriptor = parentDescriptor.getPropertyDescriptor(propertyName); MongoPersistentProperty declaredPersistentProperty = entity.getPersistentProperty( PropertyHelper.toJavaBeanPropertyName(propertyName)); if (declaredPersistentProperty != null && declaredPersistentProperty.getSetter() == null && parentPersistentProperty.getSetter() != null) { try { // Some properties will be writable in parent but not locally, so we must fix their descriptor. PropertyDescriptor localDescriptor = (PropertyDescriptor) ReflectHelper.getPrivateFieldValue( AbstractPersistentProperty.class, "propertyDescriptor", declaredPersistentProperty); localDescriptor.setWriteMethod(parentPersistentProperty.getSetter()); } catch (IllegalAccessException | NoSuchFieldException | IntrospectionException e) { LOG.error("Could not extract propertyDescriptor {} from persistent class {}", propertyName, entityType.getName()); } } if (parentPersistentProperty instanceof MongoPersistentProperty && declaredPersistentProperty == null && !entityDeclaredPropertyNames.contains(propertyName) && propertyDescriptor != null && !propertyDescriptor.isComputed()) { entity.addPersistentProperty((MongoPersistentProperty) parentPersistentProperty); } } });
private void verifyFieldTypes() { doWithProperties(new PropertyTypeAssertionHandler()); }
public String getCollection() { return expression == null // ? collection // : expression.getValue(getEvaluationContext(null), String.class); }
@Override public boolean hasTextScoreProperty() { return getTextScoreProperty() != null; }
MongoPersistentProperty currentIdProperty = getIdProperty();
/** * Creates a new {@link BasicMongoPersistentEntity} with the given {@link TypeInformation}. Will default the * collection name to the entities simple type name. * * @param typeInformation must not be {@literal null}. */ public BasicMongoPersistentEntity(TypeInformation<T> typeInformation) { super(typeInformation, MongoPersistentPropertyComparator.INSTANCE); Class<?> rawType = typeInformation.getType(); String fallback = MongoCollectionUtils.getPreferredCollectionName(rawType); if (this.isAnnotationPresent(Document.class)) { Document document = this.getRequiredAnnotation(Document.class); this.collection = StringUtils.hasText(document.collection()) ? document.collection() : fallback; this.language = StringUtils.hasText(document.language()) ? document.language() : ""; this.expression = detectExpression(document); } else { this.collection = fallback; this.language = ""; this.expression = null; } }
private void verifyFieldTypes() { doWithProperties(new PropertyTypeAssertionHandler()); }
public String getCollection() { return expression == null // ? collection // : expression.getValue(getEvaluationContext(null), String.class); }
@Override public boolean hasTextScoreProperty() { return getTextScoreProperty() != null; }
MongoPersistentProperty currentIdProperty = getIdProperty();
private void verifyFieldUniqueness() { AssertFieldNameUniquenessHandler handler = new AssertFieldNameUniquenessHandler(); doWithProperties(handler); doWithAssociations(handler); }
BasicMongoPersistentEntity<?> superEntity = getPersistentEntity(superInterface); if (superEntity != null) { superEntity.doWithProperties(new SimplePropertyHandler() { @Override public void doWithPersistentProperty(PersistentProperty<?> parentPersistentProperty) {
@Nullable @Override public MongoPersistentProperty getTextScoreProperty() { return getPersistentProperty(TextScore.class); }
@Override protected <T> BasicMongoPersistentEntity<T> createPersistentEntity(TypeInformation<T> typeInformation) { return new BasicMongoPersistentEntity<T>(typeInformation); }