@@ -56,6 +56,7 @@ class R2dbcQueryCreator extends RelationalQueryCreator<PreparedOperation<?>> {
5656 private final ReactiveDataAccessStrategy dataAccessStrategy ;
5757 private final RelationalEntityMetadata <?> entityMetadata ;
5858 private final List <String > projectedProperties ;
59+ private final Class <?> entityToRead ;
5960
6061 /**
6162 * Creates new instance of this class with the given {@link PartTree}, {@link ReactiveDataAccessStrategy},
@@ -78,6 +79,7 @@ public R2dbcQueryCreator(PartTree tree, ReactiveDataAccessStrategy dataAccessStr
7879 this .dataAccessStrategy = dataAccessStrategy ;
7980 this .entityMetadata = entityMetadata ;
8081 this .projectedProperties = projectedProperties ;
82+ this .entityToRead = entityMetadata .getTableEntity ().getType ();
8183 }
8284
8385 /**
@@ -90,7 +92,7 @@ public R2dbcQueryCreator(PartTree tree, ReactiveDataAccessStrategy dataAccessStr
9092 @ Override
9193 protected PreparedOperation <?> complete (@ Nullable Criteria criteria , Sort sort ) {
9294
93- StatementMapper statementMapper = dataAccessStrategy .getStatementMapper ().forType (entityMetadata . getJavaType () );
95+ StatementMapper statementMapper = dataAccessStrategy .getStatementMapper ().forType (entityToRead );
9496
9597 if (tree .isDelete ()) {
9698 return delete (criteria , statementMapper );
@@ -157,15 +159,15 @@ private Expression[] getSelectProjection() {
157159
158160 } else if (tree .isExistsProjection ()) {
159161
160- expressions = dataAccessStrategy .getIdentifierColumns (entityMetadata . getJavaType () ).stream ()
162+ expressions = dataAccessStrategy .getIdentifierColumns (entityToRead ).stream ()
161163 .map (table ::column )
162164 .collect (Collectors .toList ());
163165 } else if (tree .isCountProjection ()) {
164166
165167 SqlIdentifier idColumn = entityMetadata .getTableEntity ().getRequiredIdProperty ().getColumnName ();
166168 expressions = Collections .singletonList (Functions .count (table .column (idColumn )));
167169 } else {
168- expressions = dataAccessStrategy .getAllColumns (entityMetadata . getJavaType () ).stream ()
170+ expressions = dataAccessStrategy .getAllColumns (entityToRead ).stream ()
169171 .map (table ::column )
170172 .collect (Collectors .toList ());
171173 }
0 commit comments