squash warnings + remove usages of some deprecated methods
This commit is contained in:
parent
ce860e31ff
commit
6e8d609485
|
@ -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
|
||||
*
|
||||
|
|
|
@ -225,7 +225,7 @@ public class ClassPropertyHolder extends AbstractPropertyHolder {
|
|||
);
|
||||
}
|
||||
if ( inheritanceState.isEmbeddableSuperclass() ) {
|
||||
persistentClass.addMappedsuperclassProperty(prop);
|
||||
persistentClass.addMappedSuperclassProperty( prop );
|
||||
addPropertyToMappedSuperclass( prop, declaringClass );
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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.
|
||||
* <p/>
|
||||
* For example, with a batch-size setting of 32 the pre-built batch sizes would be [32, 16, 10, 9, 8, 7, .., 1].
|
||||
|
|
|
@ -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<Property> 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<Property> properties = new ArrayList<>();
|
||||
private int[] originalPropertyOrder = ArrayHelper.EMPTY_INT_ARRAY;
|
||||
private Map<String,MetaAttribute> 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<Selectable> cachedSelectables;
|
||||
private transient List<Selectable> cachedSelectables;
|
||||
// lazily computed based on 'properties' field: invalidate by setting to null when properties are modified
|
||||
private List<Column> cachedColumns;
|
||||
private transient List<Column> 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<Property> 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<Selectable> getColumnIterator() {
|
||||
@SuppressWarnings("unchecked")
|
||||
Iterator<Selectable>[] iters = new Iterator[ getPropertySpan() ];
|
||||
|
@ -157,15 +163,12 @@ public class Component extends SimpleValue implements MetaAttributable, Sortable
|
|||
|
||||
@Override
|
||||
public List<Selectable> 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<String, MetaAttribute> 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<String, MetaAttribute> 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<Column> 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 );
|
||||
}
|
||||
|
|
|
@ -159,7 +159,7 @@ public abstract class Constraint implements RelationalModel, Exportable, Seriali
|
|||
|
||||
@Deprecated(since = "6.0")
|
||||
public Iterator<Column> getColumnIterator() {
|
||||
return columns.iterator();
|
||||
return getColumns().iterator();
|
||||
}
|
||||
|
||||
public Table getTable() {
|
||||
|
|
|
@ -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<Column> columns = new ArrayList<>();
|
||||
private java.util.Map<Column, String> columnOrderMap = new HashMap<>( );
|
||||
private Identifier name;
|
||||
private Table table;
|
||||
private final java.util.List<Column> columns = new ArrayList<>();
|
||||
private final java.util.Map<Column, String> columnOrderMap = new HashMap<>( );
|
||||
|
||||
@Override
|
||||
public String sqlCreateString(Mapping mapping, SqlStringGenerationContext context, String defaultCatalog,
|
||||
|
|
|
@ -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<Property> getReferenceablePropertyIterator() {
|
||||
return getPropertyIterator();
|
||||
}
|
||||
|
|
|
@ -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<String, MetaAttribute> getMetaAttributes();
|
||||
|
||||
void setMetaAttributes(java.util.Map metas);
|
||||
void setMetaAttributes(Map<String, MetaAttribute> metas);
|
||||
|
||||
MetaAttribute getMetaAttribute(String name);
|
||||
|
||||
|
|
|
@ -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<String> 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<String> 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() {
|
||||
|
|
|
@ -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<Property> properties = new ArrayList<>();
|
||||
private final java.util.List<Property> declaredProperties = new ArrayList<>();
|
||||
private final java.util.List<Subclass> subclasses = new ArrayList<>();
|
||||
private final java.util.List<Property> subclassProperties = new ArrayList<>();
|
||||
private final java.util.List<Table> subclassTables = new ArrayList<>();
|
||||
private final List<Property> properties = new ArrayList<>();
|
||||
private final List<Property> declaredProperties = new ArrayList<>();
|
||||
private final List<Subclass> subclasses = new ArrayList<>();
|
||||
private final List<Property> subclassProperties = new ArrayList<>();
|
||||
private final List<Table> 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<Join> joins = new ArrayList<>();
|
||||
private final java.util.List<Join> subclassJoins = new ArrayList<>();
|
||||
private final java.util.List<FilterConfiguration> filters = new ArrayList<>();
|
||||
private java.util.Map<String, MetaAttribute> metaAttributes;
|
||||
private final List<Join> joins = new ArrayList<>();
|
||||
private final List<Join> subclassJoins = new ArrayList<>();
|
||||
private final List<FilterConfiguration> filters = new ArrayList<>();
|
||||
protected final Set<String> synchronizedTables = new HashSet<>();
|
||||
private String loaderName;
|
||||
private Boolean isAbstract;
|
||||
private boolean hasSubselectLoadableCollections;
|
||||
private Component identifierMapper;
|
||||
private java.util.List<CallbackDefinition> callbackDefinitions;
|
||||
private List<CallbackDefinition> 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<Subclass> getSubclasses() {
|
||||
@SuppressWarnings("unchecked")
|
||||
List<Subclass>[] iters = new List[subclasses.size() + 1];
|
||||
int i = 0;
|
||||
for ( Subclass subclass : subclasses ) {
|
||||
iters[i++] = subclass.getSubclasses();
|
||||
List<Subclass>[] 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<Subclass> getSubclassIterator() {
|
||||
@SuppressWarnings("unchecked")
|
||||
Iterator<Subclass>[] iters = new Iterator[subclasses.size() + 1];
|
||||
Iterator<Subclass> iter = subclasses.iterator();
|
||||
final Iterator<Subclass>[] iters = new Iterator[subclasses.size() + 1];
|
||||
final Iterator<Subclass> 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<PersistentClass> getSubclassClosure() {
|
||||
ArrayList<List<PersistentClass>> lists = new ArrayList<>();
|
||||
final ArrayList<List<PersistentClass>> 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<PersistentClass> getSubclassClosureIterator() {
|
||||
ArrayList<Iterator<PersistentClass>> iters = new ArrayList<>();
|
||||
final ArrayList<Iterator<PersistentClass>> 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<Property> getPropertyClosure();
|
||||
|
||||
@Deprecated(since = "6.0")
|
||||
@Deprecated(since = "6.0") @Remove
|
||||
public abstract Iterator<Property> getPropertyClosureIterator();
|
||||
|
||||
public abstract List<Table> getTableClosure();
|
||||
|
||||
@Deprecated(since = "6.0")
|
||||
@Deprecated(since = "6.0") @Remove
|
||||
public abstract Iterator<Table> getTableClosureIterator();
|
||||
|
||||
public abstract List<KeyValue> getKeyClosure();
|
||||
|
||||
@Deprecated(since = "6.0")
|
||||
@Deprecated(since = "6.0") @Remove
|
||||
public abstract Iterator<KeyValue> 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<Property> getSubclassPropertyClosureIterator() {
|
||||
ArrayList<Iterator<Property>> iters = new ArrayList<>();
|
||||
final ArrayList<Iterator<Property>> 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<Property> getSubclassPropertyClosure() {
|
||||
ArrayList<List<Property>> lists = new ArrayList<>();
|
||||
final ArrayList<List<Property>> 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<Join> 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<Table> 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<Property> getReferenceablePropertyIterator() {
|
||||
return getPropertyClosureIterator();
|
||||
}
|
||||
|
@ -638,10 +646,8 @@ public abstract class PersistentClass implements AttributeContainer, Serializabl
|
|||
return true;
|
||||
}
|
||||
|
||||
final Iterator<Property> 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<String> names = new HashSet<>();
|
||||
final HashSet<String> 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<String, MetaAttribute> getMetaAttributes() {
|
||||
return metaAttributes;
|
||||
}
|
||||
|
||||
public void setMetaAttributes(java.util.Map metas) {
|
||||
public void setMetaAttributes(java.util.Map<String,MetaAttribute> 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
|
||||
|
@ -819,7 +823,7 @@ public abstract class PersistentClass implements AttributeContainer, Serializabl
|
|||
*/
|
||||
@Deprecated(since = "6.0")
|
||||
public Iterator<Property> getPropertyIterator() {
|
||||
ArrayList<Iterator<Property>> iterators = new ArrayList<>();
|
||||
final ArrayList<Iterator<Property>> 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).
|
||||
* <p/>
|
||||
* Differs from {@link #getUnjoinedProperties} in that the returned iterator
|
||||
* will include properties defined as part of a join.
|
||||
* <p/>
|
||||
* 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<Property> getProperties() {
|
||||
ArrayList<List<Property>> list = new ArrayList<>();
|
||||
final ArrayList<List<Property>> list = new ArrayList<>();
|
||||
list.add( properties );
|
||||
for (Join join : joins) {
|
||||
list.add( join.getProperties() );
|
||||
|
@ -997,12 +1014,10 @@ public abstract class PersistentClass implements AttributeContainer, Serializabl
|
|||
|
||||
protected void checkColumnDuplication(Set<String> distinctColumns, Value value)
|
||||
throws MappingException {
|
||||
if (value == null) {
|
||||
return;
|
||||
}
|
||||
if ( value != null ) {
|
||||
for ( Selectable columnOrFormula : value.getSelectables() ) {
|
||||
if ( !columnOrFormula.isFormula() ) {
|
||||
Column col = (Column) columnOrFormula;
|
||||
final Column col = (Column) columnOrFormula;
|
||||
if ( !distinctColumns.add( col.getName() ) ) {
|
||||
throw new MappingException(
|
||||
"Column '" + col.getName()
|
||||
|
@ -1013,6 +1028,7 @@ public abstract class PersistentClass implements AttributeContainer, Serializabl
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void checkPropertyColumnDuplication(Set<String> distinctColumns, List<Property> properties)
|
||||
throws MappingException {
|
||||
|
@ -1045,7 +1061,7 @@ public abstract class PersistentClass implements AttributeContainer, Serializabl
|
|||
}
|
||||
|
||||
protected void checkColumnDuplication() {
|
||||
HashSet<String> cols = new HashSet<>();
|
||||
final HashSet<String> 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 );
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -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<String, MetaAttribute> 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<String, MetaAttribute> metas) {
|
||||
this.metaAttributes = metas;
|
||||
}
|
||||
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -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<Property> 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<Selectable> 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()
|
||||
|
|
|
@ -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<Join> 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();
|
||||
|
|
|
@ -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<Column> iter = columns.values().iterator();
|
||||
final Iterator<Column> 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<Column> getColumnIterator() {
|
||||
return columns.values().iterator();
|
||||
return getColumns().iterator();
|
||||
}
|
||||
|
||||
public Collection<Column> getColumns() {
|
||||
return columns.values();
|
||||
}
|
||||
|
||||
@Deprecated(since = "6.2")
|
||||
public Iterator<Index> getIndexIterator() {
|
||||
return indexes.values().iterator();
|
||||
return getIndexes().values().iterator();
|
||||
}
|
||||
|
||||
public Map<String, Index> getIndexes() {
|
||||
return unmodifiableMap( indexes );
|
||||
}
|
||||
|
||||
@Deprecated(since = "6.0")
|
||||
public Iterator<ForeignKey> getForeignKeyIterator() {
|
||||
return foreignKeys.values().iterator();
|
||||
return getForeignKeys().values().iterator();
|
||||
}
|
||||
|
||||
public Map<ForeignKeyKey, ForeignKey> 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<String, UniqueKey> 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<String> getCheckConstraintsIterator() {
|
||||
return checkConstraints.iterator();
|
||||
return getCheckConstraints().iterator();
|
||||
}
|
||||
|
||||
public List<String> getCheckConstraints() {
|
||||
return checkConstraints;
|
||||
return unmodifiableList( checkConstraints );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -900,7 +903,7 @@ public class Table implements RelationalModel, Serializable, ContributableDataba
|
|||
for ( Function<SqlStringGenerationContext, InitCommand> producer : initCommandProducers ) {
|
||||
initCommands.add( producer.apply( context ) );
|
||||
}
|
||||
return Collections.unmodifiableList( initCommands );
|
||||
return unmodifiableList( initCommands );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<Property> getNonDuplicatedPropertyIterator() {
|
||||
return getPropertyClosureIterator();
|
||||
}
|
||||
|
@ -47,18 +44,6 @@ public class UnionSubclass extends Subclass implements TableOwner {
|
|||
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();
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ import org.hibernate.internal.util.StringHelper;
|
|||
* @author Brett Meyer
|
||||
*/
|
||||
public class UniqueKey extends Constraint {
|
||||
private Map<Column, String> columnOrderMap = new HashMap<>();
|
||||
private final Map<Column, String> columnOrderMap = new HashMap<>();
|
||||
|
||||
@Override
|
||||
public String sqlConstraintString(
|
||||
|
|
|
@ -51,20 +51,12 @@ public class EntityRepresentationStrategyMap implements EntityRepresentationStra
|
|||
this.proxyFactory = createProxyFactory( bootType );
|
||||
this.instantiator = new EntityInstantiatorDynamicMap( bootType );
|
||||
|
||||
//noinspection unchecked
|
||||
final Iterator<Property> 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 );
|
||||
|
|
|
@ -308,22 +308,20 @@ public class EntityRepresentationStrategyPojoStandard implements EntityRepresent
|
|||
|
||||
boolean foundCustomAccessor = false;
|
||||
|
||||
final Iterator<Property> 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() ) {
|
||||
|
|
|
@ -237,14 +237,11 @@ public class ToOneAttributeMapping
|
|||
}
|
||||
// Simple one-to-one mapped by cases
|
||||
if ( bidirectionalAttributeName == null ) {
|
||||
//noinspection deprecation
|
||||
final Iterator<Property> 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<Property> 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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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<String, String[]> 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<String> spaces = new HashSet<String>();
|
||||
final HashSet<String> spaces = new HashSet<>();
|
||||
collectQuerySpaces( spaces );
|
||||
return spaces.toArray( new String[ spaces.size() ] );
|
||||
return spaces.toArray( EMPTY_STRING_ARRAY );
|
||||
}
|
||||
|
||||
public void collectQuerySpaces(Collection<String> spaces) {
|
||||
|
|
|
@ -84,9 +84,8 @@ public class NonRootTablePolymorphicTests {
|
|||
assertThat( rootRootTable, sameInstance( rootTable ) );
|
||||
assertThat( rootRootTable.getName(), is( "root" ) );
|
||||
|
||||
final Iterator<Subclass> 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" ) ) {
|
||||
|
|
|
@ -59,24 +59,22 @@ public class AttributeOrderingTests {
|
|||
}
|
||||
|
||||
public void verifyBootModel(DomainModelScope modelScope) {
|
||||
final Consumer<Iterator<Property>> alphabeticOrderChecker = (properties) -> {
|
||||
final Consumer<Iterator<Property>> 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() )
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -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))
|
||||
)
|
||||
);
|
||||
}
|
||||
|
|
|
@ -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<PersistentClass
|
|||
return metadata.getEntityBinding( entityName );
|
||||
}
|
||||
|
||||
private void addNeighbours(List<PersistentClass> neighbours, Iterator<? extends PersistentClass> subclassIterator) {
|
||||
while ( subclassIterator.hasNext() ) {
|
||||
final PersistentClass subclass = subclassIterator.next();
|
||||
private void addNeighbours(List<PersistentClass> 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<PersistentClass
|
|||
public List<PersistentClass> getNeighbours(PersistentClass pc) {
|
||||
final List<PersistentClass> neighbours = new ArrayList<>();
|
||||
|
||||
addNeighbours( neighbours, pc.getSubclassIterator() );
|
||||
addNeighbours( neighbours, pc.getSubclasses() );
|
||||
|
||||
return neighbours;
|
||||
}
|
||||
|
|
|
@ -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<Selectable> assocClassColumnIterator = property.getValue().getColumnIterator();
|
||||
final Iterator<Selectable> collectionKeyColumnIterator = collectionValue.getKey().getColumnIterator();
|
||||
if ( Tools.iteratorsContentEqual( assocClassColumnIterator, collectionKeyColumnIterator ) ) {
|
||||
final List<Selectable> assocClassSelectables = property.getValue().getSelectables();
|
||||
final List<Selectable> 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<Property> properties, Table collectionTable) {
|
||||
while ( properties.hasNext() ) {
|
||||
final Property property = properties.next();
|
||||
private static String searchMappedBy(List<Property> 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<Property> componentPropertyIterator = component.getPropertyIterator();
|
||||
while ( componentPropertyIterator.hasNext() ) {
|
||||
final Property property = componentPropertyIterator.next();
|
||||
final Iterator<Selectable> propertySelectables = property.getValue().getColumnIterator();
|
||||
final Iterator<Selectable> collectionSelectables = collectionValue.getKey().getColumnIterator();
|
||||
if ( Tools.iteratorsContentEqual( propertySelectables, collectionSelectables ) ) {
|
||||
for ( Property property : component.getProperties() ) {
|
||||
final List<Selectable> propertySelectables = property.getValue().getSelectables();
|
||||
final List<Selectable> collectionSelectables = collectionValue.getKey().getSelectables();
|
||||
if ( Objects.equals( propertySelectables, collectionSelectables ) ) {
|
||||
return property.getName();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<Property> properties = propComponent.getPropertyIterator();
|
||||
while ( properties.hasNext() ) {
|
||||
final Property property = properties.next();
|
||||
|
||||
for ( Property property : propComponent.getProperties() ) {
|
||||
final PropertyAuditingData componentPropertyAuditingData =
|
||||
componentAuditingData.getPropertyAuditingData( property.getName() );
|
||||
|
||||
|
|
|
@ -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<Property> 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<Property> 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();
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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<Property> componentProperties = component.getPropertyIterator();
|
||||
while ( componentProperties.hasNext() ) {
|
||||
final Property componentProperty = componentProperties.next();
|
||||
for ( Property componentProperty : component.getProperties() ) {
|
||||
propertiesGroupMapping.put( componentProperty.getName(), property.getName() );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -45,7 +45,7 @@ public interface PersistentPropertiesSource {
|
|||
return new PersistentPropertiesSource() {
|
||||
@Override
|
||||
public Iterator<Property> getPropertyIterator() {
|
||||
return persistentClass.getPropertyIterator();
|
||||
return persistentClass.getProperties().iterator();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -105,7 +105,7 @@ public interface PersistentPropertiesSource {
|
|||
return new PersistentPropertiesSource() {
|
||||
@Override
|
||||
public Iterator<Property> getPropertyIterator() {
|
||||
return component.getPropertyIterator();
|
||||
return component.getProperties().iterator();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -51,27 +51,10 @@ public abstract class Tools {
|
|||
return (List<X>) collection;
|
||||
}
|
||||
else {
|
||||
List<X> 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.
|
||||
*
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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,15 +254,9 @@ public class DomainModelExtension
|
|||
}
|
||||
|
||||
for ( PersistentClass entityBinding : metadata.getEntityBindings() ) {
|
||||
if ( entityBinding.isInherited() ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( !entityBinding.isInherited() ) {
|
||||
boolean hasLob = false;
|
||||
|
||||
final Iterator<Property> props = entityBinding.getPropertyClosureIterator();
|
||||
while ( props.hasNext() ) {
|
||||
final Property prop = props.next();
|
||||
for ( Property prop : entityBinding.getPropertyClosure() ) {
|
||||
if ( prop.getValue().isSimpleValue() ) {
|
||||
if ( isLob( (SimpleValue) prop.getValue() ) ) {
|
||||
hasLob = true;
|
||||
|
@ -277,10 +270,10 @@ public class DomainModelExtension
|
|||
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) {
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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<PersistentClass> entityBindings = metadata.getEntityBindings();
|
||||
final Collection<PersistentClass> entityBindings = metadata.getEntityBindings();
|
||||
if ( entityBindings != null ) {
|
||||
entityBindings.forEach( this::handlePersistentClass );
|
||||
}
|
||||
|
@ -68,25 +68,22 @@ 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<Property> propertyIterator) {
|
||||
if ( ! processedDomainTypeNames.add( metamodelClass.getDomainClassName() ) ) {
|
||||
// already processed
|
||||
return;
|
||||
}
|
||||
|
||||
propertyIterator.forEachRemaining(
|
||||
property -> metamodelClass.addAttribute(
|
||||
private void handleManagedClass(MetamodelClass metamodelClass, List<Property> 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";
|
||||
|
@ -95,9 +92,10 @@ public class JpaStaticMetamodelGenerator {
|
|||
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() );
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue