Skip to content
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

Transaction fails when entity has set @Durability #2027

Open
jakov222 opened this issue Jan 24, 2025 · 1 comment
Open

Transaction fails when entity has set @Durability #2027

jakov222 opened this issue Jan 24, 2025 · 1 comment
Labels
status: feedback-provided Feedback has been provided

Comments

@jakov222
Copy link

jakov222 commented Jan 24, 2025

Hey, I am trying to save few documents in a transaction. Entity of the document is annotated with @Durability(MAJORITY_AND_PERSIST_TO_ACTIVE). Transaction fails with Transaction has failed with cause 'java.lang.IllegalArgumentException: withDurability is not supported in a transaction'
Is this intended? Probably has something to do with this comment #1487 (comment)

tagging @programmatix

// edit
ok, I can clearly see now that this is intentional. Could you please share why? I wanted to achieve this scenario - annotate entity with @Durability. Have repository with reference to CrudRepository with durable save methods and other @Transactional method that does some operations

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Jan 24, 2025
@mikereiche
Copy link
Collaborator

mikereiche commented Jan 28, 2025

Durability in a transaction is a transaction configuration property.

https://docs.couchbase.com/java-sdk/current/howtos/distributed-acid-transactions-from-the-sdk.html#configuration

In spring data couchbase, you would specify it by overriding the configureEnvironment() method of you implementation of AbstractCouchbaseConfiguration.

@Override
public void configureEnvironment(ClusterEnvironment.Builder builder) {
	builder.transactionsConfig(
	com.couchbase.client.java.transactions.config.TransactionsConfig.builder().durabilityLevel(DurabilityLevel.MAJORITY_AND_PERSIST_TO_ACTIVE));
}

@mikereiche mikereiche added status: feedback-provided Feedback has been provided and removed status: waiting-for-triage An issue we've not yet triaged labels Jan 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: feedback-provided Feedback has been provided
Projects
None yet
Development

No branches or pull requests

3 participants