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

Expose some properties as Enums #578

Open
xisvaldo opened this issue Feb 14, 2023 · 3 comments
Open

Expose some properties as Enums #578

xisvaldo opened this issue Feb 14, 2023 · 3 comments

Comments

@xisvaldo
Copy link

We are using hypersistence-utils in our applications, but we are not using the hibernate.properties explicitly. Instead, we are customizing the object mapper via Spring @Configuration, extending HibernatePropertiesCustomizer.
It would be very useful if we do not have to depend on string changes on both sides, I mean, if in the future you decide to change hypersistence.utils.jackson.object.mapper property name to something else, developers would also have to change it.
I would like to suggest exposing those properties as enums.

@vladmihalcea
Copy link
Owner

Even if an Enum is used, if a property name will change, it's Enum name will change as well.

The properties are already exposed as constants you can reference programmatically, so you don't need to use the String values in the Java based Spring configuration.

@xisvaldo
Copy link
Author

Thanks for your quick answer. I understand your point regarding to the Enum name.
But I can't see how the properties are exposed as constants. For example:

public enum PropertyKey {
        JACKSON_OBJECT_MAPPER(
            "hypersistence.utils.jackson.object.mapper",
            "hibernate.types.jackson.object.mapper"
        )

hypersistence.utils.jackson.object.mapper is plain string, a private key from PropertyKey.JACKSON_OBJECT_MAPPER. If at least it was like Configuration.PROPERTIES_FILE_PATH, we could access it instead of hardcording a string.

@vladmihalcea vladmihalcea reopened this Feb 14, 2023
@vladmihalcea
Copy link
Owner

Yes, that's right. I was under the impression that it's possible to use the PropertyKey directly when passing the settings, but that's not currently possible.

If you this it's useful, you could try to provide a Pull Request that adds support for this feature.

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

No branches or pull requests

2 participants