Skip to content

Mapping two-column result set to Map #2672

Closed
@acanthite1855

Description

@acanthite1855

It would be nice to have a simple built-in way top map two-column result set to a Map. Just like mapping single-column results to List or Set.

Currently, my options either to create a DTO and then manually do result.stream().collect(toMap(Dto::getId, Dto::getCount)) or use @MapKey("id") and Map<Long, Dto> or use ResultHandler, which is basically the same as streams but ugly, though it does not allocate unnecessary instances of Dto class.

At least that's the options I've found on google so far. I mean, it is quite a common issue.

Are there any limitations that make it impossible to implement such mapping as a built-in feature?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions