As I understand the original question is not about database index but about the insertion of List index value in the column specified by @OrderColumn. In other words - Ebean to not insert the List index value in the column specified by @OrderColumn but it should according to comply with JPA 2+. (
https://www.logicbig.com/tutorials/java-ee-tutorial/jpa/order-column.html)
As result:
- no order is preserved in List
- user cant create a unique database index for such table (in the example below, the unique index for (promise_id, index) is not possible because of index column is null)
In addition - Ebean can use pair of FK + Ordinal columns (because it is uniquee) to update certain rows in the target table instead of deleting and inserting all rows in case of collection modification. Usually, it is far more efficient because it is a rare situation when the whole collection is changed. This optimization is implemented in Eclipselink and Datanucleus, not sure about Hibernate.
I've hit by this issue too and forced to work around this by using default value from database sequence for such ordinal column. It solved the first problem (insertion order is preserved) but not solved the second.
I can provide PR with the test for that issue.
вторник, 8 июня 2021 г. в 07:54:12 UTC+3, Rob Bygrave: