Comments (3)
Hello, @bhishambajaj1999.
Unfortunately, I'm unable to replicate this problem in my current environment.
Would it be possible for you to provide us with a reproducer?
from r2dbc-mysql.
Hello, @jchrys , Please find additional info.
public class Orders {
@id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@column(name = "id", nullable = false)
private Long id;
@column(name = "order_id", nullable = false)
private String orderId;
@column(name = "status", nullable = false)
@Enumerated(EnumType.STRING)
private OrderState status;
@column(name = "type", nullable = false)
@Enumerated(EnumType.STRING)
private OrderType type;
@column(name = "client_code", nullable = false)
private String clientCode;
@column(name = "billing_code", nullable = false)
private String billingCode;
@column(name = "pincode", nullable = false)
private String pincode;
@column(name = "address", columnDefinition = "json", nullable = false)
@type(type = "json")
private Address address;
@column(name = "lab_id")
private Long labId;
@column(name = "tenant_id", nullable = false)
private String tenantId;
@column(name = "contact_no", nullable = false)
private String contactNo;
@column(name = "contact_no_hashed", nullable = false)
private String contactNoHashed;
@column(name = "email_id")
private String emailId;
@column(name = "origin", columnDefinition = "json", nullable = false)
@type(type = "json")
private Origin origin;
@column(name = "referred_by", nullable = false)
private String referredBy;
@column(name = "is_deleted", columnDefinition = "bit(1)", nullable = false)
private boolean isDeleted;
@column(name = "attributes", columnDefinition = "json", nullable = false)
@type(type = "json")
private OrderAttributes attributes;
}
This is my R2dbcConfig
@bean
public ReactiveTransactionManager transactionManager(ConnectionFactory connectionFactory) {
return new R2dbcTransactionManager(connectionFactory);
}
@OverRide
@bean
@primary
public ConnectionFactory connectionFactory() {
ConnectionFactoryOptions baseOptions = ConnectionFactoryOptions.parse(r2dbcProperties.getUrl());
ConnectionFactoryOptions ob = ConnectionFactoryOptions.builder().from(baseOptions)
.option(USER, r2dbcProperties.getUsername())
.option(PASSWORD, r2dbcProperties.getPassword())
.build();
ConnectionFactory connectionFactory = ConnectionFactories.get(ob);
PropertyMapper map = PropertyMapper.get().alwaysApplyingWhenNonNull();
ConnectionPoolConfiguration.Builder builder = ConnectionPoolConfiguration.builder(
connectionFactory);
R2dbcProperties.Pool pool = r2dbcProperties.getPool();
map.from(pool.getMaxIdleTime()).to(builder::maxIdleTime);
map.from(pool.getMaxLifeTime()).to(builder::maxLifeTime);
map.from(pool.getMaxAcquireTime()).to(builder::maxAcquireTime);
map.from(pool.getMaxCreateConnectionTime()).to(builder::maxCreateConnectionTime);
map.from(pool.getInitialSize()).to(builder::initialSize);
map.from(pool.getMaxSize()).to(builder::maxSize);
map.from(pool.getValidationQuery()).whenHasText().to(builder::validationQuery);
map.from(pool.getValidationDepth()).to(builder::validationDepth);
return new ConnectionPool(builder.build());
}
@bean
ConnectionFactoryInitializer initializer(ConnectionFactory connectionFactory) {
ConnectionFactoryInitializer initializer = new ConnectionFactoryInitializer();
initializer.setConnectionFactory(connectionFactory);
return initializer;
}
@OverRide
@bean
public R2dbcCustomConversions r2dbcCustomConversions() {
List<Converter> converters = new ArrayList<>();
converters.add(new OrdersReadingConverter(objectMapper));
converters.add(new OrdersWritingConverter(objectMapper));
return new R2dbcCustomConversions(getStoreConversions(), converters);
}
Sharing Reading convertor
public Orders convert(Row source) {
return Orders.builder()
.id(source.get("id",Long.class))
.orderId(source.get("order_id", String.class))
.status(OrderState.valueOf(source.get("status", String.class)))
.type(OrderType.valueOf(source.get("type", String.class)))
.clientCode(source.get("client_code", String.class))
.billingCode(source.get("billing_code", String.class))
.pincode(source.get("pincode", String.class))
.address(objectMapper.readValue(source.get("address", String.class), Address.class))
.labId(source.get("lab_id", Long.class))
.tenantId(source.get("tenant_id", String.class))
.contactNo(source.get("contact_no", String.class))
.contactNoHashed(source.get("contact_no_hashed", String.class))
.emailId(source.get("email_id", String.class))
.origin(objectMapper.readValue(source.get("origin", String.class), Origin.class))
.referredBy(source.get("referred_by", String.class))
.isDeleted(Boolean.TRUE.equals(source.get("is_deleted", Boolean.class)))
.attributes(
objectMapper.readValue(source.get("attributes", String.class), OrderAttributes.class))
.build();
}
The requirement is to do operation on auto generated id, which I am not able to retrieve, but It is getting saved in database correctly. Currently I am handling this by explicitly calling
return databaseClient.sql("SELECT LAST_INSERT_ID()")
.map((row, metadata) -> row.get(0, Long.class))
.one();
In Jpa I am able to retrieve this auto generated Id implicitly, I am new to R2dbc not sure if it is supported implicitly, if yes not sure what is going wrong here.
I am using spring boot **2.7.4**
implementation("io.asyncer:r2dbc-mysql:0.9.4") => Driver for r2dbc
from r2dbc-mysql.
Hello, @bhishambajaj1999.
Thank you for providing the information. It appears that the details you've shared are not quite sufficient for me to replicate the issue in my own environment(https://stackoverflow.com/help/minimal-reproducible-example). However, it seems that the issue may be related to either spring-data-r2dbc or spring-data-relational. I would suggest considering reaching out to the respective project team.
from r2dbc-mysql.
Related Issues (20)
- [feature] Support `LOCAL INFILE`
- [bug]Boolean bind variable is echoed back as ByteBuffer
- [feature]Support `sessionVariables` configuration properties
- [docs]Write a wiki instead of a huge README HOT 2
- [Feature] Support for Lightweight Ping Syntax
- [feature] Compression protocol support
- [QUESTION] How about removing `socketTimeout`? HOT 1
- [feature] Refactor SQL statement parsing
- [feature] Add support for decoding session state info in Ok packets
- Add support for MariaDB connection redirection
- [feature] Support for Custom Loop Resources
- [feature] Support standard option `lockWaitTimeout` and `statementTimeout` HOT 1
- [feature]Enable Leak detection in CI pipeline HOT 2
- [bug]align with`RowMetaData#getColumnMetadata(String)` specification HOT 3
- [feature] Support for Stored Procedure Execution HOT 1
- [bug] Deploy broken HOT 3
- [bug]Fix Snapshot deployment
- [feature] Extract public API into API package
- Support for MariaDB Extend Type Info
- Error connecting to mysql inside the docker HOT 4
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 r2dbc-mysql.