diff --git a/hibernate-core/src/main/java/org/hibernate/boot/model/process/internal/NamedConverterResolution.java b/hibernate-core/src/main/java/org/hibernate/boot/model/process/internal/NamedConverterResolution.java index 66d8b6ab60..3eff73136f 100644 --- a/hibernate-core/src/main/java/org/hibernate/boot/model/process/internal/NamedConverterResolution.java +++ b/hibernate-core/src/main/java/org/hibernate/boot/model/process/internal/NamedConverterResolution.java @@ -6,6 +6,7 @@ */ package org.hibernate.boot.model.process.internal; +import java.util.Collection; import java.util.Map; import java.util.function.Function; @@ -16,7 +17,6 @@ import org.hibernate.boot.model.convert.spi.JpaAttributeConverterCreationContext import org.hibernate.boot.registry.classloading.spi.ClassLoaderService; import org.hibernate.boot.spi.MetadataBuildingContext; import org.hibernate.mapping.BasicValue; -import org.hibernate.mapping.Collection; import org.hibernate.metamodel.mapping.JdbcMapping; import org.hibernate.type.BasicType; import org.hibernate.type.descriptor.converter.internal.AttributeConverterMutabilityPlanImpl; @@ -149,6 +149,8 @@ public class NamedConverterResolution implements BasicValue.Resolution { return ImmutableMutabilityPlan.instance(); } + // if the domain JavaType is immutable, use the immutability plan + // - note : ignore this for collection-as-basic mappings. if ( !domainJtd.getMutabilityPlan().isMutable() && !isCollection( domainJtd.getJavaTypeClass() ) ) { return ImmutableMutabilityPlan.instance(); diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/collections/asbasic/CommaDelimitedStringsConverter.java b/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/collections/asbasic/CommaDelimitedStringsConverter.java index 931690191f..cf9cf982f2 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/collections/asbasic/CommaDelimitedStringsConverter.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/collections/asbasic/CommaDelimitedStringsConverter.java @@ -6,12 +6,17 @@ */ package org.hibernate.orm.test.mapping.collections.asbasic; +import java.util.ArrayList; import java.util.Arrays; import java.util.List; +import org.hibernate.internal.util.collections.CollectionHelper; + import jakarta.persistence.AttributeConverter; + import static org.hibernate.internal.util.StringHelper.join; +import static org.hibernate.internal.util.collections.CollectionHelper.listOf; /** * @author Steve Ebersole @@ -31,7 +36,7 @@ public class CommaDelimitedStringsConverter implements AttributeConverter { + final Person reloaded = session.byId( Person.class ).load( 1 ); + assertThat( reloaded.nickNames ).hasSize( 3 ); } ); }