-
| 
         I have the following method to insert a collection which worked in r2dbc 0.8. The complete codes is here, @Override
    public Flux<UUID> saveAll(List<Post> data) {
        var sql = "INSERT INTO  posts (title, content, status) VALUES ($1, $2, $3)";
        return this.databaseClient.inConnectionMany(connection -> {
            var statement = connection.createStatement(sql)
                    .returnGeneratedValues("id");
            data.forEach(p -> {
                statement.bind(0, p.getTitle())
                        .bind(1, p.getContent())
                        .bind(2, p.getStatus())
                        .add();
            });
            return Flux.from(statement.execute()).flatMap(result -> result.map((row, rowMetadata) -> row.get("id", UUID.class)));
        });
    }When update r2dbc to the latest  I got the following exceptions. java.lang.IllegalStateException: Bound parameter count does not match parameters in SQL statement
	at io.r2dbc.postgresql.client.Binding.validate(Binding.java:176)
	at java.base/java.util.ArrayDeque.forEach(ArrayDeque.java:888)
	at io.r2dbc.postgresql.PostgresqlStatement.execute(PostgresqlStatement.java:206)
	at io.r2dbc.postgresql.PostgresqlStatement.execute(PostgresqlStatement.java:144)
	at io.r2dbc.postgresql.PostgresqlStatement.execute(PostgresqlStatement.java:56)
	at com.example.demo.domain.repository.R2dbcPostRepository.lambda$saveAll$7(R2dbcPostRepository.java:99)
	at org.springframework.r2dbc.core.DefaultDatabaseClient.lambda$inConnectionMany$6(DefaultDatabaseClient.java:141) | 
  
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
| 
         You have a trailing   | 
  
Beta Was this translation helpful? Give feedback.
-
| 
         R2DBC SPI isn't intended to be used directly by applications, it's designed to be used by libraries.  | 
  
Beta Was this translation helpful? Give feedback.
You have a trailing
.add()call. As per r2dbc/r2dbc-spi#259, if you provide the last binding to the batchStatement, then you must not calladdas final operation butexecute.