From aea84e3fdc54a8b1b1429a411e711e76381fc3f7 Mon Sep 17 00:00:00 2001 From: Sanne Grinovero Date: Wed, 9 Aug 2023 16:02:48 +0200 Subject: [PATCH] HHH-17061 Remove deprecated method PersistentClass#getJoinIterator --- .../org/hibernate/mapping/PersistentClass.java | 5 ----- .../index/jpa/AbstractJPAIndexTest.java | 2 +- .../annotations/onetoone/OneToOneTest.java | 3 +-- .../metadata/AuditMetadataGenerator.java | 4 ++-- .../integration/secondary/BasicSecondary.java | 7 +++---- .../integration/secondary/NamingSecondary.java | 15 ++++++--------- .../secondary/ids/EmbIdSecondary.java | 12 +++++------- .../secondary/ids/MulIdSecondary.java | 18 ++++++++---------- 8 files changed, 26 insertions(+), 40 deletions(-) diff --git a/hibernate-core/src/main/java/org/hibernate/mapping/PersistentClass.java b/hibernate-core/src/main/java/org/hibernate/mapping/PersistentClass.java index 56bd1598f5..57267701cb 100644 --- a/hibernate-core/src/main/java/org/hibernate/mapping/PersistentClass.java +++ b/hibernate-core/src/main/java/org/hibernate/mapping/PersistentClass.java @@ -720,11 +720,6 @@ public abstract class PersistentClass implements IdentifiableTypeClass, Attribut return joins; } - @Deprecated(since = "6.0") - public Iterator getJoinIterator() { - return joins.iterator(); - } - public void addJoin(Join join) { if ( !joins.contains(join) ) { joins.add( join ); diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/index/jpa/AbstractJPAIndexTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/index/jpa/AbstractJPAIndexTest.java index fe669cf9d0..214ce40dc2 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/index/jpa/AbstractJPAIndexTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/index/jpa/AbstractJPAIndexTest.java @@ -79,7 +79,7 @@ public abstract class AbstractJPAIndexTest extends BaseNonConfigCoreFunctionalTe public void testSecondaryTableIndex(){ PersistentClass entity = metadata().getEntityBinding( Car.class.getName() ); - Join join = (Join)entity.getJoinIterator().next(); + Join join = entity.getJoins().get( 0 ); Iterator itr = join.getTable().getIndexes().values().iterator(); assertTrue( itr.hasNext() ); Index index = itr.next(); diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/onetoone/OneToOneTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/onetoone/OneToOneTest.java index 2ba1fcb191..8770821100 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/onetoone/OneToOneTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/onetoone/OneToOneTest.java @@ -308,8 +308,7 @@ public class OneToOneTest extends BaseNonConfigCoreFunctionalTestCase { @TestForIssue( jiraKey = "HHH-4606" ) public void testJoinColumnConfiguredInXml() { PersistentClass pc = metadata().getEntityBinding( Son.class.getName() ); - Iterator iter = pc.getJoinIterator(); - Table table = iter.next().getTable(); + Table table = pc.getJoins().get( 0 ).getTable(); Iterator columnIter = table.getColumns().iterator(); boolean fooFound = false; boolean barFound = false; diff --git a/hibernate-envers/src/main/java/org/hibernate/envers/configuration/internal/metadata/AuditMetadataGenerator.java b/hibernate-envers/src/main/java/org/hibernate/envers/configuration/internal/metadata/AuditMetadataGenerator.java index f093c73a40..95e4d2fd07 100644 --- a/hibernate-envers/src/main/java/org/hibernate/envers/configuration/internal/metadata/AuditMetadataGenerator.java +++ b/hibernate-envers/src/main/java/org/hibernate/envers/configuration/internal/metadata/AuditMetadataGenerator.java @@ -144,7 +144,7 @@ public final class AuditMetadataGenerator extends AbstractMetadataGenerator { } private void createJoins(PersistentClass persistentClass, JoinAwarePersistentEntity entity, ClassAuditingData auditingData) { - final Iterator joins = persistentClass.getJoinIterator(); + final Iterator joins = persistentClass.getJoins().iterator(); final Map joinElements = new HashMap<>(); entityJoins.put( persistentClass.getEntityName(), joinElements ); @@ -196,7 +196,7 @@ public final class AuditMetadataGenerator extends AbstractMetadataGenerator { String entityName, EntityMappingData mappingData, boolean firstPass) { - final Iterator joins = persistentClass.getJoinIterator(); + final Iterator joins = persistentClass.getJoins().iterator(); while ( joins.hasNext() ) { final org.hibernate.mapping.Join join = joins.next(); diff --git a/hibernate-envers/src/test/java/org/hibernate/orm/test/envers/integration/secondary/BasicSecondary.java b/hibernate-envers/src/test/java/org/hibernate/orm/test/envers/integration/secondary/BasicSecondary.java index 50b7fbf3e2..2950f7155a 100644 --- a/hibernate-envers/src/test/java/org/hibernate/orm/test/envers/integration/secondary/BasicSecondary.java +++ b/hibernate-envers/src/test/java/org/hibernate/orm/test/envers/integration/secondary/BasicSecondary.java @@ -14,6 +14,7 @@ import org.hibernate.orm.test.envers.BaseEnversJPAFunctionalTestCase; import org.hibernate.orm.test.envers.Priority; import org.hibernate.mapping.Join; +import org.junit.Assert; import org.junit.Test; /** @@ -71,13 +72,11 @@ public class BasicSecondary extends BaseEnversJPAFunctionalTestCase { @SuppressWarnings("unchecked") @Test public void testTableNames() { - assert "secondary_AUD".equals( - ((Iterator) + Assert.assertEquals("secondary_AUD", metadata().getEntityBinding( "org.hibernate.orm.test.envers.integration.secondary.SecondaryTestEntity_AUD" ) - .getJoinIterator()) - .next().getTable().getName() + .getJoins().get( 0 ).getTable().getName() ); } } diff --git a/hibernate-envers/src/test/java/org/hibernate/orm/test/envers/integration/secondary/NamingSecondary.java b/hibernate-envers/src/test/java/org/hibernate/orm/test/envers/integration/secondary/NamingSecondary.java index b93e141992..fceafb5d84 100644 --- a/hibernate-envers/src/test/java/org/hibernate/orm/test/envers/integration/secondary/NamingSecondary.java +++ b/hibernate-envers/src/test/java/org/hibernate/orm/test/envers/integration/secondary/NamingSecondary.java @@ -7,13 +7,12 @@ package org.hibernate.orm.test.envers.integration.secondary; import java.util.Arrays; -import java.util.Iterator; import jakarta.persistence.EntityManager; import org.hibernate.orm.test.envers.BaseEnversJPAFunctionalTestCase; import org.hibernate.orm.test.envers.Priority; -import org.hibernate.mapping.Join; +import org.junit.Assert; import org.junit.Test; /** @@ -71,13 +70,11 @@ public class NamingSecondary extends BaseEnversJPAFunctionalTestCase { @SuppressWarnings("unchecked") @Test public void testTableNames() { - assert "sec_versions".equals( - ((Iterator) - metadata().getEntityBinding( - "org.hibernate.orm.test.envers.integration.secondary.SecondaryNamingTestEntity_AUD" - ) - .getJoinIterator()) - .next().getTable().getName() + Assert.assertEquals( "sec_versions", + metadata().getEntityBinding( + "org.hibernate.orm.test.envers.integration.secondary.SecondaryNamingTestEntity_AUD" + ) + .getJoins().get( 0 ).getTable().getName() ); } } diff --git a/hibernate-envers/src/test/java/org/hibernate/orm/test/envers/integration/secondary/ids/EmbIdSecondary.java b/hibernate-envers/src/test/java/org/hibernate/orm/test/envers/integration/secondary/ids/EmbIdSecondary.java index bf938ae536..10cc1ec02a 100644 --- a/hibernate-envers/src/test/java/org/hibernate/orm/test/envers/integration/secondary/ids/EmbIdSecondary.java +++ b/hibernate-envers/src/test/java/org/hibernate/orm/test/envers/integration/secondary/ids/EmbIdSecondary.java @@ -7,14 +7,13 @@ package org.hibernate.orm.test.envers.integration.secondary.ids; import java.util.Arrays; -import java.util.Iterator; import jakarta.persistence.EntityManager; import org.hibernate.orm.test.envers.BaseEnversJPAFunctionalTestCase; import org.hibernate.orm.test.envers.Priority; import org.hibernate.orm.test.envers.entities.ids.EmbId; -import org.hibernate.mapping.Join; +import org.junit.Assert; import org.junit.Test; /** @@ -70,11 +69,10 @@ public class EmbIdSecondary extends BaseEnversJPAFunctionalTestCase { @SuppressWarnings("unchecked") @Test public void testTableNames() { - assert "sec_embid_versions".equals( - ((Iterator) - metadata().getEntityBinding( - "org.hibernate.orm.test.envers.integration.secondary.ids.SecondaryEmbIdTestEntity_AUD" - ).getJoinIterator()).next().getTable().getName() + Assert.assertEquals( "sec_embid_versions", + metadata().getEntityBinding( + "org.hibernate.orm.test.envers.integration.secondary.ids.SecondaryEmbIdTestEntity_AUD" + ).getJoins().get( 0 ).getTable().getName() ); } } diff --git a/hibernate-envers/src/test/java/org/hibernate/orm/test/envers/integration/secondary/ids/MulIdSecondary.java b/hibernate-envers/src/test/java/org/hibernate/orm/test/envers/integration/secondary/ids/MulIdSecondary.java index f947ab1882..c5935075ee 100644 --- a/hibernate-envers/src/test/java/org/hibernate/orm/test/envers/integration/secondary/ids/MulIdSecondary.java +++ b/hibernate-envers/src/test/java/org/hibernate/orm/test/envers/integration/secondary/ids/MulIdSecondary.java @@ -7,14 +7,14 @@ package org.hibernate.orm.test.envers.integration.secondary.ids; import java.util.Arrays; -import java.util.Iterator; + import jakarta.persistence.EntityManager; import org.hibernate.orm.test.envers.BaseEnversJPAFunctionalTestCase; import org.hibernate.orm.test.envers.Priority; import org.hibernate.orm.test.envers.entities.ids.MulId; -import org.hibernate.mapping.Join; +import org.junit.Assert; import org.junit.Test; /** @@ -25,7 +25,7 @@ public class MulIdSecondary extends BaseEnversJPAFunctionalTestCase { @Override protected Class[] getAnnotatedClasses() { - return new Class[] {SecondaryMulIdTestEntity.class}; + return new Class[] { SecondaryMulIdTestEntity.class }; } @Test @@ -70,13 +70,11 @@ public class MulIdSecondary extends BaseEnversJPAFunctionalTestCase { @SuppressWarnings("unchecked") @Test public void testTableNames() { - assert "sec_mulid_versions".equals( - ((Iterator) - metadata().getEntityBinding( - "org.hibernate.orm.test.envers.integration.secondary.ids.SecondaryMulIdTestEntity_AUD" - ) - .getJoinIterator()) - .next().getTable().getName() + Assert.assertEquals( + "sec_mulid_versions", + metadata().getEntityBinding( + "org.hibernate.orm.test.envers.integration.secondary.ids.SecondaryMulIdTestEntity_AUD" + ).getJoins().get( 0 ).getTable().getName() ); } }