Cannot recreate collection while filter is enabled

Geek4 Comments

I have been meaning to start posting some of my new tips, tricks, and general crap I have gotten stuck on in my new life as a Java web developer. Need to go back through my notes but here was one from today. Google shows no hits for this Hibernate error message:


cannot recreate collection while filter is enabled

This seems to be an issue with collections when you are using filters. After reading some of the Hibernate source code, I figured out what the issue was. We had a collection in the form of a list in an entity but had not defined an index column — that is the database column that stores the list order. The error seemed weird and out of place and didn’t direct me to thinking about index columns. I finally started comparing code that worked with some that didn’t and found this difference. So don’t forget your index column on your list collections.


@IndexColumn(name = "listOrder")