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:
parent
7862b0700a
commit
b3eea24e0c
|
@ -66,6 +66,8 @@ public abstract class MockEntityPersister implements EntityPersister, Joinable,
|
||||||
.orElse(null);
|
.orElse(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
abstract boolean isSamePersister(MockEntityPersister entityPersister);
|
||||||
|
|
||||||
abstract boolean isSubclassPersister(MockEntityPersister entityPersister);
|
abstract boolean isSubclassPersister(MockEntityPersister entityPersister);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -126,7 +128,8 @@ public abstract class MockEntityPersister implements EntityPersister, Joinable,
|
||||||
@Override
|
@Override
|
||||||
public String getRootEntityName() {
|
public String getRootEntityName() {
|
||||||
for (MockEntityPersister persister : factory.getMockEntityPersisters()) {
|
for (MockEntityPersister persister : factory.getMockEntityPersisters()) {
|
||||||
if (this != persister && persister.isSubclassPersister(this)) {
|
if (this != persister && !persister.isSamePersister(this)
|
||||||
|
&& persister.isSubclassPersister(this)) {
|
||||||
return persister.getRootEntityName();
|
return persister.getRootEntityName();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -809,7 +809,7 @@ public abstract class MockSessionFactory
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <X> ManagedDomainType<X> managedType(String typeName) {
|
public <X> ManagedDomainType<X> managedType(String typeName) {
|
||||||
final String entityName = findEntityName( typeName );
|
final String entityName = qualifyName( typeName );
|
||||||
//noinspection unchecked
|
//noinspection unchecked
|
||||||
return entityName == null ? null : (ManagedDomainType<X>) entity( entityName );
|
return entityName == null ? null : (ManagedDomainType<X>) entity( entityName );
|
||||||
}
|
}
|
||||||
|
|
|
@ -366,6 +366,12 @@ public abstract class ProcessorSessionFactory extends MockSessionFactory {
|
||||||
initSubclassPersisters();
|
initSubclassPersisters();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
boolean isSamePersister(MockEntityPersister entityPersister) {
|
||||||
|
EntityPersister persister = (EntityPersister) entityPersister;
|
||||||
|
return typeUtil.isSameType( persister.type.asType(), type.asType() );
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
boolean isSubclassPersister(MockEntityPersister entityPersister) {
|
boolean isSubclassPersister(MockEntityPersister entityPersister) {
|
||||||
EntityPersister persister = (EntityPersister) entityPersister;
|
EntityPersister persister = (EntityPersister) entityPersister;
|
||||||
|
@ -425,20 +431,10 @@ public abstract class ProcessorSessionFactory extends MockSessionFactory {
|
||||||
return findEntityClass(entityName) != null;
|
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
|
@Override
|
||||||
String qualifyName(String entityName) {
|
String qualifyName(String entityName) {
|
||||||
TypeElement entityClass = findEntityClass(entityName);
|
TypeElement entityClass = findEntityClass(entityName);
|
||||||
return entityClass == null ? null : entityClass.getSimpleName().toString();
|
return entityClass == null ? null : entityClass.getQualifiedName().toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in New Issue