HHH-7615: Changed ToOneAttributeSourceImpl.getJoinColumns to call JoinColumnResolutionContext.resolveRelationalValuesForAttribute when attributeName is null (indicating to use the primary key of the referenced table), and likewise modified resolveRelationalValuesForAttribute methods in each JoineColumnResolutionContext impl within Binder extract the PK columns when the attribute name is null
This commit is contained in:
parent
dcc4ab49e7
commit
f48503891b
|
@ -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() ) {
|
||||
|
|
|
@ -149,6 +149,9 @@ public class ToOneAttributeSourceImpl extends SingularAttributeSourceImpl implem
|
|||
public List<Value> getJoinColumns(JoinColumnResolutionContext context) {
|
||||
final List<Value> values = new ArrayList<Value>();
|
||||
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,
|
||||
|
|
|
@ -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 );
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue