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;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.function.Consumer;
|
||||
|
@ -207,6 +208,11 @@ public abstract class AbstractIdentifiableType<J>
|
|||
@SuppressWarnings("unchecked")
|
||||
public void collectIdClassAttributes(Set<SingularPersistentAttribute<? super J,?>> attributes) {
|
||||
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 );
|
||||
}
|
||||
else if ( getSuperType() != null ) {
|
||||
|
@ -305,6 +311,10 @@ public abstract class AbstractIdentifiableType<J>
|
|||
|
||||
@Override
|
||||
public void applyIdClassAttributes(Set<SingularPersistentAttribute<? super J,?>> idClassAttributes) {
|
||||
if ( idClassAttributes.isEmpty() ) {
|
||||
AbstractIdentifiableType.this.idClassAttributes = Collections.EMPTY_SET;
|
||||
}
|
||||
else {
|
||||
for ( SingularAttribute<? super J,?> idClassAttribute : idClassAttributes ) {
|
||||
if ( AbstractIdentifiableType.this == idClassAttribute.getDeclaringType() ) {
|
||||
@SuppressWarnings({ "unchecked" })
|
||||
|
@ -314,6 +324,7 @@ public abstract class AbstractIdentifiableType<J>
|
|||
}
|
||||
AbstractIdentifiableType.this.idClassAttributes = idClassAttributes;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
|
|
|
@ -8,6 +8,7 @@ package org.hibernate.persister.entity;
|
|||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
|
@ -277,6 +278,8 @@ public class SingleTableEntityPersister extends AbstractEntityPersister {
|
|||
isNullableSubclassTable = ArrayHelper.toBooleanArray( isNullables );
|
||||
hasSequentialSelects = hasDeferred;
|
||||
|
||||
this.sequentialSelectStringsByEntityName = hasSequentialSelects ? new HashMap<>() : Collections.EMPTY_MAP;
|
||||
|
||||
// DISCRIMINATOR
|
||||
|
||||
if ( persistentClass.isPolymorphic() ) {
|
||||
|
|
Loading…
Reference in New Issue