Failure loading list mapped with @OrderColumn(updatable = false, insertable = false)

Description

We are trying to upgrade hibernate from version 4.3.5 to 5.4.0. With this the jpa version also changes from hibernate-jpa-2.1 to jpa-2.2. After the upgrade we get the following error when using the List<> collection with @OrderColumn

"javax.persistence.PersistenceException: org.hibernate.HibernateException: null index column for collection"

I have forked the hibernate-test-case-templates repo and added a test case for both hibernate 4 and hibernate 5 projects. The test case passes as expected in hibernate 4 while it fails in hibernate 5.

The workaround to use a Set mapping with an OrderBy clause works but we would like to understand the root cause of the error. There are more than 100 such one-to-mappings in our project that are affected due to this failure.

Kindly note that the test case could be found here - https://github.com/shahamit/hibernate-test-case-templates/tree/master/orm
Please refer to the JPAUnitTestCase.readObjectWithList() test case. It is created for both the projects - test-case-template-hibernate-orm4 & test-case-template-hibernate-orm5. The test case passes for the former project while fails for the latter one.

Environment

Reproduced with hibernate test template using Hibernate 5.4.0

Status

Assignee

Unassigned

Reporter

AmitS

Fix versions

Labels

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Worked in

4.3.5
4.3.11
4.2.21

Components

Affects versions

5.4.0
5.1.17
5.3.9

Priority

Blocker
Configure