I checked your code locally. An interesting testing case and I spent lots of time figuring out why the result is different between running and debugging mode in IDE. Still figuring out why. However, I found you are using merge to reattach a detached entity. It seems update is more appropriate in that scenario and when I substitute its usage I found no error shows up and everything is working as expected. Maybe merge to reattach a detached entity should behave the same way in that the index should not change? That is an interesting question and I would love to dig deeper. Anyway, a good bug reporting and thanks from a community contributor. |