HHH-14305 Memory savings in SingleTableEntityPersister
This commit is contained in:
parent
d96d20b63d
commit
63f1c1b9c6
|
@ -7,6 +7,7 @@
|
||||||
package org.hibernate.metamodel.model.domain.internal;
|
package org.hibernate.metamodel.model.domain.internal;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
@ -207,6 +208,11 @@ public abstract class AbstractIdentifiableType<J>
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public void collectIdClassAttributes(Set<SingularPersistentAttribute<? super J,?>> attributes) {
|
public void collectIdClassAttributes(Set<SingularPersistentAttribute<? super J,?>> attributes) {
|
||||||
if ( idClassAttributes != null ) {
|
if ( idClassAttributes != null ) {
|
||||||
|
//Make it writeable, if it was using the EMPTY_SET marker.
|
||||||
|
// This is because there's a semantic difference in this class between a null and an empty Set.
|
||||||
|
if ( idClassAttributes == Collections.EMPTY_SET ) {
|
||||||
|
idClassAttributes = new HashSet<>();
|
||||||
|
}
|
||||||
attributes.addAll( idClassAttributes );
|
attributes.addAll( idClassAttributes );
|
||||||
}
|
}
|
||||||
else if ( getSuperType() != null ) {
|
else if ( getSuperType() != null ) {
|
||||||
|
@ -305,14 +311,19 @@ public abstract class AbstractIdentifiableType<J>
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void applyIdClassAttributes(Set<SingularPersistentAttribute<? super J,?>> idClassAttributes) {
|
public void applyIdClassAttributes(Set<SingularPersistentAttribute<? super J,?>> idClassAttributes) {
|
||||||
for ( SingularAttribute<? super J,?> idClassAttribute : idClassAttributes ) {
|
if ( idClassAttributes.isEmpty() ) {
|
||||||
if ( AbstractIdentifiableType.this == idClassAttribute.getDeclaringType() ) {
|
AbstractIdentifiableType.this.idClassAttributes = Collections.EMPTY_SET;
|
||||||
@SuppressWarnings({ "unchecked" })
|
}
|
||||||
SingularPersistentAttribute<J,?> declaredAttribute = (SingularPersistentAttribute) idClassAttribute;
|
else {
|
||||||
addAttribute( declaredAttribute );
|
for ( SingularAttribute<? super J,?> idClassAttribute : idClassAttributes ) {
|
||||||
}
|
if ( AbstractIdentifiableType.this == idClassAttribute.getDeclaringType() ) {
|
||||||
|
@SuppressWarnings({ "unchecked" })
|
||||||
|
SingularPersistentAttribute<J,?> declaredAttribute = (SingularPersistentAttribute) idClassAttribute;
|
||||||
|
addAttribute( declaredAttribute );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
AbstractIdentifiableType.this.idClassAttributes = idClassAttributes;
|
||||||
}
|
}
|
||||||
AbstractIdentifiableType.this.idClassAttributes = idClassAttributes;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -8,6 +8,7 @@ package org.hibernate.persister.entity;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
@ -277,6 +278,8 @@ public class SingleTableEntityPersister extends AbstractEntityPersister {
|
||||||
isNullableSubclassTable = ArrayHelper.toBooleanArray( isNullables );
|
isNullableSubclassTable = ArrayHelper.toBooleanArray( isNullables );
|
||||||
hasSequentialSelects = hasDeferred;
|
hasSequentialSelects = hasDeferred;
|
||||||
|
|
||||||
|
this.sequentialSelectStringsByEntityName = hasSequentialSelects ? new HashMap<>() : Collections.EMPTY_MAP;
|
||||||
|
|
||||||
// DISCRIMINATOR
|
// DISCRIMINATOR
|
||||||
|
|
||||||
if ( persistentClass.isPolymorphic() ) {
|
if ( persistentClass.isPolymorphic() ) {
|
||||||
|
|
Loading…
Reference in New Issue