Skip to content

Commit a448e26

Browse files
committed
HHH-8184 association attributes from mapped super class are not included
1 parent f29a670 commit a448e26

File tree

6 files changed

+34
-23
lines changed

6 files changed

+34
-23
lines changed

hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/annotations/entity/RootEntityClass.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,9 @@
3838
import org.hibernate.MappingException;
3939
import org.hibernate.internal.CoreMessageLogger;
4040
import org.hibernate.internal.util.collections.CollectionHelper;
41+
import org.hibernate.internal.util.collections.JoinedIterable;
4142
import org.hibernate.metamodel.internal.source.annotations.AnnotationBindingContext;
43+
import org.hibernate.metamodel.internal.source.annotations.attribute.AssociationAttribute;
4244
import org.hibernate.metamodel.internal.source.annotations.attribute.BasicAttribute;
4345
import org.hibernate.metamodel.internal.source.annotations.attribute.Column;
4446
import org.hibernate.metamodel.internal.source.annotations.attribute.FormulaValue;
@@ -168,6 +170,19 @@ public Collection<BasicAttribute> getSimpleAttributes() {
168170
return attributes;
169171
}
170172

173+
@Override
174+
public Iterable<AssociationAttribute> getAssociationAttributes() {
175+
List<Iterable<AssociationAttribute>> list = new ArrayList<Iterable<AssociationAttribute>>( );
176+
list.add( super.getAssociationAttributes() );
177+
178+
// now the attributes of the mapped superclasses
179+
for ( MappedSuperclass mappedSuperclass : mappedSuperclasses ) {
180+
list.add( mappedSuperclass.getAssociationAttributes() );
181+
}
182+
183+
return new JoinedIterable<AssociationAttribute>( list );
184+
}
185+
171186
public Collection<MappedAttribute> getIdAttributes() {
172187
List<MappedAttribute> attributes = new ArrayList<MappedAttribute>();
173188

hibernate-core/src/test/java/org/hibernate/test/annotations/generics/GenericsTest.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,11 @@
2929
import org.hibernate.Transaction;
3030
import org.hibernate.cfg.Configuration;
3131
import org.hibernate.cfg.Environment;
32-
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
3332
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
3433

3534
/**
3635
* @author Emmanuel Bernard
3736
*/
38-
@FailureExpectedWithNewMetamodel
3937
public class GenericsTest extends BaseCoreFunctionalTestCase {
4038
@Test
4139
public void testManyToOneGenerics() throws Exception {

hibernate-core/src/test/java/org/hibernate/test/annotations/uniqueconstraint/UniqueConstraintTest.java

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
import org.hibernate.JDBCException;
1313
import org.hibernate.Session;
1414
import org.hibernate.Transaction;
15-
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
15+
import org.hibernate.metamodel.spi.relational.Database;
16+
import org.hibernate.metamodel.spi.relational.Schema;
1617
import org.hibernate.testing.TestForIssue;
1718
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
1819

@@ -22,7 +23,6 @@
2223
/**
2324
* @author Manuel Bernhardt <bernhardt.manuel@gmail.com>
2425
*/
25-
@FailureExpectedWithNewMetamodel
2626
public class UniqueConstraintTest extends BaseCoreFunctionalTestCase {
2727

2828
@Override
@@ -70,25 +70,26 @@ public void testUniquenessConstraintWithSuperclassProperty() throws Exception {
7070
@Test
7171
@TestForIssue( jiraKey = "HHH-8026" )
7272
public void testUnNamedConstraints() {
73-
Iterator<org.hibernate.mapping.Table> iterator = configuration().getTableMappings();
74-
org.hibernate.mapping.Table tableA = null;
75-
org.hibernate.mapping.Table tableB = null;
76-
while( iterator.hasNext() ) {
77-
org.hibernate.mapping.Table table = iterator.next();
78-
if ( table.getName().equals( "UniqueNoNameA" ) ) {
79-
tableA = table;
80-
}
81-
else if ( table.getName().equals( "UniqueNoNameB" ) ) {
82-
tableB = table;
73+
Database database = metadata().getDatabase();
74+
org.hibernate.metamodel.spi.relational.Table tableA = null;
75+
org.hibernate.metamodel.spi.relational.Table tableB = null;
76+
for(final Schema schema : database.getSchemas()){
77+
for(final org.hibernate.metamodel.spi.relational.Table table : schema.getTables()){
78+
if ( table.getPhysicalName().getText().equals( "UniqueNoNameA" ) ) {
79+
tableA = table;
80+
}
81+
else if ( table.getPhysicalName().getText().equals( "UniqueNoNameB" ) ) {
82+
tableB = table;
83+
}
84+
8385
}
8486
}
85-
8687
if ( tableA == null || tableB == null ) {
8788
fail( "Could not find the expected tables." );
8889
}
89-
90-
assertFalse( tableA.getUniqueKeyIterator().next().getName().equals(
91-
tableB.getUniqueKeyIterator().next().getName() ) );
90+
91+
assertFalse( tableA.getUniqueKeys().iterator().next().getName().equals(
92+
tableB.getUniqueKeys().iterator().next().getName() ) );
9293
}
9394

9495
@Entity

hibernate-entitymanager/src/test/java/org/hibernate/jpa/test/criteria/basic/CastTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
4242
import org.hibernate.testing.TestForIssue;
4343

44-
@FailureExpectedWithNewMetamodel
44+
@FailureExpectedWithNewMetamodel(message = "@OneToOne with mappedBy specified is not supported yet")
4545
public class CastTest extends AbstractMetamodelSpecificTest {
4646
private static final int QUANTITY = 2;
4747

hibernate-entitymanager/src/test/java/org/hibernate/jpa/test/criteria/basic/ExpressionsTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
*
5858
* @author Steve Ebersole
5959
*/
60-
@FailureExpectedWithNewMetamodel
60+
@FailureExpectedWithNewMetamodel(message = "@OneToOne with mappedBy specified is not supported yet")
6161
public class ExpressionsTest extends AbstractMetamodelSpecificTest {
6262
private CriteriaBuilder builder;
6363

hibernate-entitymanager/src/test/java/org/hibernate/jpa/test/util/IsLoadedTest.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@
2828
import org.junit.Test;
2929

3030
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;
31-
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
32-
3331
import static org.junit.Assert.assertFalse;
3432
import static org.junit.Assert.assertTrue;
3533

@@ -38,7 +36,6 @@
3836
*/
3937
public class IsLoadedTest extends BaseEntityManagerFunctionalTestCase {
4038
@Test
41-
@FailureExpectedWithNewMetamodel
4239
public void testIsLoadedOnPrivateSuperclassProperty() {
4340
EntityManager em = entityManagerFactory().createEntityManager();
4441
em.getTransaction().begin();

0 commit comments

Comments
 (0)