Skip to content

Commit 8bb3474

Browse files
committed
Revert "Support partially update document by entity."
This reverts commit 7e904cd.
1 parent 7e904cd commit 8bb3474

File tree

4 files changed

+3
-76
lines changed

4 files changed

+3
-76
lines changed

CONTRIBUTING.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ In order to run the tests locally with `./mvnw test` you need to have docker run
88

99
== Class names of the test classes
1010

11-
Test classes that do depend on the client have either `ERHLC` (when using the deprecated Elasticsearch `RestHighLevelClient`) or `ELC` (the new `ElasticsearchClient`) in their name.
11+
Tset classes that do depend on the client have either `ERHLC` (when using the deprecated Elasticsearch `RestHighLevelClient`) or `ELC` (the new `ElasticsearchClient`) in their name.

src/main/java/org/springframework/data/elasticsearch/core/AbstractElasticsearchTemplate.java

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@
4848
import org.springframework.data.elasticsearch.core.query.Query;
4949
import org.springframework.data.elasticsearch.core.query.SeqNoPrimaryTerm;
5050
import org.springframework.data.elasticsearch.core.query.UpdateQuery;
51-
import org.springframework.data.elasticsearch.core.query.UpdateResponse;
5251
import org.springframework.data.elasticsearch.core.routing.DefaultRoutingResolver;
5352
import org.springframework.data.elasticsearch.core.routing.RoutingResolver;
5453
import org.springframework.data.elasticsearch.support.VersionInfo;
@@ -75,7 +74,6 @@
7574
* @author Subhobrata Dey
7675
* @author Steven Pearce
7776
* @author Anton Naydenov
78-
* @author Haibo Liu
7977
*/
8078
public abstract class AbstractElasticsearchTemplate implements ElasticsearchOperations, ApplicationContextAware {
8179

@@ -307,7 +305,7 @@ public String delete(Object entity) {
307305
@Override
308306
public String delete(Object entity, IndexCoordinates index) {
309307
String entityId = getEntityId(entity);
310-
Assert.notNull(entityId, "entity must have an id that is notnull");
308+
Assert.notNull(entityId, "entity must have an if that is notnull");
311309
return this.delete(entityId, index);
312310
}
313311

@@ -470,25 +468,6 @@ public IndexCoordinates getIndexCoordinatesFor(Class<?> clazz) {
470468
return getRequiredPersistentEntity(clazz).getIndexCoordinates();
471469
}
472470

473-
@Override
474-
public <T> UpdateResponse update(T entity) {
475-
return update(this.buildUpdateQueryByEntity(entity), this.getIndexCoordinatesFor(entity.getClass()));
476-
}
477-
478-
protected <T> UpdateQuery buildUpdateQueryByEntity(T entity) {
479-
String id = this.getEntityId(entity);
480-
Assert.notNull(entity, "entity must have an id that is notnull");
481-
482-
UpdateQuery.Builder updateQueryBuilder = UpdateQuery.builder(id)
483-
.withDocument(elasticsearchConverter.mapObject(entity));
484-
485-
String routing = this.getEntityRouting(entity);
486-
if (Objects.nonNull(routing)) {
487-
updateQueryBuilder.withRouting(routing);
488-
}
489-
return updateQueryBuilder.build();
490-
}
491-
492471
protected <T> T updateIndexedObject(T entity, IndexedObjectInformation indexedObjectInformation) {
493472

494473
ElasticsearchPersistentEntity<?> persistentEntity = elasticsearchConverter.getMappingContext()
@@ -529,7 +508,7 @@ ElasticsearchPersistentEntity<?> getRequiredPersistentEntity(Class<?> clazz) {
529508
}
530509

531510
@Nullable
532-
public String getEntityId(Object entity) {
511+
private String getEntityId(Object entity) {
533512

534513
Object id = entityOperations.forEntity(entity, elasticsearchConverter.getConversionService(), routingResolver)
535514
.getId();

src/main/java/org/springframework/data/elasticsearch/core/DocumentOperations.java

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
* @author Peter-Josef Meisch
3838
* @author Farid Faoudi
3939
* @author Sijia Liu
40-
* @author Haibo Liu
4140
* @since 4.0
4241
*/
4342
public interface DocumentOperations {
@@ -308,15 +307,6 @@ default void bulkUpdate(List<UpdateQuery> queries, IndexCoordinates index) {
308307
*/
309308
ByQueryResponse delete(Query query, Class<?> clazz, IndexCoordinates index);
310309

311-
/**
312-
* Partially update a document by the given entity.
313-
*
314-
* @param entity the entity to update partially
315-
* @return the update response
316-
* @param <T> the entity type
317-
*/
318-
<T> UpdateResponse update(T entity);
319-
320310
/**
321311
* Partial update of the document.
322312
*

src/test/java/org/springframework/data/elasticsearch/core/ElasticsearchIntegrationTests.java

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,6 @@
105105
* @author Farid Faoudi
106106
* @author Peer Mueller
107107
* @author Sijia Liu
108-
* @author Haibo Liu
109108
*/
110109
@SpringIntegrationTest
111110
public abstract class ElasticsearchIntegrationTests implements NewElasticsearchClientDevelopment {
@@ -178,20 +177,6 @@ protected abstract Query getMatchAllQueryWithIncludesAndInlineExpressionScript(@
178177

179178
protected abstract Query getQueryWithRescorer();
180179

181-
@Test
182-
public void shouldThrowDataAccessExceptionIfDocumentDoesNotExistWhileDoingPartialUpdateByEntity() {
183-
184-
// given
185-
String documentId = nextIdAsString();
186-
String messageBeforeUpdate = "some test message";
187-
188-
SampleEntity sampleEntity = SampleEntity.builder().id(documentId).message(messageBeforeUpdate)
189-
.version(System.currentTimeMillis()).build();
190-
191-
assertThatThrownBy(() -> operations.update(sampleEntity))
192-
.isInstanceOf(DataAccessException.class);
193-
}
194-
195180
@Test
196181
public void shouldThrowDataAccessExceptionIfDocumentDoesNotExistWhileDoingPartialUpdate() {
197182

@@ -1514,33 +1499,6 @@ public void shouldDeleteIndexForGivenEntity() {
15141499
assertThat(indexOperations.exists()).isFalse();
15151500
}
15161501

1517-
@Test
1518-
public void shouldDoPartialUpdateBySuppliedEntityForExistingDocument() {
1519-
1520-
// given
1521-
String documentId = nextIdAsString();
1522-
String messageBeforeUpdate = "some test message";
1523-
String messageAfterUpdate = "test message";
1524-
1525-
SampleEntity sampleEntity = SampleEntity.builder().id(documentId).message(messageBeforeUpdate)
1526-
.version(System.currentTimeMillis()).build();
1527-
1528-
IndexQuery indexQuery = getIndexQuery(sampleEntity);
1529-
1530-
operations.index(indexQuery, IndexCoordinates.of(indexNameProvider.indexName()));
1531-
1532-
// modify the entity
1533-
sampleEntity.setMessage(messageAfterUpdate);
1534-
1535-
// when
1536-
operations.update(sampleEntity);
1537-
1538-
// then
1539-
SampleEntity indexedEntity = operations.get(documentId, SampleEntity.class,
1540-
IndexCoordinates.of(indexNameProvider.indexName()));
1541-
assertThat(indexedEntity.getMessage()).isEqualTo(messageAfterUpdate);
1542-
}
1543-
15441502
@Test
15451503
public void shouldDoPartialUpdateForExistingDocument() {
15461504

0 commit comments

Comments
 (0)