HHH-9055 - Binding support for IdClass and MapsId needs a complete review

This commit is contained in:
Steve Ebersole 2014-04-24 21:30:12 -05:00
parent f88b53cf9e
commit 9514c56c6d
2 changed files with 20 additions and 13 deletions

View File

@ -67,6 +67,7 @@ import org.hibernate.metamodel.internal.binder.HibernateTypeHelper.ReflectedColl
import org.hibernate.metamodel.internal.resolver.AssociationRelationalBindingResolver; import org.hibernate.metamodel.internal.resolver.AssociationRelationalBindingResolver;
import org.hibernate.metamodel.internal.resolver.MappedByAssociationRelationalBindingResolverImpl; import org.hibernate.metamodel.internal.resolver.MappedByAssociationRelationalBindingResolverImpl;
import org.hibernate.metamodel.internal.resolver.StandardAssociationRelationalBindingResolverImpl; import org.hibernate.metamodel.internal.resolver.StandardAssociationRelationalBindingResolverImpl;
import org.hibernate.metamodel.reflite.internal.DynamicTypeDescriptorImpl;
import org.hibernate.metamodel.reflite.internal.Primitives; import org.hibernate.metamodel.reflite.internal.Primitives;
import org.hibernate.metamodel.reflite.spi.ClassDescriptor; import org.hibernate.metamodel.reflite.spi.ClassDescriptor;
import org.hibernate.metamodel.reflite.spi.FieldDescriptor; import org.hibernate.metamodel.reflite.spi.FieldDescriptor;
@ -3488,14 +3489,23 @@ public class Binder {
} }
// Resolve the domain definition of the PK class // Resolve the domain definition of the PK class
final Aggregate pkClass;
if ( source.getEntityMode() == EntityMode.MAP ) {
pkClass = (Aggregate) localBindingContext().locateOrBuildDomainType(
new DynamicTypeDescriptorImpl( DotName.createSimple( "CID" ), null ),
true
);
}
else {
final JavaTypeDescriptor pkClassTypeDescriptor = determinePkClassTypeDescriptor( final JavaTypeDescriptor pkClassTypeDescriptor = determinePkClassTypeDescriptor(
binding.getRootEntityBinding(), binding.getRootEntityBinding(),
identifierSource identifierSource
); );
final Aggregate pkClass = (Aggregate) localBindingContext().locateOrBuildDomainType( pkClass = (Aggregate) localBindingContext().locateOrBuildDomainType(
pkClassTypeDescriptor, pkClassTypeDescriptor,
true true
); );
}
// `pkAttribute` is the (domain) attribute reference for the @EmbeddedId attribute // `pkAttribute` is the (domain) attribute reference for the @EmbeddedId attribute

View File

@ -1,22 +1,19 @@
package org.hibernate.envers.test.integration.ids.embeddedid; package org.hibernate.envers.test.integration.ids.embeddedid;
import javax.persistence.EntityManager;
import java.util.Arrays; import java.util.Arrays;
import javax.persistence.EntityManager;
import org.hibernate.envers.test.BaseEnversJPAFunctionalTestCase; import org.hibernate.envers.test.BaseEnversJPAFunctionalTestCase;
import org.hibernate.envers.test.Priority; import org.hibernate.envers.test.Priority;
import org.hibernate.testing.TestForIssue;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Test; import org.junit.Test;
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
import org.hibernate.testing.TestForIssue;
/** /**
* @author Lukasz Antoniak (lukasz dot antoniak at gmail dot com) * @author Lukasz Antoniak (lukasz dot antoniak at gmail dot com)
*/ */
@TestForIssue(jiraKey = "HHH-7690") @TestForIssue(jiraKey = "HHH-7690")
@FailureExpectedWithNewMetamodel( message = "Associations with non-envers entities not supported yet." )
public class RelationInsideEmbeddableTest extends BaseEnversJPAFunctionalTestCase { public class RelationInsideEmbeddableTest extends BaseEnversJPAFunctionalTestCase {
private Integer orderId = null; private Integer orderId = null;
private ItemId itemId = null; private ItemId itemId = null;