Hibernate inserts data in the wrong columns for list of records with @OrderColumn

Description

Using Hibernate 6.5.3 and MariaDB via Spring Boot 3.3.6, I’m facing a situation where Hibernate inserts data in the wrong columns.

With this embeddable record:

And this entity:

This test will insert data in the wrong columns:

As seen with the wrong bindings used in the insert query:

Please find a reproducer at this Git repository: https://github.com/don-vip/hhh-18957

Simply run “mvn test” and look at the logs. The wrong data can then be seen in mariadb (schema root_spacemedia, table bug_medihal_media_authors):

 

Attachments

1

Activity

Show:

Gavin King February 17, 2025 at 4:14 PM

It has been three months and the user has not provided an isolated reproducer. You have done more than enough here, and you should close the issue (up to you what to do with the test you wrote).

Jan Schatteman January 17, 2025 at 4:41 PM

You don’t really need to concern yourself with the test framework, that’s only the infrastructure to provide you with a session, in this case inside a transaction.

So really the only important issue is if i got the gist of your problem right.

Vincent Privat January 17, 2025 at 3:56 PM
Edited

I reproduced the bug with all versions I mentioned (6.4.10, 6.5.3, 6.6.2) by using the correct version of Spring Boot. But I never tried in a pure Hibernate environment without Spring in the way. I need some time to understand how the Hibernate test framework works, I looked at the simplified test and I didn’t understand it at first glance.

Jan Schatteman January 17, 2025 at 3:25 PM

I was somewhat mislead by the indicated affected versions that stated 6.6.2 as affected; I’ve now also tested it on the actual hibernate version that Spring Boot 3.3.6 depends on (6.5.3), but it still doesn’t fail.

Unless You can provide me with additional feedback, I’m guessing that this could be a problem in Spring Boot rather than Hibernate itself.

Jan Schatteman January 15, 2025 at 10:28 PM

I’ve added a pure Hibernate simplified test here, and tried it out on main and 6.6.2 and in both those cases on mariadb as well as h2, but cannot get it to fail. Could you have a look in case I missed something in the test?

Details

Assignee

Reporter

Labels

Components

Affects versions

Priority

Created December 17, 2024 at 10:16 PM
Updated February 17, 2025 at 4:14 PM