HHH-17061 Remove PersistentClass#getPropertyIterator

This commit is contained in:
Sanne Grinovero 2023-08-09 15:50:58 +02:00 committed by Sanne Grinovero
parent 0a5d9f293d
commit 5754cd608c
6 changed files with 13 additions and 43 deletions

View File

@ -29,7 +29,6 @@ import org.hibernate.dialect.Dialect;
import org.hibernate.engine.OptimisticLockStyle;
import org.hibernate.engine.spi.ExecuteUpdateResultCheckStyle;
import org.hibernate.internal.FilterConfiguration;
import org.hibernate.internal.util.collections.JoinedIterator;
import org.hibernate.internal.util.collections.JoinedList;
import org.hibernate.metamodel.spi.RuntimeModelCreationContext;
import org.hibernate.persister.entity.EntityPersister;
@ -756,30 +755,6 @@ public abstract class PersistentClass implements IdentifiableTypeClass, Attribut
return 0;
}
/**
* Build an iterator over the properties defined on this class. The returned
* iterator only accounts for "normal" properties (i.e. non-identifier
* properties).
* <p>
* Differs from {@link #getUnjoinedProperties()} (followed by iterator()) in that the returned iterator
* will include properties defined as part of a join.
* <p>
* The properties defined in superclasses of the mapping inheritance are not included.
*
* @return An iterator over the "normal" properties.
*
* @deprecated use {@link #getProperties()}
*/
@Deprecated(since = "6.0")
public Iterator<Property> getPropertyIterator() {
final ArrayList<Iterator<Property>> iterators = new ArrayList<>();
iterators.add( properties.iterator() );
for ( Join join : joins ) {
iterators.add( join.getPropertyIterator() );
}
return new JoinedIterator<>( iterators );
}
/**
* Build a list of the properties defined on this class. The returned
* iterator only accounts for "normal" properties (i.e. non-identifier
@ -1076,9 +1051,9 @@ public abstract class PersistentClass implements IdentifiableTypeClass, Attribut
}
private boolean determineIfNaturalIdDefined() {
final Iterator<Property> props = getRootClass().getPropertyIterator();
while ( props.hasNext() ) {
if ( props.next().isNaturalIdentifier() ) {
final List<Property> props = getRootClass().getProperties();
for ( Property p : props ) {
if ( p.isNaturalIdentifier() ) {
return true;
}
}

View File

@ -49,7 +49,7 @@ public class SimpleEntityTypeResolutionsTests {
assertThat( resolution.getJdbcMapping(), sameInstance( resolution.getLegacyResolvedBasicType() ) );
}
final Iterator<Property> itr = simpleEntityBinding.getPropertyIterator();
final Iterator<Property> itr = simpleEntityBinding.getProperties().iterator();
while ( itr.hasNext() ) {
final Property property = itr.next();
final BasicValue propertyValue = (BasicValue) property.getValue();

View File

@ -75,7 +75,7 @@ public class NonReflectiveBinderTest {
/*Property property = cm.getIdentifierProperty();
property.getMetaAttribute(null);*/
Iterator<Property> propertyIterator = cm.getPropertyIterator();
Iterator<Property> propertyIterator = cm.getProperties().iterator();
while ( propertyIterator.hasNext() ) {
Property element = propertyIterator.next();
Map ma = element.getMetaAttributes();

View File

@ -105,10 +105,8 @@ public class CollectionMappedByResolver {
}
private static String searchMappedBy(PersistentClass referencedClass, Collection collectionValue) {
final Iterator<Property> assocClassProps = referencedClass.getPropertyIterator();
while ( assocClassProps.hasNext() ) {
final Property property = assocClassProps.next();
final List<Property> assocClassProps = referencedClass.getProperties();
for ( Property property : assocClassProps ) {
final List<Selectable> assocClassSelectables = property.getValue().getSelectables();
final List<Selectable> collectionKeySelectables = collectionValue.getKey().getSelectables();
if ( Objects.equals( assocClassSelectables, collectionKeySelectables ) ) {

View File

@ -7,7 +7,6 @@
package org.hibernate.orm.test.envers.integration.properties;
import java.util.Arrays;
import java.util.Iterator;
import java.util.Map;
import jakarta.persistence.EntityManager;
@ -17,6 +16,7 @@ import org.hibernate.orm.test.envers.Priority;
import org.hibernate.mapping.PersistentClass;
import org.hibernate.mapping.Property;
import org.junit.Assert;
import org.junit.Test;
/**
@ -76,10 +76,8 @@ public class UnversionedOptimisticLockingField extends BaseEnversJPAFunctionalTe
@Test
public void testMapping() {
PersistentClass pc = metadata().getEntityBinding( UnversionedOptimisticLockingFieldEntity.class.getName() + "_AUD" );
Iterator pi = pc.getPropertyIterator();
while ( pi.hasNext() ) {
Property p = (Property) pi.next();
assert !"optLocking".equals( p.getName() );
for ( Property p : pc.getProperties() ) {
Assert.assertNotEquals( "optLocking", p.getName() );
}
}
}

View File

@ -74,10 +74,9 @@ public class TestTools {
}
public static Set<String> extractModProperties(PersistentClass persistentClass, String suffix) {
final Set<String> result = new HashSet<String>();
final Iterator iterator = persistentClass.getPropertyIterator();
while ( iterator.hasNext() ) {
final Property property = (Property) iterator.next();
final Set<String> result = new HashSet<>();
final List<Property> props = persistentClass.getProperties();
for ( Property property : props ) {
final String propertyName = property.getName();
if ( propertyName.endsWith( suffix ) ) {
result.add( propertyName );