[JIRA] (HHH-16781) @JavaType annotation is ignored when Basic type is already registered for same JabcType/Java class pair
by Čedomir Igaly (JIRA)
Čedomir Igaly ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%... ) *commented* on HHH-16781 ( https://hibernate.atlassian.net/browse/HHH-16781?atlOrigin=eyJpIjoiYWZiZm... )
Re: @JavaType annotation is ignored when Basic type is already registered for same JabcType/Java class pair ( https://hibernate.atlassian.net/browse/HHH-16781?atlOrigin=eyJpIjoiYWZiZm... )
Source of the problem is in method InferredBasicValueResolver#from.
When explicitJavaType is non null, call to BasicTypeRegistry#resolve. This part of code is real source of the problem:
>
>
>
> final BasicType<J> basicType = getRegisteredType( jtdToUse.getJavaType()
> );
>
>
>
> if ( basicType != null ) {
>
>
>
> if ( basicType.getJdbcType() == stdToUse )
>
> Unknown macro: { return basicType; }
>
>
> else
>
> Unknown macro: { return new NamedBasicTypeImpl<>( jtdToUse, stdToUse,
> basicType.getName() ); }
>
>
> }
>
>
basicType is non null since there is registered type corresponding to JavaType. Since basicType.jdbcType is identical to required JdbcType, it will be returned as result
To avoid that problem, when explicitJavaType is non null, part of code
>
>
>
> jdbcMapping = resolveSqlTypeIndicators(
>
>
>
> stdIndicators,
>
>
>
> typeConfiguration.getBasicTypeRegistry().resolve( explicitJavaType,
> inferredJdbcType ),
>
>
>
> explicitJavaType
>
>
>
> );
>
>
is replaced by
>
>
>
> final BasicTypeImpl<T> basicType = new BasicTypeImpl<>( explicitJavaType,
> inferredJdbcType );
>
>
>
> // if we are still building mappings, register this ad-hoc type
>
>
>
> // via a unique code. this is to support envers
>
>
>
> typeConfiguration.getMetadataBuildingContext().getBootstrapContext()
>
>
>
> .registerAdHocBasicType( basicType );
>
>
>
> jdbcMapping = resolveSqlTypeIndicators(
>
>
>
> stdIndicators,
>
>
>
> basicType,
>
>
>
> explicitJavaType
>
>
>
> );
>
>
Which is copy&paste cerator parameter from BasicTypeRegistry#resolve
( https://hibernate.atlassian.net/browse/HHH-16781#add-comment?atlOrigin=ey... ) Add Comment ( https://hibernate.atlassian.net/browse/HHH-16781#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:956085d )
1 year, 3 months
[JIRA] (HHH-16779) EntityManager.find(Class<T> entityClass, Object primaryKey) generate unexpected sql
by 周雁鸣 (JIRA)
周雁鸣 ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%... ) *updated* an issue
Hibernate ORM ( https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiMzNhZWFmZmNm... ) / Bug ( https://hibernate.atlassian.net/browse/HHH-16779?atlOrigin=eyJpIjoiMzNhZW... ) HHH-16779 ( https://hibernate.atlassian.net/browse/HHH-16779?atlOrigin=eyJpIjoiMzNhZW... ) EntityManager.find(Class<T> entityClass, Object primaryKey) generate unexpected sql ( https://hibernate.atlassian.net/browse/HHH-16779?atlOrigin=eyJpIjoiMzNhZW... )
Change By: 周雁鸣 ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%... )
Before hibernate 6.2
{code:sql}o.h.SQL DEBUG select t1_0.id,t1_0.index from test_entity t1_0 where t1_0.id=?
o.h.o.j.bind TRACE binding parameter [1] as [ARRAY] - [1]{code}
Since hibernate 6.2
{code:sql}o.h.SQL DEBUG select t1_0.id,t1_0.index from test_entity t1_0 where array_contains(?,t1_0.id)
o.h.o.j.bind TRACE binding parameter [1] as [ARRAY] - [[1, null, null, null, null, null, null, null, null, null]]{code}
Does it changed by designed design ? if it is so , please we should add an option to let user revert it , and improve the migration document.
( https://hibernate.atlassian.net/browse/HHH-16779#add-comment?atlOrigin=ey... ) Add Comment ( https://hibernate.atlassian.net/browse/HHH-16779#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:956085d )
1 year, 3 months