Skip to content

HHH-9414: Convert MarkerObject to enum for serialization safety#11703

Open
hoyeonyy wants to merge 1 commit intohibernate:mainfrom
hoyeonyy:HHH-9414
Open

HHH-9414: Convert MarkerObject to enum for serialization safety#11703
hoyeonyy wants to merge 1 commit intohibernate:mainfrom
hoyeonyy:HHH-9414

Conversation

@hoyeonyy
Copy link

@hoyeonyy hoyeonyy commented Jan 29, 2026

Description

Fixes HHH-9414 by converting MarkerObject from class to enum, ensuring singleton identity is preserved across serialization/deserialization.

Problem:
Class-based MarkerObject creates new instances when deserialized, breaking == reference checks in session serialization scenarios (Spring Web Flow, clustered environments).

Solution:
Use enum to leverage Java's built-in serialization guarantees for singletons.

Changes

  • Convert MarkerObject to enum with 6 constants
  • Update 6 usage sites to reference enum values
  • Add comprehensive serialization tests

Fixes https://hibernate.atlassian.net/browse/HHH-9414


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license
and can be relicensed under the terms of the LGPL v2.1 license in the future at the maintainers' discretion.
For more information on licensing, please check here.



Please make sure that the following tasks are completed:
Tasks specific to HHH-9414 (Bug):

  • Add test reproducing the bug
  • Add entries as relevant to migration-guide.adoc OR check there are no breaking changes

Copy link
Member

@beikov beikov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the change, but the test seems useless to me. I'm not sure why the class was deprecated though as we use it internally. Can you chime in @gavinking?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants