Example usage for org.springframework.data.elasticsearch.core.mapping ElasticsearchPersistentEntity getPropertyAccessor

List of usage examples for org.springframework.data.elasticsearch.core.mapping ElasticsearchPersistentEntity getPropertyAccessor

Introduction

In this page you can find the example usage for org.springframework.data.elasticsearch.core.mapping ElasticsearchPersistentEntity getPropertyAccessor.

Prototype

<B> PersistentPropertyAccessor<B> getPropertyAccessor(B bean);

Source Link

Document

Returns a PersistentPropertyAccessor to access property values of the given bean.

Usage

From source file:org.springframework.data.elasticsearch.core.DefaultResultMapper.java

private <T> void setPersistentEntityId(T result, String id, Class<T> clazz) {

    if (mappingContext != null && clazz.isAnnotationPresent(Document.class)) {

        ElasticsearchPersistentEntity<?> persistentEntity = mappingContext.getPersistentEntity(clazz);
        PersistentProperty<?> idProperty = persistentEntity.getIdProperty();

        // Only deal with String because ES generated Ids are strings !
        if (idProperty != null && idProperty.getType().isAssignableFrom(String.class)) {
            persistentEntity.getPropertyAccessor(result).setProperty(idProperty, id);
        }//from w w w.ja  v a  2 s. c  o m
    }
}