HHH-20318 + HHH-20647 Fix Clob/NClob unwrap and wrap conversions#12955
Conversation
|
https://github.com/hibernate/hibernate-orm/actions/runs/28514900223/job/84584414810 @beikov The PostgreSQL-family CI checks failed with the trace below. Here's my analysis. Stack traceRoot causePostgreSQL declares At bind time, the following call is then made, and because none of the branches in st.setClob( index, javaType.unwrap( nclob, Clob.class, options ) );My takeI think this should be tracked as a separate ticket. So, for now, I've marked As shown above, this lives in a code path unrelated to the |
beikov
left a comment
There was a problem hiding this comment.
I think this should be tracked as a separate ticket. So, for now, I've marked NClobAttributeQueryUpdateTest with @SkipForDialect(PostgreSQLDialect.class, matchSubTypes = true) and pushed the change.
As shown above, this lives in a code path unrelated to the CharacterStream unwrap branch this ticket was opened for. HHH-20318 should stay scoped to the CharacterStream conversion mistake, especially since this failure surfaces on a database that sits on the opposite side from those originally called out in this ticket.
I agree that this is out of scope for that ticket, but then please create another Jira ticket and add a commit for that to this PR, which addresses my last concerns.
Signed-off-by: Oh YoungJe <139232765+GulSauce@users.noreply.github.com>
Signed-off-by: Oh YoungJe <139232765+GulSauce@users.noreply.github.com>
|
@beikov |
|
The |
Changes are ready to merge, Christian confirmed it by DM
HHH-20318
issue
SerializableClobProxy(wrapped when aClobinstance is passed during parameter wrap)and
java.sql.Clobdo not implementClobImplementer.The class passed to the
unwrapfunction then differs depending on the Dialect.Dialects where
useStreamForLobBinding() == false(PostgreSQL, etc.)CLOB_BINDING→ callsunwrap(clob, Clob.class, _)SerializableClobProxyis successfully unwrapped via thetoJdbcClobhelperDialects inheriting the default (H2, MySQL, etc.)
STREAM_BINDING→ callsunwrap(clob, CharacterStream.class, _)instanceof ClobImplementerisfalse, so theelsebranch is enteredjava.io.Readerto Hibernate'sCharacterStreaminterface throws aClassCastExceptionfix
Applied the same logic as
BlobJavaType.unwrap'sreturn type.cast( new StreamBackedBinaryStream( value.getBinaryStream(), value.length() ) );.In the
elsebranch, explicitly construct aCharacterStreamImpl(Reader, long)to wrap theReaderin aCharacterStreamimplementation.NClobJavaType.unwraphas the same issue and is fixed as well.HHH-20647
issue
PostgreSQL declares
NationalizationSupport.IMPLICIT, soDialect#contributeTypes(TypeContributions, ServiceRegistry)does not register the NClob descriptor. As a result, descriptor lookup falls back to the family descriptor —ClobJdbcType.At bind time, the following call is then made, and because none of the branches in
NClobJavaType#unwrapmatchClob.class, execution falls through tothrow unknownUnwrap(type);atNClobJavaType.java:143:fix
Added conversion logic
—
NClob→Clobinunwrapand
Clob→NClobinwrap.https://hibernate.atlassian.net/browse/HHH-20318
https://hibernate.atlassian.net/browse/HHH-20647
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.
Please make sure that the following tasks are completed:
Tasks specific to HHH-20647 (Bug):
migration-guide.adocOR check there are no breaking changesTasks specific to HHH-20318 (Bug):
migration-guide.adocOR check there are no breaking changes