1717
1818import java .util .Iterator ;
1919import java .util .List ;
20+ import java .util .function .BiFunction ;
2021import java .util .stream .Stream ;
2122
2223import org .jspecify .annotations .Nullable ;
24+
2325import org .springframework .dao .DataAccessException ;
2426import org .springframework .data .cassandra .core .convert .CassandraConverter ;
2527import org .springframework .data .cassandra .core .cql .CqlOperations ;
3335import com .datastax .oss .driver .api .core .CqlIdentifier ;
3436import com .datastax .oss .driver .api .core .cql .BatchType ;
3537import com .datastax .oss .driver .api .core .cql .ResultSet ;
38+ import com .datastax .oss .driver .api .core .cql .Row ;
3639import com .datastax .oss .driver .api .core .cql .Statement ;
3740
3841/**
@@ -92,7 +95,7 @@ default CassandraBatchOperations batchOps() {
9295 /**
9396 * The table name used for the specified class by this template.
9497 *
95- * @param entityClass The entity type must not be {@literal null}.
98+ * @param entityClass the entity type must not be {@literal null}.
9699 * @return the {@link CqlIdentifier}
97100 */
98101 CqlIdentifier getTableName (Class <?> entityClass );
@@ -105,7 +108,7 @@ default CassandraBatchOperations batchOps() {
105108 * Execute a {@code SELECT} query and convert the resulting items to a {@link List} of entities.
106109 *
107110 * @param cql must not be {@literal null}.
108- * @param entityClass The entity type must not be {@literal null}.
111+ * @param entityClass the entity type must not be {@literal null}.
109112 * @return the converted results
110113 * @throws DataAccessException if there is any problem executing the query.
111114 */
@@ -129,7 +132,7 @@ default CassandraBatchOperations batchOps() {
129132 * Execute a {@code SELECT} query and convert the resulting item to an entity.
130133 *
131134 * @param cql must not be {@literal null}.
132- * @param entityClass The entity type must not be {@literal null}.
135+ * @param entityClass the entity type must not be {@literal null}.
133136 * @return the converted object or {@literal null}.
134137 * @throws DataAccessException if there is any problem executing the query.
135138 */
@@ -154,18 +157,32 @@ default CassandraBatchOperations batchOps() {
154157 * Execute a {@code SELECT} query and convert the resulting items to a {@link List} of entities.
155158 *
156159 * @param statement must not be {@literal null}.
157- * @param entityClass The entity type must not be {@literal null}.
160+ * @param entityClass the entity type must not be {@literal null}.
158161 * @return the converted results
159162 * @throws DataAccessException if there is any problem executing the query.
160163 */
161164 <T > List <T > select (Statement <?> statement , Class <T > entityClass ) throws DataAccessException ;
162165
166+ /**
167+ * Execute a {@code SELECT} query and convert the resulting items to a {@link List} of entities considering the given
168+ * {@link BiFunction mapping function}.
169+ *
170+ * @param statement must not be {@literal null}.
171+ * @param entityClass the entity type must not be {@literal null}.
172+ * @param mapper mapping function invoked after materializing {@code entityClass} must not be {@literal null}.
173+ * @return the converted results
174+ * @throws DataAccessException if there is any problem executing the query.
175+ * @since 5.0
176+ */
177+ <S , T > List <T > select (Statement <?> statement , Class <S > entityClass , BiFunction <S , Row , T > mapper )
178+ throws DataAccessException ;
179+
163180 /**
164181 * Execute a {@code SELECT} query with paging and convert the result set to a {@link Slice} of entities. A sliced
165182 * query translates the effective {@link Statement#getFetchSize() fetch size} to the page size.
166183 *
167184 * @param statement the CQL statement, must not be {@literal null}.
168- * @param entityClass The entity type must not be {@literal null}.
185+ * @param entityClass the entity type must not be {@literal null}.
169186 * @return the converted results
170187 * @throws DataAccessException if there is any problem executing the query.
171188 * @since 2.0
@@ -190,7 +207,7 @@ default CassandraBatchOperations batchOps() {
190207 * Execute a {@code SELECT} query and convert the resulting item to an entity.
191208 *
192209 * @param statement must not be {@literal null}.
193- * @param entityClass The entity type must not be {@literal null}.
210+ * @param entityClass the entity type must not be {@literal null}.
194211 * @return the converted object or {@literal null}.
195212 * @throws DataAccessException if there is any problem executing the query.
196213 */
@@ -204,7 +221,7 @@ default CassandraBatchOperations batchOps() {
204221 * Execute a {@code SELECT} query and convert the resulting items to a {@link List} of entities.
205222 *
206223 * @param query must not be {@literal null}.
207- * @param entityClass The entity type must not be {@literal null}.
224+ * @param entityClass the entity type must not be {@literal null}.
208225 * @return the converted results
209226 * @throws DataAccessException if there is any problem executing the query.
210227 * @since 2.0
@@ -215,7 +232,7 @@ default CassandraBatchOperations batchOps() {
215232 * Execute a {@code SELECT} query with paging and convert the result set to a {@link Slice} of entities.
216233 *
217234 * @param query the query object used to create a CQL statement, must not be {@literal null}.
218- * @param entityClass The entity type must not be {@literal null}.
235+ * @param entityClass the entity type must not be {@literal null}.
219236 * @return the converted results
220237 * @throws DataAccessException if there is any problem executing the query.
221238 * @since 2.0
@@ -241,7 +258,7 @@ default CassandraBatchOperations batchOps() {
241258 * Execute a {@code SELECT} query and convert the resulting item to an entity.
242259 *
243260 * @param query must not be {@literal null}.
244- * @param entityClass The entity type must not be {@literal null}.
261+ * @param entityClass the entity type must not be {@literal null}.
245262 * @return the converted object or {@literal null}.
246263 * @throws DataAccessException if there is any problem executing the query.
247264 * @since 2.0
@@ -253,7 +270,7 @@ default CassandraBatchOperations batchOps() {
253270 *
254271 * @param query must not be {@literal null}.
255272 * @param update must not be {@literal null}.
256- * @param entityClass The entity type must not be {@literal null}.
273+ * @param entityClass the entity type must not be {@literal null}.
257274 * @throws DataAccessException if there is any problem executing the query.
258275 */
259276 boolean update (Query query , Update update , Class <?> entityClass ) throws DataAccessException ;
@@ -262,7 +279,7 @@ default CassandraBatchOperations batchOps() {
262279 * Remove entities (rows)/columns from the table by {@link Query}.
263280 *
264281 * @param query must not be {@literal null}.
265- * @param entityClass The entity type must not be {@literal null}.
282+ * @param entityClass the entity type must not be {@literal null}.
266283 * @throws DataAccessException if there is any problem executing the query.
267284 */
268285 boolean delete (Query query , Class <?> entityClass ) throws DataAccessException ;
@@ -322,7 +339,7 @@ default CassandraBatchOperations batchOps() {
322339 * @param id the Id value. For single primary keys it's the plain value. For composite primary keys either the
323340 * {@link org.springframework.data.cassandra.core.mapping.PrimaryKeyClass} or
324341 * {@link org.springframework.data.cassandra.core.mapping.MapId}. Must not be {@literal null}.
325- * @param entityClass The entity type must not be {@literal null}.
342+ * @param entityClass the entity type must not be {@literal null}.
326343 * @return the converted object or {@literal null}.
327344 * @throws DataAccessException if there is any problem executing the query.
328345 */
@@ -407,15 +424,15 @@ default WriteResult delete(Object entity, DeleteOptions options) throws DataAcce
407424 * @param id the Id value. For single primary keys it's the plain value. For composite primary keys either the
408425 * {@link org.springframework.data.cassandra.core.mapping.PrimaryKeyClass} or
409426 * {@link org.springframework.data.cassandra.core.mapping.MapId}. Must not be {@literal null}.
410- * @param entityClass The entity type must not be {@literal null}.
427+ * @param entityClass the entity type must not be {@literal null}.
411428 * @throws DataAccessException if there is any problem executing the query.
412429 */
413430 boolean deleteById (Object id , Class <?> entityClass ) throws DataAccessException ;
414431
415432 /**
416433 * Execute a {@code TRUNCATE} query to remove all entities of a given class.
417434 *
418- * @param entityClass The entity type must not be {@literal null}.
435+ * @param entityClass the entity type must not be {@literal null}.
419436 * @throws DataAccessException if there is any problem executing the query.
420437 */
421438 void truncate (Class <?> entityClass ) throws DataAccessException ;
0 commit comments