spring-data-r2dbc icon indicating copy to clipboard operation
spring-data-r2dbc copied to clipboard

1.2.0 - migration of fluent API without entity classes

Open rjaros opened this issue 4 years ago • 6 comments

With 1.1.x it was possible to use:

databaseClient.insert().into("table_name")

databaseClient.update().table("table_name")

databaseClient.delete().from("table_name")

without any entity classes.

In 1.2.0 org.springframework.data.r2dbc.core.DatabaseClient is deprecated in favor of org.springframework.r2dbc.core.DatabaseClient and R2dbcEntityTemplate, but neither of them seem to support this kind of operations. What is the correct migration path?

rjaros avatar Nov 01 '20 01:11 rjaros

We don't provide a SQL construction DSL anymore. You can use the SQL builder API from org.springframework.data.relational.core.sql directly or tools like jOOQ if you like.

mp911de avatar Nov 10 '20 10:11 mp911de

But the whole DSL is still there. Looking at the current docs: https://docs.spring.io/spring-data/r2dbc/docs/1.2.0/reference/html/#r2dbc.entityoperations.fluent-api we still have matching function, the Criteria class with all the operators and we can even provide the table name.

As far as I understand the example code: https://docs.spring.io/spring-data/r2dbc/docs/1.2.0/api/org/springframework/data/r2dbc/core/ReactiveUpdateOperation.html the entity class itself is not even used here for anything.

rjaros avatar Nov 10 '20 15:11 rjaros

I've got a few medium sized applications with lots of code based on r2dbc fluent api running with current Spring Boot. Please consider a better migration path for people like me :-)

rjaros avatar Nov 10 '20 15:11 rjaros

+1 This would be great. I also have the same usages of insert.into("")/update.table("table").

So a bit of a pain migrating away from that right now.

baltom avatar Nov 19 '20 14:11 baltom

Take attention to possible SQL injections, if you pass values directly to SQL builder API

istarion avatar Nov 20 '20 11:11 istarion

I have created a small Kotlin project, which addresses this issue: https://github.com/rjaros/r2dbc-e4k

rjaros avatar Dec 21 '20 01:12 rjaros