Hello, recently we started to work with the @OrderColumn feature and found out that by using this the entityManager is creating a lot of update queries where it would not be necessary to have them. Let's take this example:
We run the following code:
And we can see this output in the logs:
Why does hibernate need to set the position using a separate query, getting the position is very straightforward (basically just an indexOf on the bag). So why do we have two requests, a first insert with the position set to 0, and then an update to set the right position? In that case it’s not that important, but we end up having performances slowed because of this when saving a lot of entities. |