Skip to content

Conversation

marko-bekhta
Copy link
Contributor

Opening as a draft as it's based on Marco's PR: #49271

I've added "reasons" why the check is failing to help users identify what's been modified and hopefully help them.
Then for the checks themselves ... looking through the Jackson properties:

if (!jacksonBuildTimeConfig.failOnUnknownProperties()) {
// this feature is enabled by default, so we disable it
objectMapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
}
if (!jacksonBuildTimeConfig.failOnEmptyBeans()) {
// this feature is enabled by default, so we disable it
objectMapper.disable(SerializationFeature.FAIL_ON_EMPTY_BEANS);
}
if (!jacksonBuildTimeConfig.writeDatesAsTimestamps()) {
// this feature is enabled by default, so we disable it
objectMapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
}
if (!jacksonBuildTimeConfig.writeDurationsAsTimestamps()) {
// this feature is enabled by default, so we disable it
objectMapper.disable(SerializationFeature.WRITE_DURATIONS_AS_TIMESTAMPS);
}
if (jacksonBuildTimeConfig.acceptCaseInsensitiveEnums()) {
objectMapper.enable(MapperFeature.ACCEPT_CASE_INSENSITIVE_ENUMS);
}
JsonInclude.Include serializationInclusion = jacksonBuildTimeConfig.serializationInclusion().orElse(null);
if (serializationInclusion != null) {
objectMapper.setSerializationInclusion(serializationInclusion);
}
ZoneId zoneId = jacksonBuildTimeConfig.timezone();
if (!zoneId.getId().equals("UTC")) { // Jackson uses UTC as the default, so let's not reset it
objectMapper.setTimeZone(TimeZone.getTimeZone(zoneId));
}
if (jacksonSupport.configuredNamingStrategy().isPresent()) {
objectMapper.setPropertyNamingStrategy(jacksonSupport.configuredNamingStrategy().get());
}

I guess unless the user switched back to the defaults -- they are potentially in trouble, so I tried to include that and check the values.

@quarkus-bot quarkus-bot bot added the area/hibernate-orm Hibernate ORM label Aug 1, 2025
Copy link

quarkus-bot bot commented Aug 1, 2025

/cc @gsmet (hibernate-orm)

Copy link
Member

@mbellade mbellade left a comment

Choose a reason for hiding this comment

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

Nice, hopefully this will get rid of false positives. Looks like these changes are unrelated to the metamodel checks though, so maybe we can merge this separately without waiting for my PR.

@gsmet gsmet changed the title Adjust the Hiberante ORM's JSON/XML formatter modification checks Adjust the Hibernate ORM's JSON/XML formatter modification checks Aug 1, 2025
@gsmet gsmet force-pushed the fix/i49258-formula-column-json-mapping branch from 789fd4b to 7a42453 Compare August 3, 2025 21:32
@gsmet gsmet marked this pull request as ready for review August 3, 2025 21:32
Copy link

quarkus-bot bot commented Aug 3, 2025

Status for workflow Quarkus CI

This is the status report for running Quarkus CI on commit 7a42453.

✅ The latest workflow run for the pull request has completed successfully.

It should be safe to merge provided you have a look at the other checks in the summary.

You can consult the Develocity build scans.

Copy link
Member

@mbellade mbellade left a comment

Choose a reason for hiding this comment

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

Now that #49321 is in with the fix for HHH-19675 we can merge this and backport to 3.25.

@FroMage
Copy link
Member

FroMage commented Aug 5, 2025

FTR, my new error message is this:

Caused by: java.lang.IllegalStateException: Persistence unit [<default>] uses Quarkus' main formatting facilities for JSON columns in the database. 
As these facilities are primarily meant for REST endpoints, and they might have been customized for such use, this may lead to undesired behavior, up to and including data loss. 
To address this:
	- If the application does not customize the JSON serialization/deserialization, set "quarkus.hibernate-orm.mapping.format.global=ignore". This will be the default in future versions of Quarkus. 
	- Otherwise, define a custom `FormatMapper` bean annotated with @JsonFormat and @PersistenceUnitExtension to address your database serialization/deserialization needs.
The reasons why the check was triggered are: 
	-Detected 'quarkus.jackson.write-dates-as-timestamps' property set to 'false'. For ObjectMapper being compatible with the clean, default one the expected value is: 'true'.
See the migration guide for more details and how to proceed.

@gsmet gsmet merged commit e85f5ad into quarkusio:main Aug 5, 2025
62 of 64 checks passed
@quarkus-bot quarkus-bot bot added this to the 3.26 - main milestone Aug 5, 2025
@gsmet
Copy link
Member

gsmet commented Aug 5, 2025

Thanks to both of you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/hibernate-orm Hibernate ORM
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants