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


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 -
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.


Reproduced with hibernate test template using Hibernate 5.4.0


Gail Badner
February 21, 2019, 7:39 PM

The issue is specifically with @OrderColumn(updatable = false, insertable = false)

February 25, 2019, 10:47 AM

The issue also appears when using a "Map" mapping with @MapKeyColumn(insertable = false, updatable = false) annotation. I have updated the test case to include this mapping too.

Apparently it seems that when we specify updatable = false and insertable = false, the hibernate code is skipping the order/key column which leads to nulls and hence the error.

Are there any workarounds to this issue other than compromising on having the values for insertable and updatable to be default i.e. true?

Since this issue is blocking us from upgrading hibernate we are trying to see if there are alternatives.

March 26, 2019, 9:30 AM

This issue is a blocker for us to upgrade to the latest version of hibernate. It's been more than a month there hasn't been any activity or troubleshooting done for this issue. Is there something pending on my side to take this issue further towards a resolution OR is this bug missing something for it to be picked up for further analysis?

Nathan Xu
December 15, 2019, 5:01 PM

I tested via Hibernate 5.4.10 and got some basic conclusions as following:

  • It seems Hibernate is working as expected, so if insertable = false, updatable = false, the column in question won’t show up in both insert and update SQL statements;

  • It seems your demo testing case passes for List case, though the exception is thrown when the list is fetched (seems your testing case only covers saving). It seems Hibernate is complaining in a readable way;

  • It seems your demo testing case failed for Map case. Again, it seems Hibernate is complaining in a readable way;

  • Maybe Hibernate should complain while saving phase to avoid surprising exception while fetching for the List case, but that seems another issue.

I didn’t test Hibernate 4, though.






Fix versions




Suitable for new contributors


Requires Release Note


Pull Request




Worked in



Affects versions