diff --git a/hibernate-core/src/main/java/org/hibernate/boot/model/internal/CollectionBinder.java b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/CollectionBinder.java index b1f9ed1685..a1f89fd5ea 100644 --- a/hibernate-core/src/main/java/org/hibernate/boot/model/internal/CollectionBinder.java +++ b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/CollectionBinder.java @@ -1143,7 +1143,7 @@ public abstract class CollectionBinder { Locale.ROOT, "Property '%s.%s' is not a collection and may not be a '@OneToMany', '@ManyToMany', or '@ElementCollection'", property.getDeclaringType().getName(), - property.getName() + property.resolveAttributeName() ) ); } diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/collections/custom/declaredtype/UserWithUnimplementedCollectionTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/collections/custom/declaredtype/UserWithUnimplementedCollectionTest.java index 4fb6d9f4ce..4c608fee95 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/collections/custom/declaredtype/UserWithUnimplementedCollectionTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/collections/custom/declaredtype/UserWithUnimplementedCollectionTest.java @@ -31,46 +31,48 @@ package org.hibernate.orm.test.mapping.collections.custom.declaredtype; import org.hibernate.AnnotationException; +import org.hibernate.SessionFactory; +import org.hibernate.boot.Metadata; +import org.hibernate.boot.MetadataSources; + import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; -import org.junit.Test; +import org.hibernate.testing.orm.junit.DomainModel; +import org.hibernate.testing.orm.junit.DomainModelScope; +import org.hibernate.testing.orm.junit.ServiceRegistry; +import org.hibernate.testing.orm.junit.ServiceRegistryScope; +import org.junit.jupiter.api.Test; + +import jakarta.persistence.OneToMany; import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; /** + * Test that we get an exception when an attribute whose type is not a Collection + * is annotated with any of