diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/internal/Binder.java b/hibernate-core/src/main/java/org/hibernate/metamodel/internal/Binder.java index d8399b8458..9e2634d6f5 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/internal/Binder.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/internal/Binder.java @@ -1950,6 +1950,13 @@ public class Binder { @Override public List< Value > resolveRelationalValuesForAttribute( String attributeName ) { + if ( attributeName == null ) { + List< Value > values = new ArrayList< Value >(); + for ( Column column : entityBinding.getPrimaryTable().getPrimaryKey().getColumns() ) { + values.add( column ); + } + return values; + } final AttributeBinding referencedAttributeBinding = entityBinding.locateAttributeBinding( attributeName ); if ( referencedAttributeBinding == null ) { @@ -2311,6 +2318,13 @@ public class Binder { @Override public List< Value > resolveRelationalValuesForAttribute( String attributeName ) { + if ( attributeName == null ) { + List< Value > values = new ArrayList< Value >(); + for ( Column column : referencedEntityBinding.getPrimaryTable().getPrimaryKey().getColumns() ) { + values.add( column ); + } + return values; + } final AttributeBinding referencedAttributeBinding = referencedEntityBinding.locateAttributeBinding( attributeName ); if ( !referencedAttributeBinding.getAttribute().isSingular() ) { diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/annotations/ToOneAttributeSourceImpl.java b/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/annotations/ToOneAttributeSourceImpl.java index a6acab899b..6c8ad40eef 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/annotations/ToOneAttributeSourceImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/annotations/ToOneAttributeSourceImpl.java @@ -149,6 +149,9 @@ public class ToOneAttributeSourceImpl extends SingularAttributeSourceImpl implem public List getJoinColumns(JoinColumnResolutionContext context) { final List values = new ArrayList(); for ( Column column : associationAttribute.getJoinColumnValues() ) { + if ( column.getReferencedColumnName() == null ) { + return context.resolveRelationalValuesForAttribute( null ); + } org.hibernate.metamodel.spi.relational.Column resolvedColumn = context.resolveColumn( column.getReferencedColumnName(), logicalJoinTableName, diff --git a/hibernate-core/src/test/java/org/hibernate/metamodel/internal/source/annotations/entity/OneToManyBindingTest.java b/hibernate-core/src/test/java/org/hibernate/metamodel/internal/source/annotations/entity/OneToManyBindingTest.java index 280f9f12cc..ffc889dd1f 100644 --- a/hibernate-core/src/test/java/org/hibernate/metamodel/internal/source/annotations/entity/OneToManyBindingTest.java +++ b/hibernate-core/src/test/java/org/hibernate/metamodel/internal/source/annotations/entity/OneToManyBindingTest.java @@ -31,7 +31,6 @@ import org.hibernate.metamodel.spi.binding.HibernateTypeDescriptor; import org.hibernate.metamodel.spi.binding.PluralAttributeBinding; import org.hibernate.test.annotations.loader.Player; import org.hibernate.test.annotations.loader.Team; -import org.hibernate.testing.FailureExpectedWithNewMetamodel; import org.hibernate.testing.junit4.BaseAnnotationBindingTestCase; import org.hibernate.testing.junit4.Resources; @@ -44,7 +43,6 @@ import static org.junit.Assert.assertTrue; public class OneToManyBindingTest extends BaseAnnotationBindingTestCase { @Test @Resources(annotatedClasses = { Team.class, Player.class }) - @FailureExpectedWithNewMetamodel(jiraKey = "HHH-7549") public void testPluralAttributeBindingTest() { EntityBinding playerBinding = getEntityBinding( Player.class ); assertNotNull( playerBinding ); diff --git a/hibernate-core/src/test/java/org/hibernate/metamodel/spi/binding/BasicAnnotationBindingTests.java b/hibernate-core/src/test/java/org/hibernate/metamodel/spi/binding/BasicAnnotationBindingTests.java index 6a40cca347..505b6103cc 100644 --- a/hibernate-core/src/test/java/org/hibernate/metamodel/spi/binding/BasicAnnotationBindingTests.java +++ b/hibernate-core/src/test/java/org/hibernate/metamodel/spi/binding/BasicAnnotationBindingTests.java @@ -26,7 +26,6 @@ package org.hibernate.metamodel.spi.binding; import org.junit.Test; import org.hibernate.metamodel.MetadataSources; -import org.hibernate.testing.FailureExpectedWithNewMetamodel; /** * Basic tests of annotation based binding code @@ -56,8 +55,9 @@ public class BasicAnnotationBindingTests extends AbstractBasicBindingTests { sources.addAnnotatedClass( SimpleEntityWithSimpleComponent.SimpleComponent.class ); } + @Override @Test - @FailureExpectedWithNewMetamodel(jiraKey = "HHH-7549") +// @FailureExpectedWithNewMetamodel(jiraKey = "HHH-7549") public void testEntityWithManyToOneMapping() { super.testEntityWithManyToOneMapping(); } diff --git a/hibernate-core/src/test/java/org/hibernate/test/criteria/ComplexJoinAliasTest.java b/hibernate-core/src/test/java/org/hibernate/test/criteria/ComplexJoinAliasTest.java index d8c5d904c4..554ed41e7d 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/criteria/ComplexJoinAliasTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/criteria/ComplexJoinAliasTest.java @@ -31,7 +31,6 @@ import org.junit.Test; import org.hibernate.Criteria; import org.hibernate.Session; import org.hibernate.criterion.Restrictions; -import org.hibernate.testing.FailureExpectedWithNewMetamodel; import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; import static org.junit.Assert.assertEquals; @@ -94,7 +93,6 @@ import static org.junit.Assert.assertEquals; * @author Chris Wilson * @link https://hibernate.onjira.com/browse/HHH-4630 */ -@FailureExpectedWithNewMetamodel public class ComplexJoinAliasTest extends BaseCoreFunctionalTestCase { @Override diff --git a/hibernate-core/src/test/java/org/hibernate/test/fetchprofiles/join/selfReferencing/JoinSelfReferentialFetchProfileTest.java b/hibernate-core/src/test/java/org/hibernate/test/fetchprofiles/join/selfReferencing/JoinSelfReferentialFetchProfileTest.java index e1b94b36f7..2cd272d41f 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/fetchprofiles/join/selfReferencing/JoinSelfReferentialFetchProfileTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/fetchprofiles/join/selfReferencing/JoinSelfReferentialFetchProfileTest.java @@ -28,13 +28,11 @@ import org.hibernate.criterion.Restrictions; import org.junit.Test; -import org.hibernate.testing.FailureExpectedWithNewMetamodel; import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; /** * @author Steve Ebersole */ -@FailureExpectedWithNewMetamodel // NPE @ Binder.bindManyToOneAttribute(Binder.java:1053) public class JoinSelfReferentialFetchProfileTest extends BaseCoreFunctionalTestCase { @Override protected Class[] getAnnotatedClasses() { diff --git a/hibernate-core/src/test/java/org/hibernate/test/ondemandload/LazyLoadingTest.java b/hibernate-core/src/test/java/org/hibernate/test/ondemandload/LazyLoadingTest.java index 2511fb8e27..e56403cafd 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/ondemandload/LazyLoadingTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/ondemandload/LazyLoadingTest.java @@ -32,7 +32,6 @@ import org.hibernate.Hibernate; import org.hibernate.Session; import org.hibernate.cfg.Configuration; import org.hibernate.cfg.Environment; -import org.hibernate.testing.FailureExpectedWithNewMetamodel; import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; import static org.junit.Assert.assertEquals; @@ -40,7 +39,6 @@ import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; -@FailureExpectedWithNewMetamodel public class LazyLoadingTest extends BaseCoreFunctionalTestCase { @Before