diff --git a/src/main/java/org/springframework/data/couchbase/core/CouchbaseTemplateSupport.java b/src/main/java/org/springframework/data/couchbase/core/CouchbaseTemplateSupport.java index 53f136e6f..4b0c93332 100644 --- a/src/main/java/org/springframework/data/couchbase/core/CouchbaseTemplateSupport.java +++ b/src/main/java/org/springframework/data/couchbase/core/CouchbaseTemplateSupport.java @@ -87,7 +87,7 @@ public CouchbaseDocument encodeEntity(final Object entityToEncode) { } @Override - public T decodeEntity(String id, String source, Long cas, Class entityClass, String scope, String collection) { + public T decodeEntity(Object id, String source, Long cas, Class entityClass, String scope, String collection) { // this is the entity class defined for the repository. It may not be the class of the document that was read // we will reset it after reading the document @@ -146,7 +146,7 @@ public T decodeEntity(String id, String source, Long cas, Class entityCla if (cas != null && cas != 0 && persistentEntity.getVersionProperty() != null) { accessor.setProperty(persistentEntity.getVersionProperty(), cas); } - N1qlJoinResolver.handleProperties(persistentEntity, accessor, template.reactive(), id, scope, collection); + N1qlJoinResolver.handleProperties(persistentEntity, accessor, template.reactive(), id.toString(), scope, collection); return accessor.getBean(); } diff --git a/src/main/java/org/springframework/data/couchbase/core/NonReactiveSupportWrapper.java b/src/main/java/org/springframework/data/couchbase/core/NonReactiveSupportWrapper.java index 7cb19f82d..edf85db33 100644 --- a/src/main/java/org/springframework/data/couchbase/core/NonReactiveSupportWrapper.java +++ b/src/main/java/org/springframework/data/couchbase/core/NonReactiveSupportWrapper.java @@ -40,7 +40,7 @@ public Mono encodeEntity(Object entityToEncode) { } @Override - public Mono decodeEntity(String id, String source, Long cas, Class entityClass, String scope, + public Mono decodeEntity(Object id, String source, Long cas, Class entityClass, String scope, String collection) { return Mono.fromSupplier(() -> support.decodeEntity(id, source, cas, entityClass, scope, collection)); } diff --git a/src/main/java/org/springframework/data/couchbase/core/ReactiveCouchbaseTemplateSupport.java b/src/main/java/org/springframework/data/couchbase/core/ReactiveCouchbaseTemplateSupport.java index 3b02905dd..067b2366f 100644 --- a/src/main/java/org/springframework/data/couchbase/core/ReactiveCouchbaseTemplateSupport.java +++ b/src/main/java/org/springframework/data/couchbase/core/ReactiveCouchbaseTemplateSupport.java @@ -86,7 +86,7 @@ public Mono encodeEntity(final Object entityToEncode) { } @Override - public Mono decodeEntity(String id, String source, Long cas, Class entityClass, String scope, + public Mono decodeEntity(Object id, String source, Long cas, Class entityClass, String scope, String collection) { return Mono.fromSupplier(() -> { // this is the entity class defined for the repository. It may not be the class of the document that was read @@ -118,7 +118,7 @@ public Mono decodeEntity(String id, String source, Long cas, Class ent + TemplateUtils.SELECT_ID); } - final CouchbaseDocument converted = new CouchbaseDocument(id); + final CouchbaseDocument converted = new CouchbaseDocument(id.toString()); // if possible, set the version property in the source so that if the constructor has a long version argument, // it will have a value and not fail (as null is not a valid argument for a long argument). This possible failure @@ -146,7 +146,7 @@ public Mono decodeEntity(String id, String source, Long cas, Class ent if (cas != null && cas != 0 && persistentEntity.getVersionProperty() != null) { accessor.setProperty(persistentEntity.getVersionProperty(), cas); } - N1qlJoinResolver.handleProperties(persistentEntity, accessor, template, id, scope, collection); + N1qlJoinResolver.handleProperties(persistentEntity, accessor, template, id.toString(), scope, collection); return accessor.getBean(); }); } diff --git a/src/main/java/org/springframework/data/couchbase/core/ReactiveInsertByIdOperationSupport.java b/src/main/java/org/springframework/data/couchbase/core/ReactiveInsertByIdOperationSupport.java index 0d319fb4a..ae448193a 100644 --- a/src/main/java/org/springframework/data/couchbase/core/ReactiveInsertByIdOperationSupport.java +++ b/src/main/java/org/springframework/data/couchbase/core/ReactiveInsertByIdOperationSupport.java @@ -84,7 +84,7 @@ public Mono one(T object) { return Mono.just(object).flatMap(support::encodeEntity) .flatMap(converted -> template.getCouchbaseClientFactory().withScope(pArgs.getScope()) .getCollection(pArgs.getCollection()).reactive() - .insert(converted.getId(), converted.export(), buildOptions(pArgs.getOptions(), converted)) + .insert(converted.getId().toString(), converted.export(), buildOptions(pArgs.getOptions(), converted)) .flatMap(result -> support.applyUpdatedId(object, converted.getId()) .flatMap(updatedObject -> support.applyUpdatedCas(updatedObject, converted, result.cas())))) .onErrorMap(throwable -> { diff --git a/src/main/java/org/springframework/data/couchbase/core/ReactiveReplaceByIdOperationSupport.java b/src/main/java/org/springframework/data/couchbase/core/ReactiveReplaceByIdOperationSupport.java index ba96de24c..8f7f78e86 100644 --- a/src/main/java/org/springframework/data/couchbase/core/ReactiveReplaceByIdOperationSupport.java +++ b/src/main/java/org/springframework/data/couchbase/core/ReactiveReplaceByIdOperationSupport.java @@ -84,7 +84,7 @@ public Mono one(T object) { return Mono.just(object).flatMap(support::encodeEntity) .flatMap(converted -> template.getCouchbaseClientFactory().withScope(pArgs.getScope()) .getCollection(pArgs.getCollection()).reactive() - .replace(converted.getId(), converted.export(), + .replace(converted.getId().toString(), converted.export(), buildReplaceOptions(pArgs.getOptions(), object, converted)) .flatMap(result -> support.applyUpdatedCas(object, converted, result.cas()))) .onErrorMap(throwable -> { diff --git a/src/main/java/org/springframework/data/couchbase/core/ReactiveTemplateSupport.java b/src/main/java/org/springframework/data/couchbase/core/ReactiveTemplateSupport.java index 69d5db015..06ffc81a6 100644 --- a/src/main/java/org/springframework/data/couchbase/core/ReactiveTemplateSupport.java +++ b/src/main/java/org/springframework/data/couchbase/core/ReactiveTemplateSupport.java @@ -27,7 +27,7 @@ public interface ReactiveTemplateSupport { Mono encodeEntity(Object entityToEncode); - Mono decodeEntity(String id, String source, Long cas, Class entityClass, String scope, String collection); + Mono decodeEntity(Object id, String source, Long cas, Class entityClass, String scope, String collection); Mono applyUpdatedCas(T entity, CouchbaseDocument converted, long cas); diff --git a/src/main/java/org/springframework/data/couchbase/core/ReactiveUpsertByIdOperationSupport.java b/src/main/java/org/springframework/data/couchbase/core/ReactiveUpsertByIdOperationSupport.java index e84fe1fca..a50afa0ed 100644 --- a/src/main/java/org/springframework/data/couchbase/core/ReactiveUpsertByIdOperationSupport.java +++ b/src/main/java/org/springframework/data/couchbase/core/ReactiveUpsertByIdOperationSupport.java @@ -84,7 +84,7 @@ public Mono one(T object) { return Mono.just(object).flatMap(support::encodeEntity) .flatMap(converted -> template.getCouchbaseClientFactory().withScope(pArgs.getScope()) .getCollection(pArgs.getCollection()).reactive() - .upsert(converted.getId(), converted.export(), buildUpsertOptions(pArgs.getOptions(), converted)) + .upsert(converted.getId().toString(), converted.export(), buildUpsertOptions(pArgs.getOptions(), converted)) .flatMap(result -> support.applyUpdatedId(object, converted.getId()) .flatMap(updatedObject -> support.applyUpdatedCas(updatedObject, converted, result.cas())))) .onErrorMap(throwable -> { diff --git a/src/main/java/org/springframework/data/couchbase/core/TemplateSupport.java b/src/main/java/org/springframework/data/couchbase/core/TemplateSupport.java index bd5ab0ae9..4f62129d6 100644 --- a/src/main/java/org/springframework/data/couchbase/core/TemplateSupport.java +++ b/src/main/java/org/springframework/data/couchbase/core/TemplateSupport.java @@ -26,7 +26,7 @@ public interface TemplateSupport { CouchbaseDocument encodeEntity(Object entityToEncode); - T decodeEntity(String id, String source, Long cas, Class entityClass, String scope, String collection); + T decodeEntity(Object id, String source, Long cas, Class entityClass, String scope, String collection); T applyUpdatedCas(T entity, CouchbaseDocument converted, long cas); diff --git a/src/main/java/org/springframework/data/couchbase/core/mapping/CouchbaseDocument.java b/src/main/java/org/springframework/data/couchbase/core/mapping/CouchbaseDocument.java index ead8146ed..cf9bbe58e 100644 --- a/src/main/java/org/springframework/data/couchbase/core/mapping/CouchbaseDocument.java +++ b/src/main/java/org/springframework/data/couchbase/core/mapping/CouchbaseDocument.java @@ -49,7 +49,7 @@ public class CouchbaseDocument implements CouchbaseStorable { /** * Represents the document ID used to identify the document in the bucket. */ - private String id; + private Object id; /** * Contains the expiration time of the document. @@ -68,7 +68,7 @@ public CouchbaseDocument() { * * @param id the document ID. */ - public CouchbaseDocument(final String id) { + public CouchbaseDocument(final Object id) { this(id, DEFAULT_EXPIRATION_TIME); } @@ -78,7 +78,7 @@ public CouchbaseDocument(final String id) { * @param id the document ID. * @param expiration the expiration time of the document. */ - public CouchbaseDocument(final String id, final int expiration) { + public CouchbaseDocument(final Object id, final int expiration) { this.id = id; this.expiration = expiration; content = new TreeMap<>(); @@ -245,7 +245,7 @@ public CouchbaseDocument setExpiration(int expiration) { * * @return the ID of the document. */ - public String getId() { + public Object getId() { return id; } @@ -255,7 +255,7 @@ public String getId() { * @param id the ID of the document. * @return the {@link CouchbaseDocument} for chaining. */ - public CouchbaseDocument setId(String id) { + public CouchbaseDocument setId(Object id) { this.id = id; return this; }