diff --git a/hibernate-core/src/main/java/org/hibernate/boot/spi/MetadataImplementor.java b/hibernate-core/src/main/java/org/hibernate/boot/spi/MetadataImplementor.java
index f9ffd397ff..e5f69230c1 100644
--- a/hibernate-core/src/main/java/org/hibernate/boot/spi/MetadataImplementor.java
+++ b/hibernate-core/src/main/java/org/hibernate/boot/spi/MetadataImplementor.java
@@ -25,7 +25,7 @@ import org.hibernate.type.spi.TypeConfiguration;
*
* @since 5.0
*/
-public interface MetadataImplementor extends Metadata, Mapping {
+public interface MetadataImplementor extends Metadata {
/**
* Access to the options used to build this Metadata
*
diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/ClassPropertyHolder.java b/hibernate-core/src/main/java/org/hibernate/cfg/ClassPropertyHolder.java
index 89126108db..d54ce831d8 100644
--- a/hibernate-core/src/main/java/org/hibernate/cfg/ClassPropertyHolder.java
+++ b/hibernate-core/src/main/java/org/hibernate/cfg/ClassPropertyHolder.java
@@ -225,7 +225,7 @@ public class ClassPropertyHolder extends AbstractPropertyHolder {
);
}
if ( inheritanceState.isEmbeddableSuperclass() ) {
- persistentClass.addMappedsuperclassProperty(prop);
+ persistentClass.addMappedSuperclassProperty( prop );
addPropertyToMappedSuperclass( prop, declaringClass );
}
else {
diff --git a/hibernate-core/src/main/java/org/hibernate/internal/util/collections/ArrayHelper.java b/hibernate-core/src/main/java/org/hibernate/internal/util/collections/ArrayHelper.java
index 5ecf262a99..392348a310 100644
--- a/hibernate-core/src/main/java/org/hibernate/internal/util/collections/ArrayHelper.java
+++ b/hibernate-core/src/main/java/org/hibernate/internal/util/collections/ArrayHelper.java
@@ -18,7 +18,6 @@ import java.util.function.Consumer;
import org.hibernate.HibernateException;
import org.hibernate.LockMode;
import org.hibernate.LockOptions;
-import org.hibernate.internal.build.AllowSysOut;
import org.hibernate.type.Type;
public final class ArrayHelper {
@@ -268,36 +267,36 @@ public final class ArrayHelper {
public static final Type[] EMPTY_TYPE_ARRAY = {};
public static final byte[] EMPTY_BYTE_ARRAY = {};
- public static int[] getBatchSizes(int maxBatchSize) {
- int batchSize = maxBatchSize;
- int n = 1;
- while ( batchSize > 1 ) {
- batchSize = getNextBatchSize( batchSize );
- n++;
- }
- int[] result = new int[n];
- batchSize = maxBatchSize;
- for ( int i = 0; i < n; i++ ) {
- result[i] = batchSize;
- batchSize = getNextBatchSize( batchSize );
- }
- return result;
- }
+// public static int[] getBatchSizes(int maxBatchSize) {
+// int batchSize = maxBatchSize;
+// int n = 1;
+// while ( batchSize > 1 ) {
+// batchSize = getNextBatchSize( batchSize );
+// n++;
+// }
+// int[] result = new int[n];
+// batchSize = maxBatchSize;
+// for ( int i = 0; i < n; i++ ) {
+// result[i] = batchSize;
+// batchSize = getNextBatchSize( batchSize );
+// }
+// return result;
+// }
+//
+// private static int getNextBatchSize(int batchSize) {
+// if ( batchSize <= 10 ) {
+// return batchSize - 1; //allow 9,8,7,6,5,4,3,2,1
+// }
+// else if ( batchSize / 2 < 10 ) {
+// return 10;
+// }
+// else {
+// return batchSize / 2;
+// }
+// }
- private static int getNextBatchSize(int batchSize) {
- if ( batchSize <= 10 ) {
- return batchSize - 1; //allow 9,8,7,6,5,4,3,2,1
- }
- else if ( batchSize / 2 < 10 ) {
- return 10;
- }
- else {
- return batchSize / 2;
- }
- }
-
- private static int SEED = 23;
- private static int PRIME_NUMBER = 37;
+ private static final int SEED = 23;
+ private static final int PRIME_NUMBER = 37;
/**
* calculate the array hash (only the first level)
@@ -406,21 +405,6 @@ public final class ArrayHelper {
return Arrays.asList( values );
}
- @AllowSysOut
- public static void main(String... args) {
- int[] batchSizes = ArrayHelper.getBatchSizes( 32 );
-
- System.out.println( "Forward ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" );
- for ( int i = 0; i < batchSizes.length; i++ ) {
- System.out.println( "[" + i + "] -> " + batchSizes[i] );
- }
-
- System.out.println( "Backward ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" );
- for ( int i = batchSizes.length - 1; i >= 0; i-- ) {
- System.out.println( "[" + i + "] -> " + batchSizes[i] );
- }
- }
-
public static boolean isEmpty(Object[] array) {
return array == null || array.length == 0;
}
diff --git a/hibernate-core/src/main/java/org/hibernate/loader/BatchFetchStyle.java b/hibernate-core/src/main/java/org/hibernate/loader/BatchFetchStyle.java
index c4013d4d43..8f6cfdacbc 100644
--- a/hibernate-core/src/main/java/org/hibernate/loader/BatchFetchStyle.java
+++ b/hibernate-core/src/main/java/org/hibernate/loader/BatchFetchStyle.java
@@ -22,7 +22,7 @@ import org.jboss.logging.Logger;
public enum BatchFetchStyle {
/**
* The legacy algorithm where we keep a set of pre-built batch sizes based on
- * {@link org.hibernate.internal.util.collections.ArrayHelper#getBatchSizes}. Batches are performed
+ * {@code org.hibernate.internal.util.collections.ArrayHelper#getBatchSizes}. Batches are performed
* using the next-smaller pre-built batch size from the number of existing batchable identifiers.
*
* For example, with a batch-size setting of 32 the pre-built batch sizes would be [32, 16, 10, 9, 8, 7, .., 1].
diff --git a/hibernate-core/src/main/java/org/hibernate/mapping/Component.java b/hibernate-core/src/main/java/org/hibernate/mapping/Component.java
index 83559eb8b5..6d41829cc6 100644
--- a/hibernate-core/src/main/java/org/hibernate/mapping/Component.java
+++ b/hibernate-core/src/main/java/org/hibernate/mapping/Component.java
@@ -16,6 +16,7 @@ import java.util.Objects;
import java.util.stream.Collectors;
import org.hibernate.MappingException;
+import org.hibernate.Remove;
import org.hibernate.boot.model.relational.Database;
import org.hibernate.boot.model.relational.SqlStringGenerationContext;
import org.hibernate.boot.model.source.internal.hbm.MappingDocument;
@@ -43,26 +44,30 @@ import org.hibernate.type.Type;
* @author Steve Ebersole
*/
public class Component extends SimpleValue implements MetaAttributable, SortableValue {
- private final ArrayList properties = new ArrayList<>();
- private int[] originalPropertyOrder = ArrayHelper.EMPTY_INT_ARRAY;
+
private String componentClassName;
private boolean embedded;
private String parentProperty;
private PersistentClass owner;
private boolean dynamic;
- private Map metaAttributes;
private boolean isKey;
private String roleName;
+ private final ArrayList properties = new ArrayList<>();
+ private int[] originalPropertyOrder = ArrayHelper.EMPTY_INT_ARRAY;
+ private Map metaAttributes;
+
private Class extends EmbeddableInstantiator> customInstantiator;
// cache the status of the type
private volatile Type type;
// lazily computed based on 'properties' field: invalidate by setting to null when properties are modified
- private List cachedSelectables;
+ private transient List cachedSelectables;
// lazily computed based on 'properties' field: invalidate by setting to null when properties are modified
- private List cachedColumns;
+ private transient List cachedColumns;
+
+ private transient IdentifierGenerator builtIdentifierGenerator;
public Component(MetadataBuildingContext metadata, PersistentClass owner) throws MappingException {
this( metadata, owner.getTable(), owner );
@@ -96,7 +101,7 @@ public class Component extends SimpleValue implements MetaAttributable, Sortable
this.parentProperty = original.parentProperty;
this.owner = original.owner;
this.dynamic = original.dynamic;
- this.metaAttributes = original.metaAttributes == null ? null : new HashMap(original.metaAttributes);
+ this.metaAttributes = original.metaAttributes == null ? null : new HashMap<>(original.metaAttributes);
this.isKey = original.isKey;
this.roleName = original.roleName;
this.customInstantiator = original.customInstantiator;
@@ -112,6 +117,7 @@ public class Component extends SimpleValue implements MetaAttributable, Sortable
return properties.size();
}
+ @Deprecated @Remove
public Iterator getPropertyIterator() {
return properties.iterator();
}
@@ -137,14 +143,14 @@ public class Component extends SimpleValue implements MetaAttributable, Sortable
@Override
public int getColumnSpan() {
- int n=0;
+ int span = 0;
for ( Property property : getProperties() ) {
- n += property.getColumnSpan();
+ span += property.getColumnSpan();
}
- return n;
+ return span;
}
- @Override @Deprecated
+ @Override @Deprecated @SuppressWarnings("deprecation")
public Iterator getColumnIterator() {
@SuppressWarnings("unchecked")
Iterator[] iters = new Iterator[ getPropertySpan() ];
@@ -157,15 +163,12 @@ public class Component extends SimpleValue implements MetaAttributable, Sortable
@Override
public List getSelectables() {
- if ( cachedSelectables != null ) {
- return cachedSelectables;
- }
- else {
+ if ( cachedSelectables == null ) {
cachedSelectables = properties.stream()
- .flatMap( p -> p.getSelectables().stream() )
- .collect( Collectors.toList() );
- return cachedSelectables;
+ .flatMap(p -> p.getSelectables().stream())
+ .collect(Collectors.toList());
}
+ return cachedSelectables;
}
@Override
@@ -268,17 +271,17 @@ public class Component extends SimpleValue implements MetaAttributable, Sortable
}
@Override
- public Map getMetaAttributes() {
+ public Map getMetaAttributes() {
return metaAttributes;
}
@Override
public MetaAttribute getMetaAttribute(String attributeName) {
- return metaAttributes==null?null:(MetaAttribute) metaAttributes.get(attributeName);
+ return metaAttributes==null ? null : metaAttributes.get(attributeName);
}
@Override
- public void setMetaAttributes(Map metas) {
+ public void setMetaAttributes(Map metas) {
this.metaAttributes = metas;
}
@@ -303,22 +306,21 @@ public class Component extends SimpleValue implements MetaAttributable, Sortable
@Override
public boolean[] getColumnInsertability() {
- boolean[] result = new boolean[ getColumnSpan() ];
- int i=0;
+ final boolean[] result = new boolean[ getColumnSpan() ];
+ int i = 0;
for ( Property prop : getProperties() ) {
- boolean[] chunk = prop.getValue().getColumnInsertability();
+ final boolean[] chunk = prop.getValue().getColumnInsertability();
if ( prop.isInsertable() ) {
- System.arraycopy(chunk, 0, result, i, chunk.length);
+ System.arraycopy( chunk, 0, result, i, chunk.length );
}
- i+=chunk.length;
+ i += chunk.length;
}
return result;
}
@Override
public boolean hasAnyInsertableColumns() {
- for ( int i = 0; i < properties.size(); i++ ) {
- final Property property = properties.get( i );
+ for ( Property property : properties ) {
if ( property.getValue().hasAnyInsertableColumns() ) {
return true;
}
@@ -343,13 +345,11 @@ public class Component extends SimpleValue implements MetaAttributable, Sortable
@Override
public boolean hasAnyUpdatableColumns() {
- for ( int i = 0; i < properties.size(); i++ ) {
- final Property property = properties.get( i );
+ for ( Property property : properties ) {
if ( property.getValue().hasAnyUpdatableColumns() ) {
return true;
}
}
-
return false;
}
@@ -408,8 +408,6 @@ public class Component extends SimpleValue implements MetaAttributable, Sortable
return getClass().getSimpleName() + '(' + componentClassName + ')';
}
- private IdentifierGenerator builtIdentifierGenerator;
-
@Override
public IdentifierGenerator createIdentifierGenerator(
IdentifierGeneratorFactory identifierGeneratorFactory,
@@ -577,8 +575,9 @@ public class Component extends SimpleValue implements MetaAttributable, Sortable
// to be able to sort the other side of the foreign key accordingly
// and also if the source is a XML mapping
// because XML mappings might refer to this through the defined order
- if ( forceRetainOriginalOrder || isAlternateUniqueKey() || isEmbedded() || getBuildingContext() instanceof MappingDocument ) {
- final Object[] originalProperties = properties.toArray();
+ if ( forceRetainOriginalOrder || isAlternateUniqueKey() || isEmbedded()
+ || getBuildingContext() instanceof MappingDocument ) {
+ final Property[] originalProperties = properties.toArray( new Property[0] );
properties.sort( Comparator.comparing( Property::getName ) );
originalPropertyOrder = new int[originalProperties.length];
for ( int j = 0; j < originalPropertyOrder.length; j++ ) {
@@ -595,8 +594,8 @@ public class Component extends SimpleValue implements MetaAttributable, Sortable
// We have to re-order the primary key accordingly
final List columns = primaryKey.getColumns();
columns.clear();
- for ( int i = 0; i < properties.size(); i++ ) {
- for ( Selectable selectable : properties.get(i).getSelectables() ) {
+ for ( Property property : properties ) {
+ for ( Selectable selectable : property.getSelectables() ) {
if ( selectable instanceof Column ) {
columns.add( (Column) selectable );
}
diff --git a/hibernate-core/src/main/java/org/hibernate/mapping/Constraint.java b/hibernate-core/src/main/java/org/hibernate/mapping/Constraint.java
index 54596cc1bb..0be3c3b250 100644
--- a/hibernate-core/src/main/java/org/hibernate/mapping/Constraint.java
+++ b/hibernate-core/src/main/java/org/hibernate/mapping/Constraint.java
@@ -159,7 +159,7 @@ public abstract class Constraint implements RelationalModel, Exportable, Seriali
@Deprecated(since = "6.0")
public Iterator getColumnIterator() {
- return columns.iterator();
+ return getColumns().iterator();
}
public Table getTable() {
diff --git a/hibernate-core/src/main/java/org/hibernate/mapping/Index.java b/hibernate-core/src/main/java/org/hibernate/mapping/Index.java
index 14b0d3f3e0..59e0447398 100644
--- a/hibernate-core/src/main/java/org/hibernate/mapping/Index.java
+++ b/hibernate-core/src/main/java/org/hibernate/mapping/Index.java
@@ -27,10 +27,10 @@ import org.hibernate.internal.util.StringHelper;
* @author Gavin King
*/
public class Index implements RelationalModel, Exportable, Serializable {
- private Table table;
- private java.util.List columns = new ArrayList<>();
- private java.util.Map columnOrderMap = new HashMap<>( );
private Identifier name;
+ private Table table;
+ private final java.util.List columns = new ArrayList<>();
+ private final java.util.Map columnOrderMap = new HashMap<>( );
@Override
public String sqlCreateString(Mapping mapping, SqlStringGenerationContext context, String defaultCatalog,
diff --git a/hibernate-core/src/main/java/org/hibernate/mapping/JoinedSubclass.java b/hibernate-core/src/main/java/org/hibernate/mapping/JoinedSubclass.java
index 1e81c7ef18..72e5c01dd7 100644
--- a/hibernate-core/src/main/java/org/hibernate/mapping/JoinedSubclass.java
+++ b/hibernate-core/src/main/java/org/hibernate/mapping/JoinedSubclass.java
@@ -9,8 +9,8 @@ import java.util.Iterator;
import java.util.List;
import org.hibernate.MappingException;
+import org.hibernate.boot.Metadata;
import org.hibernate.boot.spi.MetadataBuildingContext;
-import org.hibernate.engine.spi.Mapping;
/**
* A subclass in a table-per-subclass mapping
@@ -41,9 +41,9 @@ public class JoinedSubclass extends Subclass implements TableOwner {
this.key = key;
}
- public void validate(Mapping mapping) throws MappingException {
+ public void validate(Metadata mapping) throws MappingException {
super.validate(mapping);
- if ( key!=null && !key.isValid(mapping) ) {
+ if ( key != null && !key.isValid( mapping ) ) {
throw new MappingException(
"subclass key mapping has wrong number of columns: " +
getEntityName() +
@@ -53,7 +53,7 @@ public class JoinedSubclass extends Subclass implements TableOwner {
}
}
- @Deprecated
+ @Deprecated @SuppressWarnings("deprecation")
public Iterator getReferenceablePropertyIterator() {
return getPropertyIterator();
}
diff --git a/hibernate-core/src/main/java/org/hibernate/mapping/MetaAttributable.java b/hibernate-core/src/main/java/org/hibernate/mapping/MetaAttributable.java
index d73c7c1ad8..01678061d6 100644
--- a/hibernate-core/src/main/java/org/hibernate/mapping/MetaAttributable.java
+++ b/hibernate-core/src/main/java/org/hibernate/mapping/MetaAttributable.java
@@ -7,6 +7,8 @@
package org.hibernate.mapping;
+import java.util.Map;
+
/**
* Common interface for things that can handle meta attributes.
*
@@ -14,9 +16,9 @@ package org.hibernate.mapping;
*/
public interface MetaAttributable {
- java.util.Map getMetaAttributes();
+ Map getMetaAttributes();
- void setMetaAttributes(java.util.Map metas);
+ void setMetaAttributes(Map metas);
MetaAttribute getMetaAttribute(String name);
diff --git a/hibernate-core/src/main/java/org/hibernate/mapping/MetaAttribute.java b/hibernate-core/src/main/java/org/hibernate/mapping/MetaAttribute.java
index 64414bb3ca..d1d3f589b8 100644
--- a/hibernate-core/src/main/java/org/hibernate/mapping/MetaAttribute.java
+++ b/hibernate-core/src/main/java/org/hibernate/mapping/MetaAttribute.java
@@ -16,8 +16,8 @@ import java.util.Collections;
* @author Gavin King
*/
public class MetaAttribute implements Serializable {
- private String name;
- private java.util.List values = new ArrayList();
+ private final String name;
+ private final java.util.List values = new ArrayList<>();
public MetaAttribute(String name) {
this.name = name;
@@ -27,7 +27,7 @@ public class MetaAttribute implements Serializable {
return name;
}
- public java.util.List getValues() {
+ public java.util.List getValues() {
return Collections.unmodifiableList(values);
}
@@ -39,7 +39,7 @@ public class MetaAttribute implements Serializable {
if ( values.size()!=1 ) {
throw new IllegalStateException("no unique value");
}
- return (String) values.get(0);
+ return values.get(0);
}
public boolean isMultiValued() {
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 492c040556..249141f926 100644
--- a/hibernate-core/src/main/java/org/hibernate/mapping/PersistentClass.java
+++ b/hibernate-core/src/main/java/org/hibernate/mapping/PersistentClass.java
@@ -13,22 +13,24 @@ import java.util.Comparator;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
+import java.util.Map;
import java.util.Set;
import java.util.StringTokenizer;
import org.hibernate.MappingException;
+import org.hibernate.Remove;
+import org.hibernate.boot.Metadata;
import org.hibernate.boot.model.CustomSql;
import org.hibernate.boot.registry.classloading.spi.ClassLoadingException;
+import org.hibernate.boot.spi.ClassLoaderAccess;
import org.hibernate.boot.spi.MetadataBuildingContext;
import org.hibernate.engine.OptimisticLockStyle;
import org.hibernate.engine.spi.ExecuteUpdateResultCheckStyle;
-import org.hibernate.engine.spi.Mapping;
import org.hibernate.internal.FilterConfiguration;
import org.hibernate.internal.util.StringHelper;
import org.hibernate.internal.util.collections.JoinedIterator;
import org.hibernate.internal.util.collections.JoinedList;
import org.hibernate.internal.util.collections.SingletonIterator;
-import org.hibernate.metamodel.RepresentationMode;
import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.jpa.event.spi.CallbackDefinition;
import org.hibernate.service.ServiceRegistry;
@@ -41,6 +43,7 @@ import org.hibernate.type.Type;
* @author Gavin King
*/
public abstract class PersistentClass implements AttributeContainer, Serializable, Filterable, MetaAttributable, Contributable {
+
private static final Alias PK_ALIAS = new Alias( 15, "PK" );
public static final String NULL_DISCRIMINATOR_MAPPING = "null";
@@ -61,25 +64,25 @@ public abstract class PersistentClass implements AttributeContainer, Serializabl
private String discriminatorValue;
private boolean lazy;
- private final java.util.List properties = new ArrayList<>();
- private final java.util.List declaredProperties = new ArrayList<>();
- private final java.util.List subclasses = new ArrayList<>();
- private final java.util.List subclassProperties = new ArrayList<>();
- private final java.util.List subclassTables = new ArrayList<>();
+ private final List properties = new ArrayList<>();
+ private final List declaredProperties = new ArrayList<>();
+ private final List subclasses = new ArrayList<>();
+ private final List subclassProperties = new ArrayList<>();
+ private final List subclassTables = new ArrayList<>();
private boolean dynamicInsert;
private boolean dynamicUpdate;
private int batchSize = -1;
private boolean selectBeforeUpdate;
- private java.util.Map metaAttributes;
- private final java.util.List joins = new ArrayList<>();
- private final java.util.List subclassJoins = new ArrayList<>();
- private final java.util.List filters = new ArrayList<>();
+ private java.util.Map metaAttributes;
+ private final List joins = new ArrayList<>();
+ private final List subclassJoins = new ArrayList<>();
+ private final List filters = new ArrayList<>();
protected final Set synchronizedTables = new HashSet<>();
private String loaderName;
private Boolean isAbstract;
private boolean hasSubselectLoadableCollections;
private Component identifierMapper;
- private java.util.List callbackDefinitions;
+ private List callbackDefinitions;
// Custom SQL
private String customSQLInsert;
@@ -98,9 +101,9 @@ public abstract class PersistentClass implements AttributeContainer, Serializabl
private boolean isCached;
- public PersistentClass(MetadataBuildingContext metadataBuildingContext) {
- this.metadataBuildingContext = metadataBuildingContext;
- this.contributor = metadataBuildingContext.getCurrentContributorName();
+ public PersistentClass(MetadataBuildingContext buildingContext) {
+ this.metadataBuildingContext = buildingContext;
+ this.contributor = buildingContext.getCurrentContributorName();
}
public String getContributor() {
@@ -129,6 +132,10 @@ public abstract class PersistentClass implements AttributeContainer, Serializabl
this.proxyInterface = null;
}
+ private ClassLoaderAccess getClassLoaderAccess() {
+ return metadataBuildingContext.getBootstrapContext().getClassLoaderAccess();
+ }
+
public Class> getMappedClass() throws MappingException {
if ( className == null ) {
return null;
@@ -136,7 +143,7 @@ public abstract class PersistentClass implements AttributeContainer, Serializabl
try {
if ( mappedClass == null ) {
- mappedClass = metadataBuildingContext.getBootstrapContext().getClassLoaderAccess().classForName( className );
+ mappedClass = getClassLoaderAccess().classForName( className );
}
return mappedClass;
}
@@ -151,7 +158,7 @@ public abstract class PersistentClass implements AttributeContainer, Serializabl
}
try {
if ( proxyInterface == null ) {
- proxyInterface = metadataBuildingContext.getBootstrapContext().getClassLoaderAccess().classForName( proxyInterfaceName );
+ proxyInterface = getClassLoaderAccess().classForName( proxyInterfaceName );
}
return proxyInterface;
}
@@ -207,11 +214,11 @@ public abstract class PersistentClass implements AttributeContainer, Serializabl
}
public int getSubclassSpan() {
- int n = subclasses.size();
+ int span = subclasses.size();
for ( Subclass subclass : subclasses ) {
- n += subclass.getSubclassSpan();
+ span += subclass.getSubclassSpan();
}
- return n;
+ return span;
}
/**
@@ -219,13 +226,14 @@ public abstract class PersistentClass implements AttributeContainer, Serializabl
*/
public List getSubclasses() {
@SuppressWarnings("unchecked")
- List[] iters = new List[subclasses.size() + 1];
- int i = 0;
- for ( Subclass subclass : subclasses ) {
- iters[i++] = subclass.getSubclasses();
+ List[] subclassLists = new List[subclasses.size() + 1];
+ int j;
+ for (j = 0; j < subclasses.size(); j++) {
+ Subclass subclass = subclasses.get(j);
+ subclassLists[j] = subclass.getSubclasses();
}
- iters[i] = subclasses;
- return new JoinedList<>( iters );
+ subclassLists[j] = subclasses;
+ return new JoinedList<>( subclassLists );
}
/**
@@ -233,11 +241,11 @@ public abstract class PersistentClass implements AttributeContainer, Serializabl
*
* @deprecated use {@link #getSubclasses()}
*/
- @Deprecated(since = "6.0")
+ @Deprecated(since = "6.0") @Remove
public Iterator getSubclassIterator() {
@SuppressWarnings("unchecked")
- Iterator[] iters = new Iterator[subclasses.size() + 1];
- Iterator iter = subclasses.iterator();
+ final Iterator[] iters = new Iterator[subclasses.size() + 1];
+ final Iterator iter = subclasses.iterator();
int i = 0;
while ( iter.hasNext() ) {
iters[i++] = iter.next().getSubclassIterator();
@@ -247,7 +255,7 @@ public abstract class PersistentClass implements AttributeContainer, Serializabl
}
public List getSubclassClosure() {
- ArrayList> lists = new ArrayList<>();
+ final ArrayList> lists = new ArrayList<>();
lists.add( List.of( this ) );
for ( Subclass subclass : getSubclasses() ) {
lists.add( subclass.getSubclassClosure() );
@@ -255,9 +263,9 @@ public abstract class PersistentClass implements AttributeContainer, Serializabl
return new JoinedList<>( lists );
}
- @Deprecated(since = "6.0")
+ @Deprecated(since = "6.0") @Remove
public Iterator getSubclassClosureIterator() {
- ArrayList> iters = new ArrayList<>();
+ final ArrayList> iters = new ArrayList<>();
iters.add( new SingletonIterator<>( this ) );
for ( Subclass subclass : getSubclasses() ) {
iters.add( subclass.getSubclassClosureIterator() );
@@ -345,17 +353,17 @@ public abstract class PersistentClass implements AttributeContainer, Serializabl
public abstract List getPropertyClosure();
- @Deprecated(since = "6.0")
+ @Deprecated(since = "6.0") @Remove
public abstract Iterator getPropertyClosureIterator();
public abstract List getTableClosure();
- @Deprecated(since = "6.0")
+ @Deprecated(since = "6.0") @Remove
public abstract Iterator getTableClosureIterator();
public abstract List getKeyClosure();
- @Deprecated(since = "6.0")
+ @Deprecated(since = "6.0") @Remove
public abstract Iterator getKeyClosureIterator();
protected void addSubclassProperty(Property prop) {
@@ -370,9 +378,9 @@ public abstract class PersistentClass implements AttributeContainer, Serializabl
subclassTables.add( subclassTable );
}
- @Deprecated(since = "6.0")
+ @Deprecated(since = "6.0") @Remove
public Iterator getSubclassPropertyClosureIterator() {
- ArrayList> iters = new ArrayList<>();
+ final ArrayList> iters = new ArrayList<>();
iters.add( getPropertyClosureIterator() );
iters.add( subclassProperties.iterator() );
for (Join join : subclassJoins) {
@@ -382,7 +390,7 @@ public abstract class PersistentClass implements AttributeContainer, Serializabl
}
public List getSubclassPropertyClosure() {
- ArrayList> lists = new ArrayList<>();
+ final ArrayList> lists = new ArrayList<>();
lists.add( getPropertyClosure() );
lists.add( subclassProperties );
for (Join join : subclassJoins) {
@@ -391,7 +399,7 @@ public abstract class PersistentClass implements AttributeContainer, Serializabl
return new JoinedList<>( lists );
}
- @Deprecated(since = "6.0")
+ @Deprecated(since = "6.0") @Remove
public Iterator getSubclassJoinClosureIterator() {
return new JoinedIterator<>( getJoinClosureIterator(), subclassJoins.iterator() );
}
@@ -404,7 +412,7 @@ public abstract class PersistentClass implements AttributeContainer, Serializabl
return new JoinedList<>( getTableClosure(), subclassTables );
}
- @Deprecated(since = "6.0")
+ @Deprecated(since = "6.0") @Remove
public Iterator getSubclassTableClosureIterator() {
return new JoinedIterator<>( getTableClosureIterator(), subclassTables.iterator() );
}
@@ -448,7 +456,7 @@ public abstract class PersistentClass implements AttributeContainer, Serializabl
public void createPrimaryKey() {
//Primary key constraint
final Table table = getTable();
- PrimaryKey pk = new PrimaryKey( table );
+ final PrimaryKey pk = new PrimaryKey( table );
pk.setName( PK_ALIAS.toAliasString( table.getName() ) );
table.setPrimaryKey( pk );
@@ -485,7 +493,7 @@ public abstract class PersistentClass implements AttributeContainer, Serializabl
*
* @deprecated use {@link #getReferenceableProperties()}
*/
- @Deprecated(since = "6.0")
+ @Deprecated(since = "6.0") @Remove
public Iterator getReferenceablePropertyIterator() {
return getPropertyClosureIterator();
}
@@ -638,10 +646,8 @@ public abstract class PersistentClass implements AttributeContainer, Serializabl
return true;
}
- final Iterator itr = getPropertyClosureIterator();
- while ( itr.hasNext() ) {
- final Property property = itr.next();
- if ( property.getName().equals( name ) ) {
+ for ( Property property : getPropertyClosure() ) {
+ if (property.getName().equals(name)) {
return true;
}
}
@@ -702,7 +708,7 @@ public abstract class PersistentClass implements AttributeContainer, Serializabl
this.optimisticLockStyle = optimisticLockStyle;
}
- public void validate(Mapping mapping) throws MappingException {
+ public void validate(Metadata mapping) throws MappingException {
for ( Property prop : getProperties() ) {
if ( !prop.isValid( mapping ) ) {
Type type = prop.getType();
@@ -721,7 +727,7 @@ public abstract class PersistentClass implements AttributeContainer, Serializabl
}
private void checkPropertyDuplication() throws MappingException {
- HashSet names = new HashSet<>();
+ final HashSet names = new HashSet<>();
for ( Property prop : getProperties() ) {
if ( !names.add( prop.getName() ) ) {
throw new MappingException( "Duplicate property mapping of " + prop.getName() + " found in " + getEntityName() );
@@ -737,18 +743,16 @@ public abstract class PersistentClass implements AttributeContainer, Serializabl
return NULL_DISCRIMINATOR_MAPPING.equals( getDiscriminatorValue() );
}
- public java.util.Map getMetaAttributes() {
+ public Map getMetaAttributes() {
return metaAttributes;
}
- public void setMetaAttributes(java.util.Map metas) {
+ public void setMetaAttributes(java.util.Map metas) {
this.metaAttributes = metas;
}
public MetaAttribute getMetaAttribute(String name) {
- return metaAttributes == null
- ? null
- : (MetaAttribute) metaAttributes.get( name );
+ return metaAttributes == null ? null : metaAttributes.get( name );
}
@Override
@@ -803,7 +807,7 @@ public abstract class PersistentClass implements AttributeContainer, Serializabl
}
/**
- * Build an iterator over the properties defined on this class. The returned
+ * Build an iterator over the properties defined on this class. The returned
* iterator only accounts for "normal" properties (i.e. non-identifier
* properties).
*
@@ -819,7 +823,7 @@ public abstract class PersistentClass implements AttributeContainer, Serializabl
*/
@Deprecated(since = "6.0")
public Iterator getPropertyIterator() {
- ArrayList> iterators = new ArrayList<>();
+ final ArrayList> iterators = new ArrayList<>();
iterators.add( properties.iterator() );
for (Join join : joins) {
iterators.add( join.getPropertyIterator() );
@@ -827,8 +831,21 @@ public abstract class PersistentClass implements AttributeContainer, Serializabl
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
+ * properties).
+ *
+ * Differs from {@link #getUnjoinedProperties} in that the returned iterator
+ * will include properties defined as part of a join.
+ *
+ * Differs from {@link #getReferenceableProperties} in that the properties
+ * defined in superclasses of the mapping inheritance are not included.
+ *
+ * @return An iterator over the "normal" properties.
+ */
public List getProperties() {
- ArrayList> list = new ArrayList<>();
+ final ArrayList> list = new ArrayList<>();
list.add( properties );
for (Join join : joins) {
list.add( join.getProperties() );
@@ -997,18 +1014,17 @@ public abstract class PersistentClass implements AttributeContainer, Serializabl
protected void checkColumnDuplication(Set distinctColumns, Value value)
throws MappingException {
- if (value == null) {
- return;
- }
- for ( Selectable columnOrFormula : value.getSelectables() ) {
- if ( !columnOrFormula.isFormula() ) {
- Column col = (Column) columnOrFormula;
- if ( !distinctColumns.add( col.getName() ) ) {
- throw new MappingException(
- "Column '" + col.getName()
- + "' is duplicated in mapping for entity '" + getEntityName()
- + "' (use '@Column(insertable=false, updatable=false)' when mapping multiple properties to the same column)"
- );
+ if ( value != null ) {
+ for ( Selectable columnOrFormula : value.getSelectables() ) {
+ if ( !columnOrFormula.isFormula() ) {
+ final Column col = (Column) columnOrFormula;
+ if ( !distinctColumns.add( col.getName() ) ) {
+ throw new MappingException(
+ "Column '" + col.getName()
+ + "' is duplicated in mapping for entity '" + getEntityName()
+ + "' (use '@Column(insertable=false, updatable=false)' when mapping multiple properties to the same column)"
+ );
+ }
}
}
}
@@ -1045,7 +1061,7 @@ public abstract class PersistentClass implements AttributeContainer, Serializabl
}
protected void checkColumnDuplication() {
- HashSet cols = new HashSet<>();
+ final HashSet cols = new HashSet<>();
if ( getIdentifierMapper() == null ) {
//an identifier mapper => getKey will be included in the getNonDuplicatedPropertyIterator()
//and checked later, so it needs to be excluded
@@ -1119,14 +1135,6 @@ public abstract class PersistentClass implements AttributeContainer, Serializabl
this.identifierMapper = handle;
}
- public String getTuplizerImplClassName(RepresentationMode mode) {
- return null;
- }
-
- public java.util.Map getTuplizerMap() {
- return null;
- }
-
private Boolean hasNaturalId;
public boolean hasNaturalId() {
@@ -1166,7 +1174,7 @@ public abstract class PersistentClass implements AttributeContainer, Serializabl
return new JoinedIterator<>( iterators );
}
- public void addMappedsuperclassProperty(Property p) {
+ public void addMappedSuperclassProperty(Property p) {
properties.add( p );
p.setPersistentClass( this );
}
diff --git a/hibernate-core/src/main/java/org/hibernate/mapping/PersistentClassVisitor.java b/hibernate-core/src/main/java/org/hibernate/mapping/PersistentClassVisitor.java
index 8f532de227..0db3aac2d3 100644
--- a/hibernate-core/src/main/java/org/hibernate/mapping/PersistentClassVisitor.java
+++ b/hibernate-core/src/main/java/org/hibernate/mapping/PersistentClassVisitor.java
@@ -6,26 +6,13 @@
*/
package org.hibernate.mapping;
-
/**
* @author max
- *
*/
public interface PersistentClassVisitor {
-
-
Object accept(RootClass class1);
-
-
Object accept(UnionSubclass subclass);
-
Object accept(SingleTableSubclass subclass);
-
-
Object accept(JoinedSubclass subclass);
-
-
Object accept(Subclass subclass);
-
-
}
diff --git a/hibernate-core/src/main/java/org/hibernate/mapping/Property.java b/hibernate-core/src/main/java/org/hibernate/mapping/Property.java
index cf873000c3..6fabc4684a 100644
--- a/hibernate-core/src/main/java/org/hibernate/mapping/Property.java
+++ b/hibernate-core/src/main/java/org/hibernate/mapping/Property.java
@@ -10,6 +10,7 @@ import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
+import java.util.Map;
import java.util.StringTokenizer;
import org.hibernate.HibernateException;
@@ -258,7 +259,7 @@ public class Property implements Serializable, MetaAttributable {
return propertyAccessorName==null || "property".equals( propertyAccessorName );
}
- public java.util.Map getMetaAttributes() {
+ public Map getMetaAttributes() {
return metaAttributes;
}
@@ -266,7 +267,7 @@ public class Property implements Serializable, MetaAttributable {
return metaAttributes==null?null:(MetaAttribute) metaAttributes.get(attributeName);
}
- public void setMetaAttributes(java.util.Map metas) {
+ public void setMetaAttributes(Map metas) {
this.metaAttributes = metas;
}
diff --git a/hibernate-core/src/main/java/org/hibernate/mapping/RootClass.java b/hibernate-core/src/main/java/org/hibernate/mapping/RootClass.java
index 6d72603d01..0cb94ec67d 100644
--- a/hibernate-core/src/main/java/org/hibernate/mapping/RootClass.java
+++ b/hibernate-core/src/main/java/org/hibernate/mapping/RootClass.java
@@ -12,8 +12,8 @@ import java.util.List;
import java.util.Set;
import org.hibernate.MappingException;
+import org.hibernate.boot.Metadata;
import org.hibernate.boot.spi.MetadataBuildingContext;
-import org.hibernate.engine.spi.Mapping;
import org.hibernate.internal.CoreLogging;
import org.hibernate.internal.CoreMessageLogger;
import org.hibernate.internal.util.ReflectHelper;
@@ -55,8 +55,8 @@ public class RootClass extends PersistentClass implements TableOwner {
private Property declaredIdentifierProperty;
private Property declaredVersion;
- public RootClass(MetadataBuildingContext metadataBuildingContext) {
- super( metadataBuildingContext );
+ public RootClass(MetadataBuildingContext buildingContext) {
+ super( buildingContext );
}
@Override
@@ -279,7 +279,7 @@ public class RootClass extends PersistentClass implements TableOwner {
}
@Override
- public void validate(Mapping mapping) throws MappingException {
+ public void validate(Metadata mapping) throws MappingException {
super.validate( mapping );
if ( !getIdentifier().isValid( mapping ) ) {
throw new MappingException(
diff --git a/hibernate-core/src/main/java/org/hibernate/mapping/SingleTableSubclass.java b/hibernate-core/src/main/java/org/hibernate/mapping/SingleTableSubclass.java
index 3d851b97e5..7aa5a3dc30 100644
--- a/hibernate-core/src/main/java/org/hibernate/mapping/SingleTableSubclass.java
+++ b/hibernate-core/src/main/java/org/hibernate/mapping/SingleTableSubclass.java
@@ -10,8 +10,8 @@ import java.util.Iterator;
import java.util.List;
import org.hibernate.MappingException;
+import org.hibernate.boot.Metadata;
import org.hibernate.boot.spi.MetadataBuildingContext;
-import org.hibernate.engine.spi.Mapping;
import org.hibernate.internal.util.collections.JoinedIterator;
import org.hibernate.internal.util.collections.JoinedList;
@@ -20,11 +20,11 @@ import org.hibernate.internal.util.collections.JoinedList;
*/
public class SingleTableSubclass extends Subclass {
- public SingleTableSubclass(PersistentClass superclass, MetadataBuildingContext metadataBuildingContext) {
- super( superclass, metadataBuildingContext );
+ public SingleTableSubclass(PersistentClass superclass, MetadataBuildingContext buildingContext) {
+ super( superclass, buildingContext );
}
- @Deprecated
+ @Deprecated @SuppressWarnings("deprecation")
protected Iterator getNonDuplicatedPropertyIterator() {
return new JoinedIterator<>(
getSuperclass().getUnjoinedPropertyIterator(),
@@ -36,7 +36,7 @@ public class SingleTableSubclass extends Subclass {
return new JoinedList<>( getSuperclass().getUnjoinedProperties(), getUnjoinedProperties() );
}
- @Deprecated
+ @Deprecated @SuppressWarnings("deprecation")
protected Iterator getDiscriminatorColumnIterator() {
return isDiscriminatorInsertable() && !getDiscriminator().hasFormula()
? getDiscriminator().getColumnIterator()
@@ -47,7 +47,7 @@ public class SingleTableSubclass extends Subclass {
return mv.accept( this );
}
- public void validate(Mapping mapping) throws MappingException {
+ public void validate(Metadata mapping) throws MappingException {
if ( getDiscriminator() == null ) {
throw new MappingException(
"No discriminator found for " + getEntityName()
diff --git a/hibernate-core/src/main/java/org/hibernate/mapping/Subclass.java b/hibernate-core/src/main/java/org/hibernate/mapping/Subclass.java
index f7de10a3f8..2544dfb378 100644
--- a/hibernate-core/src/main/java/org/hibernate/mapping/Subclass.java
+++ b/hibernate-core/src/main/java/org/hibernate/mapping/Subclass.java
@@ -7,11 +7,9 @@
package org.hibernate.mapping;
import java.util.ArrayList;
-import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
-import java.util.Map;
import org.hibernate.AssertionFailure;
import org.hibernate.boot.spi.MetadataBuildingContext;
@@ -20,7 +18,6 @@ import org.hibernate.internal.FilterConfiguration;
import org.hibernate.internal.util.collections.JoinedIterator;
import org.hibernate.internal.util.collections.JoinedList;
import org.hibernate.internal.util.collections.SingletonIterator;
-import org.hibernate.metamodel.RepresentationMode;
import org.hibernate.persister.entity.EntityPersister;
/**
@@ -28,12 +25,13 @@ import org.hibernate.persister.entity.EntityPersister;
* @author Gavin King
*/
public class Subclass extends PersistentClass {
+
private PersistentClass superclass;
private Class extends EntityPersister> classPersisterClass;
private final int subclassId;
- public Subclass(PersistentClass superclass, MetadataBuildingContext metadataBuildingContext) {
- super( metadataBuildingContext );
+ public Subclass(PersistentClass superclass, MetadataBuildingContext buildingContext) {
+ super( buildingContext );
this.superclass = superclass;
this.subclassId = superclass.nextSubclassId();
}
@@ -115,8 +113,8 @@ public class Subclass extends PersistentClass {
}
@Override
- public void addMappedsuperclassProperty(Property p) {
- super.addMappedsuperclassProperty( p );
+ public void addMappedSuperclassProperty(Property p) {
+ super.addMappedSuperclassProperty( p );
getSuperclass().addSubclassProperty(p);
}
@@ -273,7 +271,7 @@ public class Subclass extends PersistentClass {
return new JoinedList<>( getSuperclass().getJoinClosure(), super.getJoinClosure() );
}
- @Deprecated(since = "6.0")
+ @Deprecated(since = "6.0") @SuppressWarnings("deprecation")
public Iterator getJoinClosureIterator() {
return new JoinedIterator<>(
getSuperclass().getJoinClosureIterator(),
@@ -333,34 +331,6 @@ public class Subclass extends PersistentClass {
getSuperclass().hasSubselectLoadableCollections();
}
- @Override
- public String getTuplizerImplClassName(RepresentationMode mode) {
- String impl = super.getTuplizerImplClassName( mode );
- if ( impl == null ) {
- impl = getSuperclass().getTuplizerImplClassName( mode );
- }
- return impl;
- }
-
- @Override
- public Map getTuplizerMap() {
- Map specificTuplizerDefs = super.getTuplizerMap();
- Map superclassTuplizerDefs = getSuperclass().getTuplizerMap();
- if ( specificTuplizerDefs == null && superclassTuplizerDefs == null ) {
- return null;
- }
- else {
- Map combined = new HashMap();
- if ( superclassTuplizerDefs != null ) {
- combined.putAll( superclassTuplizerDefs );
- }
- if ( specificTuplizerDefs != null ) {
- combined.putAll( specificTuplizerDefs );
- }
- return java.util.Collections.unmodifiableMap( combined );
- }
- }
-
@Override
public Component getIdentifierMapper() {
return superclass.getIdentifierMapper();
diff --git a/hibernate-core/src/main/java/org/hibernate/mapping/Table.java b/hibernate-core/src/main/java/org/hibernate/mapping/Table.java
index 1350aae04f..563f9d6abb 100644
--- a/hibernate-core/src/main/java/org/hibernate/mapping/Table.java
+++ b/hibernate-core/src/main/java/org/hibernate/mapping/Table.java
@@ -34,6 +34,9 @@ import org.hibernate.tool.schema.extract.spi.TableInformation;
import org.jboss.logging.Logger;
+import static java.util.Collections.unmodifiableList;
+import static java.util.Collections.unmodifiableMap;
+
/**
* A relational database table.
*
@@ -228,24 +231,19 @@ public class Table implements RelationalModel, Serializable, ContributableDataba
if ( column == null ) {
return null;
}
-
- Column myColumn = columns.get( column.getCanonicalName() );
-
- return column.equals( myColumn ) ?
- myColumn :
- null;
+ final Column myColumn = columns.get( column.getCanonicalName() );
+ return column.equals( myColumn ) ? myColumn : null;
}
public Column getColumn(Identifier name) {
if ( name == null ) {
return null;
}
-
return columns.get( name.getCanonicalName() );
}
public Column getColumn(int n) {
- Iterator iter = columns.values().iterator();
+ final Iterator iter = columns.values().iterator();
for ( int i = 0; i < n - 1; i++ ) {
iter.next();
}
@@ -253,7 +251,7 @@ public class Table implements RelationalModel, Serializable, ContributableDataba
}
public void addColumn(Column column) {
- Column old = getColumn( column );
+ final Column old = getColumn( column );
if ( old == null ) {
if ( primaryKey != null ) {
for ( Column c : primaryKey.getColumns() ) {
@@ -269,8 +267,8 @@ public class Table implements RelationalModel, Serializable, ContributableDataba
}
}
}
- this.columns.put( column.getCanonicalName(), column );
- column.uniqueInteger = this.columns.size();
+ columns.put( column.getCanonicalName(), column );
+ column.uniqueInteger = columns.size();
}
else {
column.uniqueInteger = old.uniqueInteger;
@@ -283,24 +281,29 @@ public class Table implements RelationalModel, Serializable, ContributableDataba
@Deprecated(since = "6.0")
public Iterator getColumnIterator() {
- return columns.values().iterator();
+ return getColumns().iterator();
}
public Collection getColumns() {
return columns.values();
}
+ @Deprecated(since = "6.2")
public Iterator getIndexIterator() {
- return indexes.values().iterator();
+ return getIndexes().values().iterator();
+ }
+
+ public Map getIndexes() {
+ return unmodifiableMap( indexes );
}
@Deprecated(since = "6.0")
public Iterator getForeignKeyIterator() {
- return foreignKeys.values().iterator();
+ return getForeignKeys().values().iterator();
}
public Map getForeignKeys() {
- return Collections.unmodifiableMap( foreignKeys );
+ return unmodifiableMap( foreignKeys );
}
@Deprecated(since = "6.0")
@@ -310,7 +313,7 @@ public class Table implements RelationalModel, Serializable, ContributableDataba
public Map getUniqueKeys() {
cleanseUniqueKeyMapIfNeeded();
- return uniqueKeys;
+ return unmodifiableMap( uniqueKeys );
}
private int sizeOfUniqueKeyMapOnLastCleanse;
@@ -381,7 +384,7 @@ public class Table implements RelationalModel, Serializable, ContributableDataba
}
private boolean isSameAsPrimaryKeyColumns(UniqueKey uniqueKey) {
- if ( primaryKey == null || ! primaryKey.getColumnIterator().hasNext() ) {
+ if ( primaryKey == null || primaryKey.getColumns().isEmpty() ) {
// happens for many-to-many tables
return false;
}
@@ -393,9 +396,9 @@ public class Table implements RelationalModel, Serializable, ContributableDataba
public int hashCode() {
final int prime = 31;
int result = 1;
- result = prime * result + ((catalog == null) ? 0 : catalog.hashCode());
- result = prime * result + ((name == null) ? 0 : name.hashCode());
- result = prime * result + ((schema == null) ? 0 : schema.hashCode());
+ result = prime * result + (catalog == null ? 0 : catalog.hashCode());
+ result = prime * result + (name == null ? 0 : name.hashCode());
+ result = prime * result + (schema == null ? 0 : schema.hashCode());
return result;
}
@@ -820,11 +823,11 @@ public class Table implements RelationalModel, Serializable, ContributableDataba
@Deprecated(since = "6.0")
public Iterator getCheckConstraintsIterator() {
- return checkConstraints.iterator();
+ return getCheckConstraints().iterator();
}
public List getCheckConstraints() {
- return checkConstraints;
+ return unmodifiableList( checkConstraints );
}
@Override
@@ -900,7 +903,7 @@ public class Table implements RelationalModel, Serializable, ContributableDataba
for ( Function producer : initCommandProducers ) {
initCommands.add( producer.apply( context ) );
}
- return Collections.unmodifiableList( initCommands );
+ return unmodifiableList( initCommands );
}
}
}
diff --git a/hibernate-core/src/main/java/org/hibernate/mapping/UnionSubclass.java b/hibernate-core/src/main/java/org/hibernate/mapping/UnionSubclass.java
index fbe44ce8db..49a1a65694 100644
--- a/hibernate-core/src/main/java/org/hibernate/mapping/UnionSubclass.java
+++ b/hibernate-core/src/main/java/org/hibernate/mapping/UnionSubclass.java
@@ -8,9 +8,7 @@ package org.hibernate.mapping;
import java.util.Iterator;
import java.util.List;
-import org.hibernate.MappingException;
import org.hibernate.boot.spi.MetadataBuildingContext;
-import org.hibernate.engine.spi.Mapping;
/**
* A subclass in a table-per-concrete-class mapping
@@ -18,10 +16,9 @@ import org.hibernate.engine.spi.Mapping;
*/
public class UnionSubclass extends Subclass implements TableOwner {
private Table table;
- private KeyValue key;
- public UnionSubclass(PersistentClass superclass, MetadataBuildingContext metadataBuildingContext) {
- super( superclass, metadataBuildingContext );
+ public UnionSubclass(PersistentClass superclass, MetadataBuildingContext buildingContext) {
+ super( superclass, buildingContext );
}
public Table getTable() {
@@ -37,7 +34,7 @@ public class UnionSubclass extends Subclass implements TableOwner {
return synchronizedTables;
}
- @Deprecated
+ @Deprecated @SuppressWarnings("deprecation")
protected Iterator getNonDuplicatedPropertyIterator() {
return getPropertyClosureIterator();
}
@@ -46,18 +43,6 @@ public class UnionSubclass extends Subclass implements TableOwner {
protected List getNonDuplicatedProperties() {
return getPropertyClosure();
}
-
- public void validate(Mapping mapping) throws MappingException {
- super.validate(mapping);
- if ( key!=null && !key.isValid(mapping) ) {
- throw new MappingException(
- "subclass key mapping has wrong number of columns: " +
- getEntityName() +
- " type: " +
- key.getType().getName()
- );
- }
- }
public Table getIdentityTable() {
return getTable();
diff --git a/hibernate-core/src/main/java/org/hibernate/mapping/UniqueKey.java b/hibernate-core/src/main/java/org/hibernate/mapping/UniqueKey.java
index 0806e9f0a4..811ddb5755 100644
--- a/hibernate-core/src/main/java/org/hibernate/mapping/UniqueKey.java
+++ b/hibernate-core/src/main/java/org/hibernate/mapping/UniqueKey.java
@@ -19,7 +19,7 @@ import org.hibernate.internal.util.StringHelper;
* @author Brett Meyer
*/
public class UniqueKey extends Constraint {
- private Map columnOrderMap = new HashMap<>();
+ private final Map columnOrderMap = new HashMap<>();
@Override
public String sqlConstraintString(
diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/internal/EntityRepresentationStrategyMap.java b/hibernate-core/src/main/java/org/hibernate/metamodel/internal/EntityRepresentationStrategyMap.java
index 335087fcad..decf51099c 100644
--- a/hibernate-core/src/main/java/org/hibernate/metamodel/internal/EntityRepresentationStrategyMap.java
+++ b/hibernate-core/src/main/java/org/hibernate/metamodel/internal/EntityRepresentationStrategyMap.java
@@ -51,20 +51,12 @@ public class EntityRepresentationStrategyMap implements EntityRepresentationStra
this.proxyFactory = createProxyFactory( bootType );
this.instantiator = new EntityInstantiatorDynamicMap( bootType );
- //noinspection unchecked
- final Iterator itr = bootType.getPropertyClosureIterator();
- int i = 0;
- while ( itr.hasNext() ) {
+ for ( Property property : bootType.getPropertyClosure() ) {
//TODO: redesign how PropertyAccessors are acquired...
- final Property property = itr.next();
- final PropertyAccess propertyAccess = PropertyAccessStrategyMapImpl.INSTANCE.buildPropertyAccess(
- null,
- property.getName(),
- true );
+ final PropertyAccess propertyAccess = PropertyAccessStrategyMapImpl.INSTANCE
+ .buildPropertyAccess( null, property.getName(), true );
- propertyAccessMap.put( property.getName(), propertyAccess );
-
- i++;
+ propertyAccessMap.put(property.getName(), propertyAccess);
}
createProxyFactory( bootType );
diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/internal/EntityRepresentationStrategyPojoStandard.java b/hibernate-core/src/main/java/org/hibernate/metamodel/internal/EntityRepresentationStrategyPojoStandard.java
index 54df14f072..4889732b1e 100644
--- a/hibernate-core/src/main/java/org/hibernate/metamodel/internal/EntityRepresentationStrategyPojoStandard.java
+++ b/hibernate-core/src/main/java/org/hibernate/metamodel/internal/EntityRepresentationStrategyPojoStandard.java
@@ -308,22 +308,20 @@ public class EntityRepresentationStrategyPojoStandard implements EntityRepresent
boolean foundCustomAccessor = false;
- final Iterator itr = bootType.getPropertyClosureIterator();
- while ( itr.hasNext() ) {
+ for ( Property property : bootType.getPropertyClosure() ) {
//TODO: redesign how PropertyAccessors are acquired...
- final Property property = itr.next();
- final PropertyAccess propertyAccess = makePropertyAccess( property );
+ final PropertyAccess propertyAccess = makePropertyAccess(property);
- propertyAccessMap.put( property.getName(), propertyAccess );
+ propertyAccessMap.put(property.getName(), propertyAccess);
- if ( ! (propertyAccess instanceof PropertyAccessBasicImpl) ) {
+ if (!(propertyAccess instanceof PropertyAccessBasicImpl)) {
foundCustomAccessor = true;
}
- getterNames.add( propertyAccess.getGetter().getMethodName() );
- getterTypes.add( propertyAccess.getGetter().getReturnTypeClass() );
+ getterNames.add(propertyAccess.getGetter().getMethodName());
+ getterTypes.add(propertyAccess.getGetter().getReturnTypeClass());
- setterNames.add( propertyAccess.getSetter().getMethodName() );
+ setterNames.add(propertyAccess.getSetter().getMethodName());
}
if ( foundCustomAccessor || ! Environment.useReflectionOptimizer() ) {
diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/ToOneAttributeMapping.java b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/ToOneAttributeMapping.java
index 678262002f..23e575695d 100644
--- a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/ToOneAttributeMapping.java
+++ b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/ToOneAttributeMapping.java
@@ -237,14 +237,11 @@ public class ToOneAttributeMapping
}
// Simple one-to-one mapped by cases
if ( bidirectionalAttributeName == null ) {
- //noinspection deprecation
- final Iterator propertyClosureIterator = entityBinding.getPropertyClosureIterator();
- while ( propertyClosureIterator.hasNext() ) {
- final Property property = propertyClosureIterator.next();
- if ( property.getValue() instanceof OneToOne
- && name.equals( ( (OneToOne) property.getValue() ).getMappedByProperty() )
- && ( (OneToOne) property.getValue() ).getReferencedEntityName().equals(
- declaringType.getJavaType().getJavaType().getTypeName() ) ) {
+ for ( Property property : entityBinding.getPropertyClosure() ) {
+ if (property.getValue() instanceof OneToOne
+ && name.equals(((OneToOne) property.getValue()).getMappedByProperty())
+ && ((OneToOne) property.getValue()).getReferencedEntityName().equals(
+ declaringType.getJavaType().getJavaType().getTypeName())) {
bidirectionalAttributeName = property.getName();
break;
}
@@ -252,15 +249,12 @@ public class ToOneAttributeMapping
}
}
else {
- //noinspection deprecation
- final Iterator propertyClosureIterator = entityBinding.getPropertyClosureIterator();
- while ( propertyClosureIterator.hasNext() ) {
- final Property property = propertyClosureIterator.next();
+ for ( Property property : entityBinding.getPropertyClosure() ) {
final Value value = property.getValue();
- if ( value instanceof Collection
- && name.equals( ( (Collection) value ).getMappedByProperty() )
- && ( (Collection) value ).getElement().getType().getName()
- .equals( declaringType.getJavaType().getJavaType().getTypeName() ) ) {
+ if (value instanceof Collection
+ && name.equals(((Collection) value).getMappedByProperty())
+ && ((Collection) value).getElement().getType().getName()
+ .equals(declaringType.getJavaType().getJavaType().getTypeName())) {
bidirectionalAttributeName = property.getName();
break;
}
diff --git a/hibernate-core/src/main/java/org/hibernate/persister/entity/AbstractEntityPersister.java b/hibernate-core/src/main/java/org/hibernate/persister/entity/AbstractEntityPersister.java
index 2699a1aaab..8d88ebee9b 100644
--- a/hibernate-core/src/main/java/org/hibernate/persister/entity/AbstractEntityPersister.java
+++ b/hibernate-core/src/main/java/org/hibernate/persister/entity/AbstractEntityPersister.java
@@ -86,7 +86,6 @@ import org.hibernate.engine.spi.EntityEntryFactory;
import org.hibernate.engine.spi.EntityKey;
import org.hibernate.engine.spi.ExecuteUpdateResultCheckStyle;
import org.hibernate.engine.spi.LoadQueryInfluencers;
-import org.hibernate.engine.spi.Managed;
import org.hibernate.engine.spi.NaturalIdResolutions;
import org.hibernate.engine.spi.PersistenceContext;
import org.hibernate.engine.spi.PersistentAttributeInterceptable;
diff --git a/hibernate-core/src/main/java/org/hibernate/query/sql/internal/ResultSetMappingProcessor.java b/hibernate-core/src/main/java/org/hibernate/query/sql/internal/ResultSetMappingProcessor.java
index ae3c2889a2..c45f06627f 100644
--- a/hibernate-core/src/main/java/org/hibernate/query/sql/internal/ResultSetMappingProcessor.java
+++ b/hibernate-core/src/main/java/org/hibernate/query/sql/internal/ResultSetMappingProcessor.java
@@ -47,10 +47,12 @@ import org.hibernate.type.ComponentType;
import org.hibernate.type.EntityType;
import org.hibernate.type.Type;
+import static org.hibernate.internal.util.collections.ArrayHelper.EMPTY_STRING_ARRAY;
+
/**
- * Responsible for processing the {@link ResultSetMapping}
- * defined by a {@link org.hibernate.query.sql.spi.NativeSelectQueryDefinition} and
- * pre-process it for consumption in {@link SQLQueryParser}.
+ * Responsible for processing the {@link ResultSetMapping} defined by a
+ * {@link org.hibernate.query.sql.spi.NativeSelectQueryDefinition} and
+ * preprocessing it for consumption by {@link SQLQueryParser}.
*
* @author Gavin King
* @author Max Andersen
@@ -102,11 +104,6 @@ public class ResultSetMappingProcessor implements SQLQueryParser.ParserContext {
}
}
- private boolean hasPropertyResultMap(String alias) {
- Map propertyMaps = internalGetPropertyResultsMap( alias );
- return propertyMaps != null && ! propertyMaps.isEmpty();
- }
-
public SQLQueryParser.ParserContext process() {
// first, break down the returns into maps keyed by alias
// so that role returns can be more easily resolved to their owners
@@ -617,9 +614,9 @@ public class ResultSetMappingProcessor implements SQLQueryParser.ParserContext {
}
public String[] collectQuerySpaces() {
- final HashSet spaces = new HashSet();
+ final HashSet spaces = new HashSet<>();
collectQuerySpaces( spaces );
- return spaces.toArray( new String[ spaces.size() ] );
+ return spaces.toArray( EMPTY_STRING_ARRAY );
}
public void collectQuerySpaces(Collection spaces) {
diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/constraint/NonRootTablePolymorphicTests.java b/hibernate-core/src/test/java/org/hibernate/orm/test/constraint/NonRootTablePolymorphicTests.java
index 842b759cb6..9214a418cd 100644
--- a/hibernate-core/src/test/java/org/hibernate/orm/test/constraint/NonRootTablePolymorphicTests.java
+++ b/hibernate-core/src/test/java/org/hibernate/orm/test/constraint/NonRootTablePolymorphicTests.java
@@ -84,9 +84,8 @@ public class NonRootTablePolymorphicTests {
assertThat( rootRootTable, sameInstance( rootTable ) );
assertThat( rootRootTable.getName(), is( "root" ) );
- final Iterator subclassIterator = root.getSubclassIterator();
- while ( subclassIterator.hasNext() ) {
- final JoinedSubclass subclass = (JoinedSubclass) subclassIterator.next();
+ for ( Subclass value : root.getSubclasses() ) {
+ final JoinedSubclass subclass = (JoinedSubclass) value;
final org.hibernate.mapping.Table subclassTable = subclass.getTable();
if ( subclass.getJpaEntityName().equals( "Sub" ) ) {
diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/attrorder/AttributeOrderingTests.java b/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/attrorder/AttributeOrderingTests.java
index fdd35c6804..d7648d202b 100644
--- a/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/attrorder/AttributeOrderingTests.java
+++ b/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/attrorder/AttributeOrderingTests.java
@@ -59,24 +59,22 @@ public class AttributeOrderingTests {
}
public void verifyBootModel(DomainModelScope modelScope) {
- final Consumer> alphabeticOrderChecker = (properties) -> {
+ final Consumer> alphabeticOrderChecker = properties -> {
String last = null;
while ( properties.hasNext() ) {
final String current = properties.next().getName();
- if ( last != null ) {
- assert last.compareTo( current ) < 0 : "not alphabetical : " + last + " -> " + current;
- }
+ assert last == null || last.compareTo( current ) < 0 : "not alphabetical : " + last + " -> " + current;
last = current;
}
};
modelScope.getDomainModel().getEntityBindings().forEach(
- (binding) -> alphabeticOrderChecker.accept( binding.getPropertyClosureIterator() )
+ binding -> alphabeticOrderChecker.accept( binding.getPropertyClosure().iterator() )
);
modelScope.getDomainModel().visitRegisteredComponents(
- (binding) -> alphabeticOrderChecker.accept( binding.getPropertyIterator() )
+ binding -> alphabeticOrderChecker.accept( binding.getProperties().iterator() )
);
}
diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/type/Java8DateTimeTests.java b/hibernate-core/src/test/java/org/hibernate/orm/test/type/Java8DateTimeTests.java
index fb2a75472c..5ccf1a7845 100644
--- a/hibernate-core/src/test/java/org/hibernate/orm/test/type/Java8DateTimeTests.java
+++ b/hibernate-core/src/test/java/org/hibernate/orm/test/type/Java8DateTimeTests.java
@@ -15,7 +15,6 @@ import java.time.OffsetDateTime;
import java.time.OffsetTime;
import java.time.ZonedDateTime;
import java.time.temporal.ChronoUnit;
-import java.util.Iterator;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.Id;
@@ -46,9 +45,7 @@ public class Java8DateTimeTests extends BaseNonConfigCoreFunctionalTestCase {
@Test
public void basicTests() {
final PersistentClass entityBinding = metadata().getEntityBinding( TheEntity.class.getName() );
- final Iterator propertyBindingIterator = entityBinding.getPropertyClosureIterator();
- while ( propertyBindingIterator.hasNext() ) {
- final Property propertyBinding = (Property) propertyBindingIterator.next();
+ for ( Property propertyBinding : entityBinding.getPropertyClosure() ) {
assertFalse(
"Found property bound as Serializable : " + propertyBinding.getName(),
propertyBinding.getType() instanceof SerializableType
@@ -65,7 +62,7 @@ public class Java8DateTimeTests extends BaseNonConfigCoreFunctionalTestCase {
s = openSession();
s.beginTransaction();
- theEntity = (TheEntity) s.get( TheEntity.class, 1 );
+ theEntity = s.get( TheEntity.class, 1 );
dump( entityBinding, theEntity );
assertNotNull( theEntity );
s.delete( theEntity );
@@ -74,17 +71,14 @@ public class Java8DateTimeTests extends BaseNonConfigCoreFunctionalTestCase {
}
private void dump(PersistentClass entityBinding, TheEntity theEntity) {
- final Iterator propertyBindingIterator = entityBinding.getPropertyClosureIterator();
- while ( propertyBindingIterator.hasNext() ) {
- final Property propertyBinding = (Property) propertyBindingIterator.next();
+ for ( Property propertyBinding : entityBinding.getPropertyClosure() ) {
final JavaType javaType = ( (AbstractStandardBasicType) propertyBinding.getType() ).getJavaTypeDescriptor();
-
System.out.println(
String.format(
"%s (%s) -> %s",
propertyBinding.getName(),
javaType.getJavaTypeClass().getSimpleName(),
- javaType.toString( propertyBinding.getGetter( TheEntity.class ).get( theEntity ) )
+ javaType.toString(propertyBinding.getGetter(TheEntity.class).get(theEntity))
)
);
}
diff --git a/hibernate-envers/src/main/java/org/hibernate/envers/configuration/internal/PersistentClassGraphDefiner.java b/hibernate-envers/src/main/java/org/hibernate/envers/configuration/internal/PersistentClassGraphDefiner.java
index de8823c562..58b92f4a92 100644
--- a/hibernate-envers/src/main/java/org/hibernate/envers/configuration/internal/PersistentClassGraphDefiner.java
+++ b/hibernate-envers/src/main/java/org/hibernate/envers/configuration/internal/PersistentClassGraphDefiner.java
@@ -7,7 +7,6 @@
package org.hibernate.envers.configuration.internal;
import java.util.ArrayList;
-import java.util.Iterator;
import java.util.List;
import org.hibernate.boot.spi.MetadataImplementor;
@@ -38,11 +37,10 @@ public class PersistentClassGraphDefiner implements GraphDefiner neighbours, Iterator extends PersistentClass> subclassIterator) {
- while ( subclassIterator.hasNext() ) {
- final PersistentClass subclass = subclassIterator.next();
+ private void addNeighbours(List neighbours, List extends PersistentClass> subclasses) {
+ for ( PersistentClass subclass : subclasses ) {
neighbours.add( subclass );
- addNeighbours( neighbours, subclass.getSubclassIterator() );
+ addNeighbours( neighbours, subclass.getSubclasses() );
}
}
@@ -50,7 +48,7 @@ public class PersistentClassGraphDefiner implements GraphDefiner getNeighbours(PersistentClass pc) {
final List neighbours = new ArrayList<>();
- addNeighbours( neighbours, pc.getSubclassIterator() );
+ addNeighbours( neighbours, pc.getSubclasses() );
return neighbours;
}
diff --git a/hibernate-envers/src/main/java/org/hibernate/envers/configuration/internal/metadata/CollectionMappedByResolver.java b/hibernate-envers/src/main/java/org/hibernate/envers/configuration/internal/metadata/CollectionMappedByResolver.java
index 881b9ed405..b1002cd29e 100644
--- a/hibernate-envers/src/main/java/org/hibernate/envers/configuration/internal/metadata/CollectionMappedByResolver.java
+++ b/hibernate-envers/src/main/java/org/hibernate/envers/configuration/internal/metadata/CollectionMappedByResolver.java
@@ -7,7 +7,9 @@
package org.hibernate.envers.configuration.internal.metadata;
import java.util.Iterator;
+import java.util.List;
import java.util.Locale;
+import java.util.Objects;
import org.hibernate.envers.boot.EnversMappingException;
import org.hibernate.envers.configuration.internal.metadata.reader.PropertyAuditingData;
@@ -107,9 +109,9 @@ public class CollectionMappedByResolver {
while ( assocClassProps.hasNext() ) {
final Property property = assocClassProps.next();
- final Iterator assocClassColumnIterator = property.getValue().getColumnIterator();
- final Iterator collectionKeyColumnIterator = collectionValue.getKey().getColumnIterator();
- if ( Tools.iteratorsContentEqual( assocClassColumnIterator, collectionKeyColumnIterator ) ) {
+ final List assocClassSelectables = property.getValue().getSelectables();
+ final List collectionKeySelectables = collectionValue.getKey().getSelectables();
+ if ( Objects.equals( assocClassSelectables, collectionKeySelectables ) ) {
return property.getName();
}
}
@@ -119,12 +121,11 @@ public class CollectionMappedByResolver {
}
private static String searchMappedBy(PersistentClass referencedClass, Table collectionTable) {
- return searchMappedBy( referencedClass.getPropertyIterator(), collectionTable );
+ return searchMappedBy( referencedClass.getProperties(), collectionTable );
}
- private static String searchMappedBy(Iterator properties, Table collectionTable) {
- while ( properties.hasNext() ) {
- final Property property = properties.next();
+ private static String searchMappedBy(List properties, Table collectionTable) {
+ for ( Property property : properties ) {
if ( property.getValue() instanceof Collection ) {
// The equality is intentional. We want to find a collection property with the same collection table.
//noinspection ObjectEquality
@@ -138,7 +139,7 @@ public class CollectionMappedByResolver {
// happens to be an attribute inside the embeddable rather than directly on the entity.
final Component component = (Component) property.getValue();
- final String mappedBy = searchMappedBy( component.getPropertyIterator(), collectionTable );
+ final String mappedBy = searchMappedBy( component.getProperties(), collectionTable );
if ( mappedBy != null ) {
return property.getName() + "_" + mappedBy;
}
@@ -152,12 +153,10 @@ public class CollectionMappedByResolver {
// make sure it's a 'Component' because IdClass is registered as this type.
if ( keyValue instanceof Component ) {
final Component component = (Component) keyValue;
- final Iterator componentPropertyIterator = component.getPropertyIterator();
- while ( componentPropertyIterator.hasNext() ) {
- final Property property = componentPropertyIterator.next();
- final Iterator propertySelectables = property.getValue().getColumnIterator();
- final Iterator collectionSelectables = collectionValue.getKey().getColumnIterator();
- if ( Tools.iteratorsContentEqual( propertySelectables, collectionSelectables ) ) {
+ for ( Property property : component.getProperties() ) {
+ final List propertySelectables = property.getValue().getSelectables();
+ final List collectionSelectables = collectionValue.getKey().getSelectables();
+ if ( Objects.equals( propertySelectables, collectionSelectables ) ) {
return property.getName();
}
}
diff --git a/hibernate-envers/src/main/java/org/hibernate/envers/configuration/internal/metadata/ComponentMetadataGenerator.java b/hibernate-envers/src/main/java/org/hibernate/envers/configuration/internal/metadata/ComponentMetadataGenerator.java
index bd1a9c7ae0..789b1fe5ca 100644
--- a/hibernate-envers/src/main/java/org/hibernate/envers/configuration/internal/metadata/ComponentMetadataGenerator.java
+++ b/hibernate-envers/src/main/java/org/hibernate/envers/configuration/internal/metadata/ComponentMetadataGenerator.java
@@ -6,7 +6,6 @@
*/
package org.hibernate.envers.configuration.internal.metadata;
-import java.util.Iterator;
import java.util.Map;
import org.hibernate.envers.boot.model.AttributeContainer;
@@ -50,13 +49,6 @@ public final class ComponentMetadataGenerator extends AbstractMetadataGenerator
EntityMappingData mappingData,
boolean firstPass) {
final Component propComponent = (Component) value;
- final Class extends EmbeddableInstantiator> instantiatorClass;
- if ( propComponent.getCustomInstantiator() != null ) {
- instantiatorClass = propComponent.getCustomInstantiator();
- }
- else {
- instantiatorClass = null;
- }
final EmbeddableInstantiator instantiator;
if ( propComponent.getCustomInstantiator() != null ) {
instantiator = getMetadataBuildingContext().getBootstrapContext()
@@ -94,10 +86,7 @@ public final class ComponentMetadataGenerator extends AbstractMetadataGenerator
// Adding all properties of the component
propComponent.sortProperties();
- final Iterator properties = propComponent.getPropertyIterator();
- while ( properties.hasNext() ) {
- final Property property = properties.next();
-
+ for ( Property property : propComponent.getProperties() ) {
final PropertyAuditingData componentPropertyAuditingData =
componentAuditingData.getPropertyAuditingData( property.getName() );
diff --git a/hibernate-envers/src/main/java/org/hibernate/envers/configuration/internal/metadata/IdMetadataGenerator.java b/hibernate-envers/src/main/java/org/hibernate/envers/configuration/internal/metadata/IdMetadataGenerator.java
index 7c65f06b61..2fae24b0af 100644
--- a/hibernate-envers/src/main/java/org/hibernate/envers/configuration/internal/metadata/IdMetadataGenerator.java
+++ b/hibernate-envers/src/main/java/org/hibernate/envers/configuration/internal/metadata/IdMetadataGenerator.java
@@ -6,7 +6,6 @@
*/
package org.hibernate.envers.configuration.internal.metadata;
-import java.util.Iterator;
import java.util.Locale;
import org.hibernate.envers.boot.EnversMappingException;
@@ -120,18 +119,10 @@ public final class IdMetadataGenerator extends AbstractMetadataGenerator {
SimpleIdMapperBuilder mapper,
boolean key,
boolean audited) {
- final Iterator properties = component.getPropertyIterator();
- while ( properties.hasNext() ) {
- final Property property = properties.next();
-
- final Property virtualProperty;
- if ( virtualComponent != null ) {
- virtualProperty = virtualComponent.getProperty( property.getName() );
- }
- else {
- virtualProperty = null;
- }
-
+ for ( Property property : component.getProperties() ) {
+ final Property virtualProperty = virtualComponent != null
+ ? virtualComponent.getProperty( property.getName() )
+ : null;
if ( !addIdProperty( attributeContainer, key, mapper, property, virtualProperty, audited ) ) {
// If the entity is audited, and a non-supported id component is used, throw exception.
if ( audited ) {
@@ -162,12 +153,11 @@ public final class IdMetadataGenerator extends AbstractMetadataGenerator {
}
private void generateSecondPass(String entityName, Component component) {
- Iterator properties = component.getPropertyIterator();
- while ( properties.hasNext() ) {
- final Property property = properties.next();
- if ( property.getValue() instanceof ToOne ) {
+ for ( Property property : component.getProperties() ) {
+ final Value value = property.getValue();
+ if ( value instanceof ToOne ) {
final PropertyAuditingData propertyData = getIdPersistentPropertyAuditingData( property );
- final String referencedEntityName = ( (ToOne) property.getValue() ).getReferencedEntityName();
+ final String referencedEntityName = ( (ToOne) value).getReferencedEntityName();
final String prefix = getMetadataBuildingContext().getConfiguration()
.getOriginalIdPropertyName() + "." + propertyData.getName();
diff --git a/hibernate-envers/src/main/java/org/hibernate/envers/configuration/internal/metadata/InheritanceType.java b/hibernate-envers/src/main/java/org/hibernate/envers/configuration/internal/metadata/InheritanceType.java
index f0c464b74c..52b7a18856 100644
--- a/hibernate-envers/src/main/java/org/hibernate/envers/configuration/internal/metadata/InheritanceType.java
+++ b/hibernate-envers/src/main/java/org/hibernate/envers/configuration/internal/metadata/InheritanceType.java
@@ -35,8 +35,7 @@ public enum InheritanceType {
}
// We assume that every subclass is of the same type.
- final Subclass subclass = (Subclass) superclass.getSubclassIterator().next();
-
+ final Subclass subclass = superclass.getSubclasses().get(0);
if ( subclass instanceof SingleTableSubclass ) {
return InheritanceType.SINGLE;
}
diff --git a/hibernate-envers/src/main/java/org/hibernate/envers/configuration/internal/metadata/reader/AuditedPropertiesReader.java b/hibernate-envers/src/main/java/org/hibernate/envers/configuration/internal/metadata/reader/AuditedPropertiesReader.java
index aca31bb7c9..6d8eedfd05 100644
--- a/hibernate-envers/src/main/java/org/hibernate/envers/configuration/internal/metadata/reader/AuditedPropertiesReader.java
+++ b/hibernate-envers/src/main/java/org/hibernate/envers/configuration/internal/metadata/reader/AuditedPropertiesReader.java
@@ -9,7 +9,6 @@ package org.hibernate.envers.configuration.internal.metadata.reader;
import java.lang.annotation.Annotation;
import java.util.Arrays;
import java.util.Collections;
-import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
@@ -306,12 +305,9 @@ public class AuditedPropertiesReader {
}
}
- @SuppressWarnings("unchecked")
private void createPropertiesGroupMapping(Property property) {
final Component component = (Component) property.getValue();
- final Iterator componentProperties = component.getPropertyIterator();
- while ( componentProperties.hasNext() ) {
- final Property componentProperty = componentProperties.next();
+ for ( Property componentProperty : component.getProperties() ) {
propertiesGroupMapping.put( componentProperty.getName(), property.getName() );
}
}
diff --git a/hibernate-envers/src/main/java/org/hibernate/envers/configuration/internal/metadata/reader/PersistentPropertiesSource.java b/hibernate-envers/src/main/java/org/hibernate/envers/configuration/internal/metadata/reader/PersistentPropertiesSource.java
index c9c33c5f5d..18321aedff 100644
--- a/hibernate-envers/src/main/java/org/hibernate/envers/configuration/internal/metadata/reader/PersistentPropertiesSource.java
+++ b/hibernate-envers/src/main/java/org/hibernate/envers/configuration/internal/metadata/reader/PersistentPropertiesSource.java
@@ -45,7 +45,7 @@ public interface PersistentPropertiesSource {
return new PersistentPropertiesSource() {
@Override
public Iterator getPropertyIterator() {
- return persistentClass.getPropertyIterator();
+ return persistentClass.getProperties().iterator();
}
@Override
@@ -105,7 +105,7 @@ public interface PersistentPropertiesSource {
return new PersistentPropertiesSource() {
@Override
public Iterator getPropertyIterator() {
- return component.getPropertyIterator();
+ return component.getProperties().iterator();
}
@Override
diff --git a/hibernate-envers/src/main/java/org/hibernate/envers/internal/tools/Tools.java b/hibernate-envers/src/main/java/org/hibernate/envers/internal/tools/Tools.java
index b1760cc0e9..92c72b967f 100644
--- a/hibernate-envers/src/main/java/org/hibernate/envers/internal/tools/Tools.java
+++ b/hibernate-envers/src/main/java/org/hibernate/envers/internal/tools/Tools.java
@@ -51,27 +51,10 @@ public abstract class Tools {
return (List) collection;
}
else {
- List list = new ArrayList<>();
- list.addAll( collection );
- return list;
+ return new ArrayList<>( collection );
}
}
- public static boolean iteratorsContentEqual(Iterator iter1, Iterator iter2) {
- while ( iter1.hasNext() && iter2.hasNext() ) {
- if ( !iter1.next().equals( iter2.next() ) ) {
- return false;
- }
- }
-
- //noinspection RedundantIfStatement
- if ( iter1.hasNext() || iter2.hasNext() ) {
- return false;
- }
-
- return true;
- }
-
/**
* Transforms a list of arbitrary elements to a list of index-element pairs.
*
diff --git a/hibernate-testing/src/main/java/org/hibernate/testing/junit4/BaseNonConfigCoreFunctionalTestCase.java b/hibernate-testing/src/main/java/org/hibernate/testing/junit4/BaseNonConfigCoreFunctionalTestCase.java
index b70c08d964..5fcbf00492 100644
--- a/hibernate-testing/src/main/java/org/hibernate/testing/junit4/BaseNonConfigCoreFunctionalTestCase.java
+++ b/hibernate-testing/src/main/java/org/hibernate/testing/junit4/BaseNonConfigCoreFunctionalTestCase.java
@@ -9,7 +9,6 @@ package org.hibernate.testing.junit4;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.HashMap;
-import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.Map;
@@ -342,9 +341,7 @@ public class BaseNonConfigCoreFunctionalTestCase extends BaseUnitTestCase {
boolean hasLob = false;
- final Iterator props = entityBinding.getPropertyClosureIterator();
- while ( props.hasNext() ) {
- final Property prop = (Property) props.next();
+ for ( Property prop : entityBinding.getPropertyClosure() ) {
if ( prop.getValue().isSimpleValue() ) {
if ( isLob( (SimpleValue) prop.getValue() ) ) {
hasLob = true;
diff --git a/hibernate-testing/src/main/java/org/hibernate/testing/orm/junit/BaseSessionFactoryFunctionalTest.java b/hibernate-testing/src/main/java/org/hibernate/testing/orm/junit/BaseSessionFactoryFunctionalTest.java
index 05d7b6c50a..80d91753d8 100644
--- a/hibernate-testing/src/main/java/org/hibernate/testing/orm/junit/BaseSessionFactoryFunctionalTest.java
+++ b/hibernate-testing/src/main/java/org/hibernate/testing/orm/junit/BaseSessionFactoryFunctionalTest.java
@@ -8,7 +8,6 @@ package org.hibernate.testing.orm.junit;
import java.io.IOException;
import java.io.InputStream;
-import java.util.Iterator;
import java.util.Locale;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
@@ -137,9 +136,7 @@ public abstract class BaseSessionFactoryFunctionalTest
boolean hasLob = false;
- final Iterator props = entityBinding.getPropertyClosureIterator();
- while ( props.hasNext() ) {
- final Property prop = (Property) props.next();
+ for ( Property prop : entityBinding.getPropertyClosure() ) {
if ( prop.getValue().isSimpleValue() ) {
if ( isLob( (SimpleValue) prop.getValue() ) ) {
hasLob = true;
diff --git a/hibernate-testing/src/main/java/org/hibernate/testing/orm/junit/DomainModelExtension.java b/hibernate-testing/src/main/java/org/hibernate/testing/orm/junit/DomainModelExtension.java
index fb7ebcfc98..9963179b05 100644
--- a/hibernate-testing/src/main/java/org/hibernate/testing/orm/junit/DomainModelExtension.java
+++ b/hibernate-testing/src/main/java/org/hibernate/testing/orm/junit/DomainModelExtension.java
@@ -7,7 +7,6 @@
package org.hibernate.testing.orm.junit;
import java.lang.reflect.Method;
-import java.util.Iterator;
import java.util.Locale;
import java.util.Optional;
@@ -255,32 +254,26 @@ public class DomainModelExtension
}
for ( PersistentClass entityBinding : metadata.getEntityBindings() ) {
- if ( entityBinding.isInherited() ) {
- continue;
- }
-
- boolean hasLob = false;
-
- final Iterator props = entityBinding.getPropertyClosureIterator();
- while ( props.hasNext() ) {
- final Property prop = props.next();
- if ( prop.getValue().isSimpleValue() ) {
- if ( isLob( (SimpleValue) prop.getValue() ) ) {
- hasLob = true;
- break;
+ if ( !entityBinding.isInherited() ) {
+ boolean hasLob = false;
+ for ( Property prop : entityBinding.getPropertyClosure() ) {
+ if ( prop.getValue().isSimpleValue() ) {
+ if ( isLob( (SimpleValue) prop.getValue() ) ) {
+ hasLob = true;
+ break;
+ }
}
}
- }
- if ( !hasLob ) {
- ( (RootClass) entityBinding ).setCacheConcurrencyStrategy( cacheConcurrencyStrategy );
- entityBinding.setCached( true );
+ if ( !hasLob ) {
+ ( (RootClass) entityBinding ).setCacheConcurrencyStrategy( cacheConcurrencyStrategy );
+ entityBinding.setCached( true );
+ }
}
}
for ( Collection collectionBinding : metadata.getCollectionBindings() ) {
boolean isLob = false;
-
if ( collectionBinding.getElement().isSimpleValue() ) {
isLob = isLob( (SimpleValue) collectionBinding.getElement() );
}
@@ -361,7 +354,4 @@ public class DomainModelExtension
}
}
- protected void afterMetadataBuilt(Metadata metadata) {
- }
-
}
diff --git a/tooling/hibernate-gradle-plugin/src/main/java/org/hibernate/orm/tooling/gradle/metamodel/model/JpaStaticMetamodelGenerator.java b/tooling/hibernate-gradle-plugin/src/main/java/org/hibernate/orm/tooling/gradle/metamodel/model/JpaStaticMetamodelGenerator.java
index bcd7b74559..6d63d107d0 100644
--- a/tooling/hibernate-gradle-plugin/src/main/java/org/hibernate/orm/tooling/gradle/metamodel/model/JpaStaticMetamodelGenerator.java
+++ b/tooling/hibernate-gradle-plugin/src/main/java/org/hibernate/orm/tooling/gradle/metamodel/model/JpaStaticMetamodelGenerator.java
@@ -7,16 +7,15 @@
package org.hibernate.orm.tooling.gradle.metamodel.model;
import java.io.File;
-import java.util.Collections;
+import java.util.Collection;
import java.util.HashSet;
-import java.util.Iterator;
+import java.util.List;
import java.util.Set;
import org.gradle.api.file.Directory;
import org.gradle.api.file.RegularFile;
import org.hibernate.boot.spi.MetadataImplementor;
-import org.hibernate.jpa.boot.spi.Bootstrap;
import org.hibernate.jpa.boot.spi.EntityManagerFactoryBuilder;
import org.hibernate.mapping.Component;
import org.hibernate.mapping.MappedSuperclass;
@@ -25,12 +24,13 @@ import org.hibernate.mapping.Property;
import jakarta.persistence.spi.PersistenceUnitInfo;
+import static java.util.Collections.emptyMap;
+import static org.hibernate.jpa.boot.spi.Bootstrap.getEntityManagerFactoryBuilder;
+
public class JpaStaticMetamodelGenerator {
- public static void processMetamodel(
- PersistenceUnitInfo persistenceUnitInfo,
- GenerationOptions options) {
- EntityManagerFactoryBuilder target = Bootstrap.getEntityManagerFactoryBuilder( persistenceUnitInfo, Collections.emptyMap() );
+ public static void processMetamodel(PersistenceUnitInfo persistenceUnitInfo, GenerationOptions options) {
+ final EntityManagerFactoryBuilder target = getEntityManagerFactoryBuilder( persistenceUnitInfo, emptyMap() );
try {
new JpaStaticMetamodelGenerator( options, target.metadata() ).process();
}
@@ -60,7 +60,7 @@ public class JpaStaticMetamodelGenerator {
mappedSuperclasses.forEach( this::handleMappedClass );
}
- final java.util.Collection entityBindings = metadata.getEntityBindings();
+ final Collection entityBindings = metadata.getEntityBindings();
if ( entityBindings != null ) {
entityBindings.forEach( this::handlePersistentClass );
}
@@ -68,36 +68,34 @@ public class JpaStaticMetamodelGenerator {
private void handleMappedClass(MappedSuperclass mappingDescriptor) {
final MetamodelClass metamodelClass = objectFactory.metamodelClass( mappingDescriptor );
- handleManagedClass( metamodelClass, mappingDescriptor.getDeclaredPropertyIterator() );
+ handleManagedClass( metamodelClass, mappingDescriptor.getDeclaredProperties() );
}
private void handlePersistentClass(PersistentClass persistentClass) {
final MetamodelClass metamodelClass = objectFactory.metamodelClass( persistentClass );
- handleManagedClass( metamodelClass, persistentClass.getDeclaredPropertyIterator() );
+ handleManagedClass( metamodelClass, persistentClass.getDeclaredProperties() );
}
- private void handleManagedClass(MetamodelClass metamodelClass, Iterator propertyIterator) {
- if ( ! processedDomainTypeNames.add( metamodelClass.getDomainClassName() ) ) {
- // already processed
- return;
- }
-
- propertyIterator.forEachRemaining(
- property -> metamodelClass.addAttribute(
+ private void handleManagedClass(MetamodelClass metamodelClass, List properties) {
+ if ( processedDomainTypeNames.add( metamodelClass.getDomainClassName() ) ) {
+ // not yet processed
+ for ( Property property : properties ) {
+ metamodelClass.addAttribute(
objectFactory.attribute( property, property.getValue(), metamodelClass, this::handleEmbeddable )
- )
- );
+ );
+ }
- final String replaced = metamodelClass.getMetamodelClassName().replace( '.', '/' );
- final String metamodelClassJavaFileName = replaced + ".java";
- final RegularFile metamodelClassJavaFile = generationOutputDirectory.file( metamodelClassJavaFileName );
+ final String replaced = metamodelClass.getMetamodelClassName().replace( '.', '/' );
+ final String metamodelClassJavaFileName = replaced + ".java";
+ final RegularFile metamodelClassJavaFile = generationOutputDirectory.file( metamodelClassJavaFileName );
- final File metamodelClassJavaFileAsFile = metamodelClassJavaFile.getAsFile();
- metamodelClass.writeToFile( metamodelClassJavaFileAsFile, options );
+ final File metamodelClassJavaFileAsFile = metamodelClassJavaFile.getAsFile();
+ metamodelClass.writeToFile( metamodelClassJavaFileAsFile, options );
+ }
}
private void handleEmbeddable(Component embeddedValueMapping) {
final MetamodelClass metamodelClass = objectFactory.metamodelClass( embeddedValueMapping );
- handleManagedClass( metamodelClass, embeddedValueMapping.getPropertyIterator() );
+ handleManagedClass( metamodelClass, embeddedValueMapping.getProperties() );
}
}