Skip to content

Conversation

@gavinking
Copy link
Member

Previously, the static metamodel would sometimes return objects of the wrong type. For example, an Attribute<java.sql.Date> could return java.util.Date.class, which was not only wrong but also unsound. This happened because we have JavaTypes which weren't actually modeling Java types. For example, JdbcTimestampType wasn't a JavaType`.

I believe that this is the original root cause of plenty of unsoundness and weirdness in our code base, so I have spent a day redoing it, so that fields of type java.util.Date are always represented by DateJavaType, and fields of type java.sql.Date by JdbcDateJavaType.


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.


…type Date

This fixes bugs in the metamodel where getJavaType() would return the wrong
class even in the Persistence-standard metamodel. It's also a first step to
fixing a bunch of other unsound things we do in the codebase.
though perhaps we could just remove this functionality
@gavinking gavinking marked this pull request as ready for review December 10, 2025 17:59
@hibernate-github-bot
Copy link

hibernate-github-bot bot commented Dec 10, 2025

Thanks for your pull request!

This pull request does not follow the contribution rules. Could you have a look?

❌ All commit messages should start with a JIRA issue key matching pattern HHH-\d+
    ↳ Offending commits: [95a31e6, 9946499, 2a9c35a, 1636aac, 57b8584, 3a6a227, 7f5918d, 6cba4ab, b43dc84, b4aaa3e, 43bf926, 1da0f3e, f285670]

› This message was automatically generated.

@gavinking
Copy link
Member Author

Naturally,, it broke Envers.

@sebersole
Copy link
Member

Why are we dramatically changing the behavior of something we are actively telling people to not use?

@gavinking
Copy link
Member Author

gavinking commented Dec 10, 2025

Why are we dramatically changing the behavior of something we are actively telling people to not use?

As I said:

I believe that this is the original root cause of plenty of unsoundness and weirdness in our code base

Whether people are using it or not, we still have these weird objects floating around in our code which aren't what they claim to be. Which prevents us from adding assertions based on the reified types of things.

@gavinking gavinking changed the title big change to handling of java.util.Date and friends HHH-19981 big change to handling of java.util.Date and friends Dec 10, 2025
private <X> TemporalJavaType<X> forMissingPrecision(TypeConfiguration typeConfiguration) {
//noinspection unchecked,rawtypes
return (TemporalJavaType) this;
private TemporalJavaType<T> forMissingPrecision(TypeConfiguration typeConfiguration) {

Check notice

Code scanning / CodeQL

Useless parameter Note

The parameter 'typeConfiguration' is never used.
}

protected <X> TemporalJavaType<X> forTimestampPrecision(TypeConfiguration typeConfiguration) {
protected TemporalJavaType<T> forTimestampPrecision(TypeConfiguration typeConfiguration) {

Check notice

Code scanning / CodeQL

Useless parameter Note

The parameter 'typeConfiguration' is never used.
}

protected <X> TemporalJavaType<X> forDatePrecision(TypeConfiguration typeConfiguration) {
protected TemporalJavaType<T> forDatePrecision(TypeConfiguration typeConfiguration) {

Check notice

Code scanning / CodeQL

Useless parameter Note

The parameter 'typeConfiguration' is never used.
}

protected <X> TemporalJavaType<X> forTimePrecision(TypeConfiguration typeConfiguration) {
protected TemporalJavaType<T> forTimePrecision(TypeConfiguration typeConfiguration) {

Check notice

Code scanning / CodeQL

Useless parameter Note

The parameter 'typeConfiguration' is never used.
JavaTypeRegistry and TypeConfiguration are now much cleaner

+ related minor cleanups in these classes
@gavinking gavinking merged commit c973caa into hibernate:main Dec 12, 2025
23 of 27 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