Comments (15)
There’s no such thing as a stupid question. We want to provide a runtime API so code can intercept and modify queries prior to execution.
from spring-data-r2dbc.
You can use it to generate events, modify the query to e.g. implement security requirements, implement multi-tenancy, add generic query predicates.
from spring-data-r2dbc.
Ideally, intercept calls execute with a custom DatabaseClient implementation that just pre-processes your sql.
from spring-data-r2dbc.
Tried doing that. Found it complicated that I had to implement all the GenericExecuteSpec, SelectFromSpec etc, for simply doing a query preprocessor.
If DefaultDatabaseClient was public I could have simply extended it.
from spring-data-r2dbc.
Should this be implemented at compile time or at runtime? Sorry if it is a stupid question.
from spring-data-r2dbc.
Got it. What kind of modifications? Optimizations? I'm so curious.
from spring-data-r2dbc.
Does this also support transparent routing of all queries to read
/replica server and all CUD
s to write
/primary server
from spring-data-r2dbc.
from spring-data-r2dbc.
@mp911de is this still required? I could take a look into it.
from spring-data-r2dbc.
I think this ticket requires some design up-front. Looking into Spring 5's WebClient
and ExchangeFunction
is a good exercise to learn about delegation, filtering, and pre-/post-processing.
from spring-data-r2dbc.
#73 brings PreparedOperation
which can form a base to encapsulate operations that should happen on a Statement
(SQL-rendering and binding of values)
from spring-data-r2dbc.
I am migrating from a non reactive to a reactive app. I have a requirement to update all my queries with a custom value, where I replace some pattern like :id
in the query with a value specific to the current execution context.
In non reactive, I had extended JdbcTemplate and intercepted all the query methods to change the sql with the required value.
public class CustomJdbcTemplate extends JdbcTemplate {
public <T> T query(String sql, Object[] args, int[] argTypes, ResultSetExtractor<T> rse) throws DataAccessException {
// replace placeholders
String statement = QueryHelper.getInstance().populateDefinedQueryPlaceHolders(sql);
return super.query(statement, newArgTypePreparedStatementSetter(args, argTypes), rse);
}
//similar code in all query methods
}
What would be the correct approach for this with DatabaseClient? I assume a common query preprocessor would be a solution for this.
from spring-data-r2dbc.
Any update on if this is gonna be implemented soon? I need to add a filter like " AND someCode IN (A,B,C)" to all my queries and there's 100's of them. It would be really helpful if there was a simple way of achieving this 3-4 years after this ticket was created?
from spring-data-r2dbc.
The most straightforward workaround is to provide a DatabaseClient
implementation that intercepts the sql(…)
method, does its rewrite, and delegates to the DatabaseClient
instance created by Spring.
from spring-data-r2dbc.
Do I need to use AOP for intercepting the sql(…) method of DatabaseClient? We have mostly used ReactiveCrudRepository in the DAO where we use both the @query annotation and method name for generating the query but I can use the same DatabaseClient implementation for the Repository by defining a bean of type R2dbcEntityOperations.
If you could provide some hint on how can I intercept the sql() method then that will be highly appreciated.
Thanks In Advance.
from spring-data-r2dbc.
Related Issues (20)
- Upgrade to Maven Wrapper 3.9.4
- Release 1.5.16 (2021.2.16)
- Release 1.5.17 (2021.2.17)
- Model entity need to add custom Encryption on insert/update and decrypt on read HOT 4
- Upgrade to Maven Wrapper 3.9.5
- Release 1.5.18 (2021.2.18)
- Enum is not properly mapped until custom converter created HOT 5
- NativeParameterUtils doesn't support collection with nullable values HOT 7
- Issue with @Transient HOT 3
- Manage transaction name when use @Transactional annotatnion HOT 1
- Transaction rollback does not work when using jOOQ HOT 1
- Custom converter in R2dbcEntityOperations breaks nested mappings
- Caused by: io.r2dbc.postgresql.ExceptionFactory$PostgresqlBadGrammarException: [42883] operator does not exist: traffic_type = character varying
- ConditionalGenericConverter is not properly handled by Spring Data R2DBC HOT 1
- Save entity with custom UUID identifier HOT 2
- `bindProperties` throws error when entities contain enum fields HOT 1
- IN clause not working HOT 4
- `findAllByxxx` incorrectly returns a single object instead of an Iterable. HOT 1
- Unexpected behaviour when using repository saveAll() in WebFilter with response body HOT 3
- java.lang.IllegalStateException: Required property not found for class HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from spring-data-r2dbc.