From 29916adccb43a08ed3114a5eba9ee30fa46fe33e Mon Sep 17 00:00:00 2001 From: Gail Badner Date: Fri, 11 Jan 2013 11:03:02 -0800 Subject: [PATCH] HHH-7919 : Miscellaneous embeddable bugfixes --- .../java/org/hibernate/metamodel/internal/Binder.java | 9 ++++++++- .../CompositePluralAttributeElementSourceImpl.java | 2 +- .../metamodel/spi/binding/CompositeAttributeBinding.java | 9 ++++++++- .../test/annotations/embedded/EmbeddedTest.java | 5 ++++- .../test/annotations/embedded/RegionalArticle.java | 3 ++- .../test/component/basic2/ComponentJoinsTest.java | 1 - 6 files changed, 23 insertions(+), 6 deletions(-) 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 c04f54cf4d..5fe058ff18 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 @@ -1658,7 +1658,14 @@ public class Binder { */ for ( AttributeBinding ab : compositeAttributeBindingContainer.attributeBindings() ) { if ( ab.isCascadeable() ) { - CascadeStyle cascadeStyle = Cascadeable.class.cast( ab ).getCascadeStyle(); + final Cascadeable cascadeable; + if ( ab.getAttribute().isSingular() ) { + cascadeable = Cascadeable.class.cast( ab ); + } + else { + cascadeable = Cascadeable.class.cast( ( (PluralAttributeBinding) ab ).getPluralAttributeElementBinding() ); + } + CascadeStyle cascadeStyle = cascadeable.getCascadeStyle(); if ( cascadeStyle != CascadeStyles.NONE ) { elementBinding.setCascadeStyle( CascadeStyles.ALL ); } diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/annotations/CompositePluralAttributeElementSourceImpl.java b/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/annotations/CompositePluralAttributeElementSourceImpl.java index 9be3e0a2c3..7560d39cd3 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/annotations/CompositePluralAttributeElementSourceImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/annotations/CompositePluralAttributeElementSourceImpl.java @@ -146,7 +146,7 @@ public class CompositePluralAttributeElementSourceImpl implements CompositePlura embeddable, getPath(), createAggregatedOverrideMap( embeddableClass, entityClass.getAttributeOverrideMap() ), - embeddable.getClassAccessType() + embeddableClass.getClassAccessType() ) ); } diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/spi/binding/CompositeAttributeBinding.java b/hibernate-core/src/main/java/org/hibernate/metamodel/spi/binding/CompositeAttributeBinding.java index b1a2303ca9..591d7c5f42 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/spi/binding/CompositeAttributeBinding.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/spi/binding/CompositeAttributeBinding.java @@ -236,7 +236,14 @@ public class CompositeAttributeBinding public CascadeStyle getCascadeStyle() { for ( AttributeBinding attributeBinding : attributeBindings() ) { if ( attributeBinding.isCascadeable() ) { - CascadeStyle cascadeStyle = Cascadeable.class.cast( attributeBinding ).getCascadeStyle(); + final Cascadeable cascadeable; + if ( attributeBinding.getAttribute().isSingular() ) { + cascadeable = Cascadeable.class.cast( attributeBinding ); + } + else { + cascadeable = Cascadeable.class.cast( ( (PluralAttributeBinding) attributeBinding ).getPluralAttributeElementBinding() ); + } + CascadeStyle cascadeStyle = cascadeable.getCascadeStyle(); if ( cascadeStyle != CascadeStyles.NONE ) { return CascadeStyles.ALL; } diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/embedded/EmbeddedTest.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/embedded/EmbeddedTest.java index e285ddb784..c7fe054057 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/embedded/EmbeddedTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/embedded/EmbeddedTest.java @@ -46,7 +46,6 @@ import static org.junit.Assert.assertTrue; /** * @author Emmanuel Bernard */ -@FailureExpectedWithNewMetamodel public class EmbeddedTest extends BaseCoreFunctionalTestCase { @Test public void testSimple() throws Exception { @@ -154,6 +153,7 @@ public class EmbeddedTest extends BaseCoreFunctionalTestCase { } @Test + @FailureExpectedWithNewMetamodel public void testEmbeddedSuperclass() { Session s; Transaction tx; @@ -191,6 +191,7 @@ public class EmbeddedTest extends BaseCoreFunctionalTestCase { } @Test + @FailureExpectedWithNewMetamodel public void testDottedProperty() { Session s; Transaction tx; @@ -406,6 +407,7 @@ public class EmbeddedTest extends BaseCoreFunctionalTestCase { } @Test + @FailureExpectedWithNewMetamodel public void testDefaultCollectionTable() throws Exception { //are the tables correct? assertTrue( SchemaUtil.isTablePresent("WealthyPerson_vacationHomes", metadata() ) ); @@ -457,6 +459,7 @@ public class EmbeddedTest extends BaseCoreFunctionalTestCase { // make sure we support collection of embeddable objects inside embeddable objects @Test + @FailureExpectedWithNewMetamodel public void testEmbeddableInsideEmbeddable() throws Exception { Session s; Transaction tx; diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/embedded/RegionalArticle.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/embedded/RegionalArticle.java index e069286786..132e7d0678 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/embedded/RegionalArticle.java +++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/embedded/RegionalArticle.java @@ -1,6 +1,7 @@ //$Id$ package org.hibernate.test.annotations.embedded; import java.io.Serializable; +import javax.persistence.EmbeddedId; import javax.persistence.Entity; import javax.persistence.Id; @@ -15,7 +16,7 @@ public class RegionalArticle implements Serializable { private RegionalArticlePk pk; private String name; - @Id + @EmbeddedId public RegionalArticlePk getPk() { return pk; } diff --git a/hibernate-core/src/test/java/org/hibernate/test/component/basic2/ComponentJoinsTest.java b/hibernate-core/src/test/java/org/hibernate/test/component/basic2/ComponentJoinsTest.java index 481b8c3adc..d1bd7fcc4a 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/component/basic2/ComponentJoinsTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/component/basic2/ComponentJoinsTest.java @@ -34,7 +34,6 @@ import org.junit.Test; * * @author Steve Ebersole */ -@FailureExpectedWithNewMetamodel public class ComponentJoinsTest extends BaseCoreFunctionalTestCase { @Override public Class[] getAnnotatedClasses() {