From 613b5ad8db93c01128b932e9ef93096a9577f332 Mon Sep 17 00:00:00 2001 From: Mark Paluch Date: Thu, 23 Jan 2020 09:18:52 +0100 Subject: [PATCH] #283 - Fix Id property and column name usage in SimpleR2dbcRepository. We now use the Id property name when using the converter to map property names to column names. In other places, where we don't use the converter, we stick with the Id column name. --- .../support/SimpleR2dbcRepository.java | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/main/java/org/springframework/data/r2dbc/repository/support/SimpleR2dbcRepository.java b/src/main/java/org/springframework/data/r2dbc/repository/support/SimpleR2dbcRepository.java index b3f05fd..edf6160 100644 --- a/src/main/java/org/springframework/data/r2dbc/repository/support/SimpleR2dbcRepository.java +++ b/src/main/java/org/springframework/data/r2dbc/repository/support/SimpleR2dbcRepository.java @@ -30,6 +30,7 @@ import org.springframework.data.r2dbc.core.PreparedOperation; import org.springframework.data.r2dbc.core.ReactiveDataAccessStrategy; import org.springframework.data.r2dbc.core.StatementMapper; import org.springframework.data.r2dbc.query.Criteria; +import org.springframework.data.relational.core.mapping.RelationalPersistentProperty; import org.springframework.data.relational.core.sql.Functions; import org.springframework.data.relational.core.sql.Select; import org.springframework.data.relational.core.sql.StatementBuilder; @@ -129,12 +130,12 @@ public class SimpleR2dbcRepository implements ReactiveCrudRepository columns = this.accessStrategy.getAllColumns(this.entity.getJavaType()); - String idColumnName = getIdColumnName(); + String idProperty = getIdProperty().getName(); StatementMapper mapper = this.accessStrategy.getStatementMapper().forType(this.entity.getJavaType()); StatementMapper.SelectSpec selectSpec = mapper.createSelect(this.entity.getTableName()) // .withProjection(columns) // - .withCriteria(Criteria.where(idColumnName).is(id)); + .withCriteria(Criteria.where(idProperty).is(id)); PreparedOperation operation = mapper.getMappedObject(selectSpec); @@ -160,12 +161,12 @@ public class SimpleR2dbcRepository implements ReactiveCrudRepository operation = mapper.getMappedObject(selectSpec); @@ -217,12 +218,12 @@ public class SimpleR2dbcRepository implements ReactiveCrudRepository columns = this.accessStrategy.getAllColumns(this.entity.getJavaType()); - String idColumnName = getIdColumnName(); + String idProperty = getIdProperty().getName(); StatementMapper mapper = this.accessStrategy.getStatementMapper().forType(this.entity.getJavaType()); StatementMapper.SelectSpec selectSpec = mapper.createSelect(this.entity.getTableName()) // .withProjection(columns) // - .withCriteria(Criteria.where(idColumnName).in(ids)); + .withCriteria(Criteria.where(idProperty).in(ids)); PreparedOperation operation = mapper.getMappedObject(selectSpec); @@ -238,7 +239,7 @@ public class SimpleR2dbcRepository implements ReactiveCrudRepository implements ReactiveCrudRepository implements ReactiveCrudRepository implements ReactiveCrudRepository