Skip to content

DATACOUCH-623 - Add replace() method to CouchbaseRepository for CAS u… #268

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

mikereiche
Copy link
Collaborator

…sage.

  • You have read the Spring Data contribution guidelines.
  • There is a ticket in the bug tracker for the project in our JIRA.
  • You use the code formatters provided here and have them applied to your changes. Don’t submit any formatting related changes.
  • You submit test cases (unit or integration tests) that back your changes.
  • You added yourself as author in the headers of the classes you touched. Amend the date range in the Apache license header if needed. For new types, add the license header (copy from another file and set the current year only).

@mikereiche mikereiche force-pushed the datacouch_623_add_replace_to_repository_for_cas_usage branch from c205141 to c158cda Compare October 6, 2020 01:24
@mikereiche mikereiche requested review from dnault and daschl and removed request for dnault October 6, 2020 01:39
@@ -43,4 +43,8 @@
@Override
List<T> findAllById(Iterable<ID> iterable);

<S extends T> S replace(S var1);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding technology-specific methods violates somewhat the concept of handling technology-specific aspects inside the repository/template API. I left a comment on DATACOUCH-623. Especially entities annotated with @Version shouldn't require the user to call a different method for proper handling, instead, the requirement to issue a different store-specific replace call should be determined by the Spring Data code and not the caller.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Mark. I put the upsert() vs. replace() logic in the save().

@daschl
Copy link
Contributor

daschl commented Oct 7, 2020

@mikereiche after looking into this I agree with @mp911de's comment in https://jira.spring.io/browse/DATACOUCH-623?focusedCommentId=191380&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-191380 .. Let's not add to the repository, but rather in our internal code check if the version is present and if present and set use a replace operation and map to the corresponding exception.

@mikereiche mikereiche force-pushed the datacouch_623_add_replace_to_repository_for_cas_usage branch from c158cda to f9533b2 Compare October 7, 2020 21:38
}
}

private boolean hasVersionProperty(Object entity) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that method can be DRY'ed up? only provided it once and reuse.. also maybe a name that also clarifies it must be present AND not 0 might be better

Copy link
Collaborator Author

@mikereiche mikereiche Oct 9, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. I put it in a new Utils class.
I had thought of that, but SimpleReactiveCouchbaseRepository has a ReactiveCouchbaseOperations, while SimpleCouchbaseRepository has a CouchbaseOperations. But it doesn't actually need those - it just needs the mapping conext of the converter held by each *Operations - which is the same type.

@mikereiche mikereiche force-pushed the datacouch_623_add_replace_to_repository_for_cas_usage branch 2 times, most recently from c85a555 to b3e0060 Compare October 9, 2020 21:22
@mikereiche mikereiche force-pushed the datacouch_623_add_replace_to_repository_for_cas_usage branch from b3e0060 to 3b236c3 Compare October 13, 2020 00:08
@mikereiche mikereiche merged commit 0ce0f36 into master Oct 13, 2020
mikereiche added a commit that referenced this pull request Oct 13, 2020
@mikereiche mikereiche deleted the datacouch_623_add_replace_to_repository_for_cas_usage branch November 5, 2020 22:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants