I have a table that uses the insertion order (a bad obsolete design that I cannot change) and has temporary objects inserted in the wrong order. This table is called Medium, which is a child of Faith. When session.save(belief); is called session.save(belief); , the action is cascaded to child mediums, which are stored as a list in the belief class. Medium objects are stored in the appropriate order in the .getMeans () belief list, but after they are saved to the database, they are inserted in the order of their composite key. for example, if there are 3 medium objects that need to be inserted with the following order and compound keys:
[1, 1], [1, 3], [1, 2]
They will be inserted by ordered composite keys like this:
[1, 1], [1, 2], [1, 3]
Any idea as to what could be causing this? I thought that Hibernate should have inserted according to the order that they display on the List? I even tried running session.save () for each Medium entity individually, to find out if this would change, but it is not.
I appreciate your help!
EDIT: So, what I ended up doing is adding a new column to the col_index middle table, which contains the index of the Average column in the resulting matrix. I used the javax.persistence.OrderBy annotation with a new col_index column so that the list of medium objects is returned in the appropriate order. Although, this still does not fix the insertion order issue, and I would still like to get an answer for that. However, at the moment this solution will be enough.
source share