Persist RoleRightType by stable getId() instead of ordinal

Fixkamo-shared-library
Ya
20 Aprili 2026, 20:59 UTC
Mwandishi
Kamo
Ahadi ya
ea4a85b

Hibernate @Enumerated(EnumType.ORDINAL) writes/reads the declaration-index of the enum. When a RoleRightType value is removed (e.g. MANAGE_USERS, id=19), every subsequent entry's ordinal shifts down by one while getId() stays put — creating a silent divergence. In this codebase the raw-SQL upsert **************** has always written getId(), so after MANAGE_USERS was removed + new rights added the DB now holds right_type values (e.g. 136) that exceed RoleRightType.values().length, causing Hibernate to throw ArrayIndexOutOfBoundsException on read and crash startup. Introduce RoleRightTypeIdConverter **************** Integer>) that round-trips via getId(). Apply to all five ORDINAL-mapped right tables: - OrgRoleRight - MemberRight - JobTitleRight - DepartmentRight - MemberRightsApplied Unknown ids convert back to null so **************** can clean them up on the next boot rather than crashing. The column data already matches getId() (that's what insertIfAbsent writes), so no migration is needed — the converter aligns Hibernate with what's actually stored.

Mabadiliko yote

Je, unaona nini kuhusu usafiri?

Kila moja ya hizi updates ardhi katika nafasi yako ya kazi moja kwa moja. Kuanza bure na kuangalia kukua wiki baada ya wiki.

Kuwa Huru MileleMtazamo wa bei