Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Map keys of @MappedCollection not converted back to Enum #1656

Closed
Tsyklop opened this issue Nov 6, 2023 · 0 comments
Closed

Map keys of @MappedCollection not converted back to Enum #1656

Tsyklop opened this issue Nov 6, 2023 · 0 comments
Assignees
Labels
type: bug A general bug

Comments

@Tsyklop
Copy link

Tsyklop commented Nov 6, 2023

I have two entities:


@Data
@Table(name = "analyze_session")
@SuperBuilder
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(callSuper = true)
public class AnalyzeSessionEntity extends BaseEntity {

    private Instant endAt;

    private Instant startAt;

    private boolean ended;

    @ToString.Exclude
    @MappedCollection(idColumn = "analyze_session_id", keyColumn = "sport")
    private Map<SportType, AnalyzeSessionSportDataEntity> sportDataBySport;

    public boolean isAllSportsDataDone() {
        return this.sportDataBySport.entrySet().stream().allMatch(entry -> entry.getValue().isDone());
    }

}


@Data
@Table(name = "analyze_session_sport_data")
@Builder
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(callSuper = true)
public class AnalyzeSessionSportDataEntity extends BaseEntity {

    private boolean done;

    private SportType sport;

    private int analyzedCount;

    private Integer lastDonePage;

    private LocalDate lastDoneDate;

    private long analyzeSessionId;

}

And when Spring data jdbc load sportDataBySport Map and use String as key of Map, but need use my own enum SportType.

here screenshoots from debugger:

image
image

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Nov 6, 2023
@mp911de mp911de added type: bug A general bug and removed status: waiting-for-triage An issue we've not yet triaged labels Nov 6, 2023
schauder added a commit that referenced this issue Nov 15, 2023
Keys of maps now get properly converted.
Among others this enables the use of enums as keys.

Closes #1656
@mp911de mp911de changed the title Map with @MappedCollection and Enum key Map keys of @MappedCollection not converted back to Enum Nov 16, 2023
mp911de pushed a commit that referenced this issue Nov 16, 2023
Keys of maps now get properly converted.
Among others this enables the use of enums as keys.

Closes #1656
Original pull request: #1663
@mp911de mp911de added this to the 3.1.6 (2023.0.6) milestone Nov 16, 2023
schauder added a commit that referenced this issue Nov 16, 2023
Changed BIGINT to NUMBER.

See #1656
Original pull request #1663
schauder added a commit that referenced this issue Nov 16, 2023
Changed BIGINT to NUMBER.

See #1656
Original pull request #1663
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug A general bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants