reverted changes for auto-generated Id , added test cases for scan and scroll

This commit is contained in:
Mohsin Husen
2013-03-19 18:05:20 +00:00
parent 41de820c70
commit e433ec2d9e
3 changed files with 75 additions and 13 deletions

View File

@@ -388,15 +388,8 @@ public class ElasticsearchTemplate implements ElasticsearchOperations {
String type = isBlank(query.getType())?
retrieveTypeFromPersistentEntity(query.getObject().getClass())[0] : query.getType();
IndexRequestBuilder indexRequestBuilder = null;
if(query.getId() != null){
indexRequestBuilder = client.prepareIndex(indexName,type,query.getId());
}else {
indexRequestBuilder = client.prepareIndex(indexName,type);
}
indexRequestBuilder.setSource(objectMapper.writeValueAsString(query.getObject()));
IndexRequestBuilder indexRequestBuilder = client.prepareIndex(indexName,type,query.getId())
.setSource(objectMapper.writeValueAsString(query.getObject()));
if(query.getVersion() != null){
indexRequestBuilder.setVersion(query.getVersion());

View File

@@ -58,13 +58,10 @@ public class MappingElasticsearchEntityInformation<T, ID extends Serializable> e
public ID getId(T entity) {
ElasticsearchPersistentProperty id = entityMetadata.getIdProperty();
try {
if(id != null){
return (ID) BeanWrapper.create(entity, null).getProperty(id);
}
return (ID) BeanWrapper.create(entity, null).getProperty(id);
} catch (Exception e) {
throw new IllegalStateException("ID could not be resolved", e);
}
return null;
}
@SuppressWarnings("unchecked")