DATACOUCH-329 - Save repo return with the generated id
Original pull request: #151.
This commit is contained in:
committed by
Subhashni Balakrishnan
parent
5175bf23d8
commit
761c08517b
@@ -591,7 +591,8 @@ public class CouchbaseTemplate implements CouchbaseOperations, ApplicationEventP
|
||||
execute(new BucketCallback<Boolean>() {
|
||||
@Override
|
||||
public Boolean doInBucket() throws InterruptedException, ExecutionException {
|
||||
converted.setId(addCommonPrefixAndSuffix(converted.getId()));
|
||||
String generatedId = addCommonPrefixAndSuffix(converted.getId());
|
||||
converted.setId(generatedId);
|
||||
Document<String> doc = encodeAndWrap(converted, version);
|
||||
Document<String> storedDoc;
|
||||
//We will check version only if required
|
||||
@@ -621,6 +622,11 @@ public class CouchbaseTemplate implements CouchbaseOperations, ApplicationEventP
|
||||
storedDoc = client.insert(doc, persistTo, replicateTo);
|
||||
break;
|
||||
}
|
||||
CouchbasePersistentProperty idProperty = persistentEntity.getIdProperty();
|
||||
Object entityId = accessor.getProperty(idProperty);
|
||||
if (!generatedId.equals(entityId)) {
|
||||
accessor.setProperty(idProperty, generatedId);
|
||||
}
|
||||
|
||||
if (storedDoc != null && storedDoc.cas() != 0) {
|
||||
//inject new cas into the bean
|
||||
|
||||
Reference in New Issue
Block a user