[JIRA] (HHH-16591) @org.hibernate.annotations.JdbcType does not override the `hibernate.type.preferred_duration_jdbc_type` type
by Čedomir Igaly (JIRA)
Čedomir Igaly ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%... ) *commented* on HHH-16591 ( https://hibernate.atlassian.net/browse/HHH-16591?atlOrigin=eyJpIjoiYzNmND... )
Re: @org.hibernate.annotations.JdbcType does not override the `hibernate.type.preferred_duration_jdbc_type` type ( https://hibernate.atlassian.net/browse/HHH-16591?atlOrigin=eyJpIjoiYzNmND... )
Please, correct me if I am worng …
In present implementation you first and last assertions are contradictory. If registered JdbcType for SqlTypes.INTERVAL_SECOND is NumericJdbcType (first assertion), then sam JdbcType will be used for property annotated with @JdbcType(SqlTypes.INTERVAL_SECOND) (as is checked with last assertion). My understanding (again, please, correct me if I am wrong) is that JdbcType for INTERVAL_SECOND should not be replaced when preferred duration JDBC type is set to NUMERIC. What should be changed is JavaType used, by default, for java.time.Duration properties.
It seems to me that it your test case line
>
>
>
> final JdbcType intervalType = jdbcTypeRegistry.getDescriptor(
> SqlTypes.INTERVAL_SECOND );
>
>
should be replaced with:
>
>
>
> final JdbcType intervalType =
> mappingMetamodel.getTypeConfiguration().getBasicTypeForJavaType(
> Duration.class ).getJdbcType();
>
>
My understanding is that, whatever is preferred JDBC type for Duration is, JDBC type 3100 (= SqlTypes.INTERVAL_SECOND) should be handled by same JdbcType implementation. In this case this is PostgreSQLIntervalSecondJdbcType. To check that I wil add line:
>
>
>
> assertThat( jdbcTypeRegistry.getDescriptor( SqlTypes.INTERVAL_SECOND ) )
>
>
>
> .isOfAnyClassIn( PostgreSQLIntervalSecondJdbcType.class );
>
>
This assertion is equivalent to last one and it will fail in current implementation.
My guess is that source of the problem is in MetadataBuildingProcess class when JdbcType for INTERVAL_SECOND is replaced with one for NUMERIC. If this is fixed, your (slightly changed) test will pass, but another one will now fail.
Also, my guess is that this is more general problem, not limited only to Duration’s, but for other types where there is preferred JDBC type.
( https://hibernate.atlassian.net/browse/HHH-16591#add-comment?atlOrigin=ey... ) Add Comment ( https://hibernate.atlassian.net/browse/HHH-16591#add-comment?atlOrigin=ey... )
Get Jira notifications on your phone! Download the Jira Cloud app for Android ( https://play.google.com/store/apps/details?id=com.atlassian.android.jira.... ) or iOS ( https://itunes.apple.com/app/apple-store/id1006972087?pt=696495&ct=EmailN... ) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100225- sha1:e4eb869 )
2 years, 11 months