HHH-18358 - Fixed infinte recursion in MockEntityPersister.getRootEntityName;

Fixed MockSessionFactory.managedType;
	    ProcessorSessionFactory.qualifyName should return entityClass.getQualifiedName, not entityClass.getSimpleName
This commit is contained in:
Čedomir Igaly 2024-07-13 11:43:52 +02:00 committed by Gavin King
parent 7862b0700a
commit b3eea24e0c
3 changed files with 12 additions and 13 deletions

View File

@ -66,6 +66,8 @@ public abstract class MockEntityPersister implements EntityPersister, Joinable,
.orElse(null);
}
abstract boolean isSamePersister(MockEntityPersister entityPersister);
abstract boolean isSubclassPersister(MockEntityPersister entityPersister);
@Override
@ -126,7 +128,8 @@ public abstract class MockEntityPersister implements EntityPersister, Joinable,
@Override
public String getRootEntityName() {
for (MockEntityPersister persister : factory.getMockEntityPersisters()) {
if (this != persister && persister.isSubclassPersister(this)) {
if (this != persister && !persister.isSamePersister(this)
&& persister.isSubclassPersister(this)) {
return persister.getRootEntityName();
}
}

View File

@ -809,7 +809,7 @@ public abstract class MockSessionFactory
@Override
public <X> ManagedDomainType<X> managedType(String typeName) {
final String entityName = findEntityName( typeName );
final String entityName = qualifyName( typeName );
//noinspection unchecked
return entityName == null ? null : (ManagedDomainType<X>) entity( entityName );
}

View File

@ -366,6 +366,12 @@ public abstract class ProcessorSessionFactory extends MockSessionFactory {
initSubclassPersisters();
}
@Override
boolean isSamePersister(MockEntityPersister entityPersister) {
EntityPersister persister = (EntityPersister) entityPersister;
return typeUtil.isSameType( persister.type.asType(), type.asType() );
}
@Override
boolean isSubclassPersister(MockEntityPersister entityPersister) {
EntityPersister persister = (EntityPersister) entityPersister;
@ -425,20 +431,10 @@ public abstract class ProcessorSessionFactory extends MockSessionFactory {
return findEntityClass(entityName) != null;
}
@Override
String findEntityName(String typeName) {
for ( final Map.Entry<String, String> e : entityNameMappings.entrySet() ) {
if ( typeName.equals( e.getKey() ) || typeName.equals( e.getValue() ) ) {
return e.getKey();
}
}
return null;
}
@Override
String qualifyName(String entityName) {
TypeElement entityClass = findEntityClass(entityName);
return entityClass == null ? null : entityClass.getSimpleName().toString();
return entityClass == null ? null : entityClass.getQualifiedName().toString();
}
@Override