Skip to content

findById of CouchbaseTemplate does not involve getAndTouch entities [DATACOUCH-674] #982

Closed
@spring-projects-issues

Description

@spring-projects-issues

jorgerod opened DATACOUCH-674 and commented

Hi

FindById method does not involve touchOnRead entities, that is, internally, it only uses the get method and does not give the possibility of being able to use the getAndTouch method

 

  • spring-data-couchbase 3.2.9-RELEASE. (Couchbase.java): 
  @Override
  public <T> T findById(final String id, Class<T> entityClass) {
    final CouchbasePersistentEntity<?> entity = mappingContext.getRequiredPersistentEntity(entityClass);
    RawJsonDocument result = execute(new BucketCallback<RawJsonDocument>() {
      @Override
      public RawJsonDocument doInBucket() {
        if (entity.isTouchOnRead()) {
          return client.getAndTouch(id, entity.getExpiry(), RawJsonDocument.class);
        } else {
          return client.get(id, RawJsonDocument.class);
        }
      }
    });

    return mapToEntity(id, result, entityClass);
  }

 

  • spring-data-couhbase 4.1.1: (ReactiveFindByIdOperationSupport.ReactiveFindByIdSupport.java)
		@Override
		public Mono<T> one(final String id) {
			return Mono.just(id).flatMap(docId -> {
				GetOptions options = getOptions().transcoder(RawJsonTranscoder.INSTANCE);
				if (fields != null && !fields.isEmpty()) {
					options.project(fields);
				}
				return template.getCollection(collection).reactive().get(docId, options);
			}).map(result -> template.support().decodeEntity(id, result.contentAs(String.class), result.cas(), domainType))
                       ....

 


Affects: 4.2 M1 (2021.0.0), 4.1.2 (2020.0.2)

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions