Skip to content

Spring Data R2DBC ReactiveCrudRepository.save() method is not working even with method / class level @Transactional annotation #18664

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

Closed
daggerok opened this issue Oct 20, 2019 · 2 comments
Labels
for: external-project For an external project and not something we can fix

Comments

@daggerok
Copy link

daggerok commented Oct 20, 2019

Hello,

Please, let me know if spring-data-r2dbc transactions by default are read only?
For some reasons, data cannot be saved when I do it using ReactiveCrudRepository like so:

    @Transactional
    @ResponseBody
    @PostMapping("/sessions")
    public Mono<Session> save(@RequestBody Session session) {
        return Mono.just(session)
                   .filter(s -> Objects.nonNull(s.getName()))
                   .filter(s -> Objects.nonNull(s.getSpeakers()))
                   .map(s -> Objects.isNull(s.getId()) ? s.setId(UUID.randomUUID()) : s)
                   .flatMap(sessionRepository::save);
    }

I have prepared a repo, and that par is present, but commented here. Cannot understand, why it cannot be committed... but anyway, data can be successfully saved in database if I'm using DatabaseClient for that:

    @ResponseBody
    @PostMapping("/sessions")
    public Mono<Integer> save(@RequestBody Session session) {
        return Mono.just(session)
                   .filter(s -> Objects.nonNull(s.getName()))
                   .filter(s -> Objects.nonNull(s.getSpeakers()))
                   .map(s -> Objects.isNull(s.getId()) ? s.setId(UUID.randomUUID()) : s)
                   .flatMap(s -> client.execute("INSERT INTO sessions (id, name, speakers) VALUES ($1, $2, $3)")
                                       .bind("$1", s.getId())
                                       .bind("$2", s.getName())
                                       .bind("$3", s.getSpeakers())
                                       .fetch().rowsUpdated());
    }

full code located here

versions

  • spring-boot 2.2.0.RELEASE
  • spring-boot-starter-data-r2dbc: 0.1.0.BUILD-SNAPSHOT
  • r2dbc-postgresql: 0.8.0.RC2

Is it bug or I missed something?
Thanks!


Regards,
Maksim

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Oct 20, 2019
@daggerok daggerok changed the title Spring Data R2DBC ReactiveCrudRepository# save is not working even with method / class level @Transactional annotation Spring Data R2DBC ReactiveCrudRepository.save() method is not working even with method / class level @Transactional annotation Oct 20, 2019
@wilkinsona
Copy link
Member

Spring Data R2DBC is managed as a separate project.

@wilkinsona wilkinsona added for: external-project For an external project and not something we can fix and removed status: waiting-for-triage An issue we've not yet triaged labels Oct 20, 2019
@daggerok
Copy link
Author

Hello @wilkinsona
Created there issue here: spring-projects/spring-data-r2dbc#218

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
for: external-project For an external project and not something we can fix
Projects
None yet
Development

No branches or pull requests

3 participants