HHH-15633 Intern entity name to improve EntityKey#equals

This commit is contained in:
Christian Beikov 2022-10-26 14:02:43 +02:00
parent 0561839140
commit ec72bab0a9
2 changed files with 4 additions and 4 deletions

View File

@ -10,7 +10,6 @@ import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.util.Objects;
import org.hibernate.AssertionFailure;
import org.hibernate.persister.entity.EntityPersister;
@ -103,7 +102,7 @@ public final class EntityKey implements Serializable {
private boolean samePersistentType(final EntityKey otherKey) {
return otherKey.persister == persister
|| Objects.equals( otherKey.persister.getRootEntityName(), persister.getRootEntityName() );
|| otherKey.persister.getRootEntityName().equals( persister.getRootEntityName() );
}
@Override

View File

@ -147,8 +147,9 @@ public class EntityMetamodel implements Serializable {
RuntimeModelCreationContext creationContext) {
this.sessionFactory = creationContext.getSessionFactory();
name = persistentClass.getEntityName();
rootName = persistentClass.getRootClass().getEntityName();
// Improves performance of EntityKey#equals by avoiding content check in String#equals
name = persistentClass.getEntityName().intern();
rootName = persistentClass.getRootClass().getEntityName().intern();
identifierAttribute = PropertyFactory.buildIdentifierAttribute(
persistentClass,