in a Spring boot 3 project, I am using Hibernate search 6.1.8Final for data indexing in an Elasticserach backend. I added a typeBinder bridge to index a calculated value. In the calculation method I make a select on the database with a JPARepository. I encountered an exception a few times when modifying the object but after that the error disappeared and I don't know if it will be random. Knowing that the exception is not blocking for persistence in the database and updating the index. exception text: org.springframework.transaction.TransactionSystemException: Could not commit JPA transaction] with root cause org.hibernate.search.util.common.SearchException: HSEARCH700060: Unable to trigger entity processing while already processing entities. Make sure you do not change entities within an entity getter or a custom bridge used for indexing, and avoid any event that could trigger entity processing. Hibernate ORM flushes, in particular, must be avoided in entity getters and bridges.
In fact, after updating an indexed object, on-going reindexing is launched. the exception is triggered when the Bridge is called and more precisely when the repository is called. I would like to understand the cause of this error but I have found almost nothing on the subject.
Thanks for your help.
Thank you very much for your answer.
I found the solution, by looking more closely in the hibernate search calls. In fact, my call to the repository (which is a simple find with no action on the database) in my bridge calls a native query and there I have the execution of the flush. By changing to an HQL query, there is no longer a problem. I think that the fact that the request is native and that hibernate serach will be in this way it does not know what it does, it automatically launches a flush. When I go to an HQL query, it has the commands and it knows that it's just a get so it doesn't do a flush? On the other hand, what I found strange was that at a given moment the error was random.
Thank you.