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

Add support for transactions (sync). [DATAMONGO-1920] #2819

Closed
spring-projects-issues opened this issue Apr 5, 2018 · 0 comments
Closed
Assignees
Labels
in: core type: enhancement

Comments

@spring-projects-issues
Copy link

spring-projects-issues commented Apr 5, 2018

Christoph Strobl opened DATAMONGO-1920 and commented

Provide a MongoDB specific PlatformTransactionManager implementation.

The MongoTransactionManager should create and bind a ClientSession to the thread. Transactions are started, commited or aborted while MongoTemplate automatically detects existing ClientSessions and operates on them accordingly.

Without the presence of a MongoTransactionManager within the ApplicationContext the template should not participate in any what so ever ongoing transactions. Users have to actively opt in to transaction support. A flag on MongoTemplate should allow to enable transaction support for non native MongoDB transactions.

@Configuration
public class Config extends AbstractMongoConfiguration {

  @Bean
  MongoTransactionManager transactionManager(MongoDbFactory dbFactory) {
    return new MongoTransactionManager(dbFactory);
  }

  // ...
}

@Service
public class NightAngel {

  @Autowired PersonRepository repository;

  @Transactional
  public void trainAzoth() {

    Person durzo = repository.findByName("Durzo Blint");

    Person kylar = new Person("Kylar Stern");
    kylar.setMaster(durzo);

    repository.save(kylar);    
  }
}

Reference URL: https://www.mongodb.com/transactions

Issue Links:

  • DATAMONGO-2001 Count within session should return only the total count of documents visible to the specific session

  • DATAMONGO-1971 Install MongoDB on TravisCI ourselves

Referenced from: pull request #554

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core type: enhancement
Projects
None yet
Development

No branches or pull requests

2 participants