Trying to execute the same query instance, it seems that it carries some state from the previous executions.
We have probably to inspect the DefaultProjectionHitMapper behavior.
Probably it needs to be stateless or we need to change the method *.loading.context.spi.LoadingContext#getProjectionHitMapper into createProjectionHitMapper.
We need a test case for it maybe on *.mapper.orm.search.loading.AbstractSearchQueryEntityLoadingIT.
Having that working will allow us to reuse (to cache) the query instances within the same thread.
Good catch, thanks.
DefaultProjectionHitMapper can't be stateless because its purpose is to hold a mutable list of references to load. We need to turn getProjectionHitMapper into a factory method, or to make sure DefaultProjectionHitMapper clears it state after loading.
I think the first solution is more robust as it will work even if a search query fails after having added references to the hit mapper but before loading entities.