From 5851db384cd6eceee48010dfee6a5e3d0fae41da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Armin=20Krezovi=C4=87?= Date: Fri, 18 Jul 2025 17:57:04 +0200 Subject: [PATCH] HHH-16253 - Schema Validation Failure With Audited (N)Clob Column MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://hibernate.atlassian.net/browse/HHH-16253 Signed-off-by: Armin Krezović --- .../source/internal/hbm/ModelBinder.java | 22 ++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/hibernate-core/src/main/java/org/hibernate/boot/model/source/internal/hbm/ModelBinder.java b/hibernate-core/src/main/java/org/hibernate/boot/model/source/internal/hbm/ModelBinder.java index 544c38379a06..490df12f52cc 100644 --- a/hibernate-core/src/main/java/org/hibernate/boot/model/source/internal/hbm/ModelBinder.java +++ b/hibernate-core/src/main/java/org/hibernate/boot/model/source/internal/hbm/ModelBinder.java @@ -155,6 +155,7 @@ import org.hibernate.type.CustomType; import org.hibernate.type.ForeignKeyDirection; import org.hibernate.type.StandardBasicTypes; +import org.hibernate.type.internal.BasicTypeImpl; import org.hibernate.type.spi.TypeConfiguration; import org.hibernate.usertype.CompositeUserType; import org.hibernate.usertype.ParameterizedType; @@ -1877,11 +1878,22 @@ private void resolveLob(final SingularAttributeSourceBasic attributeSource, Simp // Resolves whether the property is LOB based on the type attribute on the attribute property source. // Essentially this expects the type to map to a CLOB/NCLOB/BLOB sql type internally and compares. if ( !value.isLob() && value.getTypeName() != null ) { - final BasicType basicType = attributeSource.getBuildingContext() - .getMetadataCollector() - .getTypeConfiguration() - .getBasicTypeRegistry() - .getRegisteredType( value.getTypeName() ); + BasicType basicType = null; + + if ( value.getTypeName().startsWith( BasicTypeImpl.EXTERNALIZED_PREFIX ) ) { + basicType = attributeSource.getBuildingContext() + .getBootstrapContext() + .resolveAdHocBasicType( value.getTypeName() ); + } + + if ( basicType == null ) { + basicType = attributeSource.getBuildingContext() + .getMetadataCollector() + .getTypeConfiguration() + .getBasicTypeRegistry() + .getRegisteredType( value.getTypeName() ); + } + if ( basicType instanceof AbstractSingleColumnStandardBasicType ) { if ( isLob( basicType.getJdbcType().getDdlTypeCode(), null ) ) { value.makeLob();