Skip to content

Conversation

@vbabanin
Copy link
Member

@vbabanin vbabanin commented Sep 6, 2025

Hibernate ORM currently handles temporal types (Instant, etc.) inconsistently depending on where they appear in an entity. For example, saving an Instant of 10:15 (always UTC) on a host in GMT+1 leads to inconsistent results once read (tested with Postgres dialect):

top-level field -> 10:15 (correct)
array/collection element -> 09:15
struct field -> 11:15

This inconsistency makes it difficult to predict how temporal values will be stored and retrieved.

This PR ensures that temporal types are handled consistently in MongoDB extension across top-level fields, arrays/collections, and structs, so that serialization and deserialization behave uniformly regardless of context.

HIBERNATE-42

@vbabanin vbabanin self-assigned this Sep 6, 2025
@vbabanin vbabanin requested a review from stIncMale September 6, 2025 02:47
@vbabanin vbabanin marked this pull request as ready for review September 9, 2025 06:22
@vbabanin vbabanin requested a review from a team as a code owner September 9, 2025 06:22
Object enabled = configurationValues.get("hibernate.type.java_time_use_direct_jdbc");
if (enabled instanceof Boolean && (Boolean) enabled) {
throw new HibernateException(format(
"Configuration property [%s] is incubating and not supported in MongoDB dialect",
Copy link
Member Author

@vbabanin vbabanin Sep 9, 2025

Choose a reason for hiding this comment

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

Offline review with Valentin:
Remove "is incubating" and "Mongo dialect"

HIBERNATE-42
@vbabanin vbabanin force-pushed the HIBERNATE-42-instant branch from ac167e0 to d7b51e5 Compare September 10, 2025 03:25
Copy link
Member

@stIncMale stIncMale left a comment

Choose a reason for hiding this comment

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

Submitting intermediate review results.

@stIncMale
Copy link
Member

The PR with all the proposed changes: vbabanin#1.

# Conflicts:
#	src/main/java/com/mongodb/hibernate/dialect/MongoDialect.java
- Add tests for the forbidden temporal types.
- Use TimestampUtcAsInstantJdbcType.
- Rename test method and display names.

HIBERNATE-42
Add test case for flattened unsupported id types.
@vbabanin vbabanin requested a review from stIncMale October 15, 2025 20:47
Copy link
Member

@stIncMale stIncMale left a comment

Choose a reason for hiding this comment

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

The last reviewed commit is 62e3e2f.

@vbabanin vbabanin requested a review from stIncMale October 21, 2025 21:01
Copy link
Member

@stIncMale stIncMale left a comment

Choose a reason for hiding this comment

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

The last reviewed commit is 087a70b.

Add test-case.
Copy link
Member

@stIncMale stIncMale left a comment

Choose a reason for hiding this comment

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

The last reviewed commit is 101c1bf.

@vbabanin vbabanin requested a review from stIncMale October 23, 2025 16:27
@vbabanin vbabanin merged commit 193c5c7 into mongodb:main Oct 23, 2025
7 checks passed
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