简体   繁体   English

Spring R2DBC + SQL Server:过程查询

[英]Spring R2DBC + SQL Server: procedures query

I am required to execute a stored procedure in a SQL server to fetch some data, and since I will later save the data into a Mongo and this one is with ReactiveMongoTemplate and so on, I introduced Spring R2DBC.我需要在 SQL 服务器中执行一个存储过程来获取一些数据,因为我稍后会将数据保存到 Mongo 中,而这个是使用ReactiveMongoTemplate ,所以我引入了 Spring R2DBC。

    implementation("org.springframework.data:spring-data-r2dbc:1.0.0.RELEASE")
    implementation("io.r2dbc:r2dbc-mssql:0.8.1.RELEASE")

I see that I can do SELECT and INSERT and so on with R2DBC, but is it possible to EXEC prod_name ?我看到我可以使用 R2DBC 执行SELECTINSERT等操作,但是可以EXEC prod_name吗? I tried it and it hangs forever and then the test terminates , without success but neither failure.我试过了,它永远挂起,然后测试终止,没有成功但也没有失败。 The last line of log is:日志的最后一行是:

io.r2dbc.mssql.QUERY - Executing query: EXEC "SCHEMA"."MY_PROCEDURE" 

The code is like:代码是这样的:

    public Flux<Coupon> selectWithProcedure() {
        return databaseClient
                .execute("EXEC \"SCHEMA\".\"MY_PROCEDURE\" ")
                .as(Coupon.class)
                .fetch().all()
                .doOnNext(coupon -> {
                    coupon.setCouponStatusRefFromId(coupon.getCouponStatusRefId());
                });
    }

And it seems that no data is retrieved.而且似乎没有检索到任何数据。

If I test some other methods with simple queries like SELECT... it works.如果我使用像SELECT...这样的简单查询来测试其他一些方法,它会起作用。 But the problem is, DBAs do not allow my app to read table data, instead, they create a procedure for me.但问题是,DBA 不允许我的应用程序读取表数据,而是为我创建了一个过程。 If this query is not possible, I must go with traditional JPA way and going reactive at Mongo side has lost its sense.如果这个查询是不可能的,我必须采用传统的 JPA 方式,而在 Mongo 方面进行反应已经失去了意义。

Well.好。 I just saw this:我刚看到这个:

https://github.com/r2dbc/r2dbc-mssql , version 0.8.1: https://github.com/r2dbc/r2dbc-mssql ,版本 0.8.1:

Next steps:下一步:

  • Execution of stored procedures存储过程的执行
  • Add support for TVP and UDTs添加对 TVP 和 UDT 的支持

And:和:

https://r2dbc.io/2019/05/13/r2dbc-0-8-milestone-8-released https://r2dbc.io/2019/05/13/r2dbc-0-8-milestone-8-released

We already have a few tickets lined up for the next milestone, and we know that they will require further SPI modifications:我们已经为下一个里程碑排好几张票,我们知道它们将需要进一步的 SPI 修改:

  • Support for Auto-Commit支持自动提交
  • Connection Validation连接验证
  • Support for Stored Procedures支持存储过程

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM