Skip to content

Spanner: Convenient way to read Object/Objects from db. #2270

Description

@bullet-tooth

It would be great to have a convenient way to retrieve the data as pojos from Spanner database.
For example com.google.cloud.spanner.ReadContext interface could be expanded with such methods for this purpose:

<T> T readRow(String table, StructMapper<T> mapper, Key key, Iterable<String> columns);
<T> List<T> read(String table, StructMapper<T> mapper, KeySet keys, Iterable<String> columns, ReadOption... options);

Where StructMapper is an interface that can be implemented by users for custom pojos. Also it is a reason to create default implementation that covers conversion for common types, as example org.springframework.jdbc.core.BeanPropertyRowMapper.

If you're ok with that I would be pleasant to make pull request.

Metadata

Metadata

Assignees

Labels

api: spannerIssues related to the Spanner API.priority: p2Moderately-important priority. Fix may not be included in next release.type: feature request‘Nice-to-have’ improvement, new feature or different behavior or design.

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions