InstanceInitializer instanceInitializer = objectInitializationContext.getSearchFactoryImplementor()
.getInstanceInitializer();
for ( Object o : queryResultList ) {
Class<?> loadedType = instanceInitializer.getClass( o );
Object unproxiedObject = instanceInitializer.unproxy( o );
DocumentBuilderIndexedEntity documentBuilder = getDocumentBuilder(
loadedType,
objectInitializationContext.getSearchFactoryImplementor()
);
if ( documentBuilder == null ) {
// the query result can contain entities which are not indexed. This can for example happen if
// the targeted entity type is a superclass with indexed and un-indexed sub classes
// entities which don't have an document builder can be ignores (HF)
continue;
}
XMember idProperty = documentBuilder.getIdGetter();
Object id = ReflectionHelper.getMemberValue( unproxiedObject, idProperty );
EntityInfoLoadKey key = new EntityInfoLoadKey( loadedType, id );
Object previousValue = idToObjectMap.put( key, unproxiedObject );
if ( previousValue == null ) {
throw new AssertionFailure( "An entity got loaded even though it was not part of the EntityInfo list" );