Spring Data R2dbc中带有postgres的数值类型映射问题

问题描述

我尝试在示例应用程序中使用Spring Data R2dbc / Postgres。

  • Spring Boot 2.4.0-M2
  • R2dbc Postgres(由Spring Boot管理)
  • Spring Data R2dbc 1.2.0-M2(由Spring Boot管理)

表脚本。


CREATE SEQUENCE IF NOT EXISTS ORDERS_ID_SEQ;

CREATE TABLE  IF NOT EXISTS ORDERS(
ID INTEGER NOT NULL PRIMARY KEY DEFAULT nextval('ORDERS_ID_SEQ'),CUST_ID BIGINT NOT NULL,AMOUNT REAL NOT NULL
);

ALTER SEQUENCE ORDERS_ID_SEQ OWNED BY ORDERS.ID;

data.sql

-- INSERT SAMPLE DATA
DELETE FROM ORDERS;
INSERT INTO ORDERS(CUST_ID,AMOUNT) VALUES (1,100.2);

我使用ResourceDatabasePopulator填充数据,它可以正常工作。

但是当我尝试通过存储库保存数据时,失败了。

@Table(value = "ORDERS")
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class Order implements Serializable {

    @Id
    @Column(value = "ID")
    private Integer id;

    @Column(value = "CUST_ID")
    private Long customerId;

    // use BigDecimal or Java Money API in the real-world application.
    @Column(value = "AMOUNT")
    private Double amount;
}


public interface OrderRepository extends R2dbcRepository<Order,Integer> {
}

// in application runner.

orders .save(Order.builder().customerId(c.getId()).amount(201.0).build())

它抛出了这样的异常:

reactor.core.Exceptions$ErrorCallbackNotImplemented: java.lang.UnsupportedOperationException: Binding parameters is not supported for the statement 'INSERT INTO ORDERS (CUST_ID,AMOUNT) VALUES (?,?)'
Caused by: java.lang.UnsupportedOperationException: Binding parameters is not supported for the statement 'INSERT INTO ORDERS (CUST_ID,?)'
    at io.r2dbc.postgresql.SimpleQueryPostgresqlStatement.bind(SimpleQueryPostgresqlStatement.java:78) ~[r2dbc-postgresql-0.8.4.RELEASE.jar:0.8.4.RELEASE]
    at io.r2dbc.postgresql.SimpleQueryPostgresqlStatement.bind(SimpleQueryPostgresqlStatement.java:44) ~[r2dbc-postgresql-0.8.4.RELEASE.jar:0.8.4.RELEASE]

完整代码here

已更新:从AbstractR2dbcConfiguration开始放弃,并在跟随the official guide时被抢救。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)