When using Hibernate ORM multi-tenancy and `Session.merge()` on a child entity of one marked with `@Indexed`, the tenant information is lost in the Lucene index, making the `@Indexed` entity not appear in search results.
This seems to happen when the entity being merged has a collection of entities with a newly added child in it. If the merged entity's child collection has not changed or if it has children removed, the tenant information in the Lucene index seems preserved.
I've created a test case here (it could probably be even simpler):
A work-around would be appreciated (or a pointer to what is wrong with the use case).
The corresponding SO post:
Hibernate 5.2.13.Final and 5.4.1.Final
H2 and PostgreSQL