Note the problem described in the issue description:
At the end of the transaction, however, the indexer tries to load the status and status texts that are referenced by the articles, which due to the flush and clear operations results in lazy initialization exceptions (the articles that are to be indexed are not attached to the session anymore).
… is no longer relevant in Hibernate Search 6: https://docs.jboss.org/hibernate/stable/search/reference/en-US/html_single/#mapper-orm-indexing-manual-indexingplan-process-execute
With Hibernate Search 6 (on contrary to Hibernate Search 5 and earlier), this pattern will work as expected:
The use case remains, though: when someone uses a session for bulk imports, they will probably want to disable automatic indexing in that session and perform mass indexing later. |