Have an Entity with a lazy loaded list
Load the Entity in a transaction and initialize the list
Close transaction and save the reference to detached object
Merge the object in a new transaction and do not touch the collection
OrderColumn will be updated after commit of second transaction
I belive the problem is in OneToManyPersister and org.hibernate.collection.internal.PersistentList.Clear (Persister seems to shift items when a clear operation is queued)
Windows 8 64
Since I am new here and did not contribute to hibernate projects before, it would be great if somebody could confirm that this is not an expected behavior and if it is, I can investigate this further and confirm the cause of the problem.
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.
Given that update is more appropriate and it is working fine, I think we can lower the severity of this ticket for you are exploring the limit, not the canonical feature.