-
Notifications
You must be signed in to change notification settings - Fork 132
ReactiveCrudRepository.save() doesn't work with PostgreSQL #247
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
Comments
Do you have a stacktrace? |
There's no crash or indication of error. The save shows as successful but does not appear in the database as confirmed by a subsequent count. The above demo can confirm that by just running |
You're probably speaking about this snippet: Customer customer = new Customer();
customer.setId(1L);
customer.setFirstName("John");
assertEquals(customer, customerRepository.save(customer).block());
assertEquals(1L, customerRepository.count().block()); The repository derives based on ID presence/absence whether the object is new or an existing one. Providing an Id value issues an Please implement |
In my real application, we have a natural ID and it's a very large table so it's not space efficient to store a database generated ID. I can confirm that making my entity implement Persistable and tracking its inserted state does indeed work. Thanks for making me aware of this interface. I'm glad that this scenario will at least throw an exception in the next release so it's clear to the user what they need to fix. Only thing I don't quite like is polluting the domain with transient isNew logic. Would there be any value to add a |
Paging @schauder. We have a similar arrangement in JDBC where the repository contains also a |
Almost. The But of course that allows you to easily add it to a repository as a custom method. |
Sorry, I mixed it up, you're right. For Spring Data R2DBC, one can use Closing as we're already consistent with what Spring Data JDBC provides and we have a guard in place to prevent silent no-op updates. |
ReactiveCrudRepository.save()
doesn't work with PostgreSQL. UsingDatabaseClient.insert()
orConnectionFactory
directly does work. I've created a small demo project that reproduces this at https://github.com/steven-sheehy/r2dbc-insert. I'm not entirely sure it's related to PostgreSQL, but that's the only thing I've tried.I'm not sure if this is the appropriate project to open this as there are a lot of projects involved.
The text was updated successfully, but these errors were encountered: