ManyToMany with OrderColumn in linking table

In hibernate 5 + kotlin + jakarta 3 I had

class event {

    @ManyToMany(fetch = FetchType.LAZY, cascade = [CascadeType.MERGE])
    @JoinTable(inverseJoinColumns = [JoinColumn(name = "video_id")])
    var videos: MutableList<Video> = ArrayList()

tables event, video and event_video linking table with event_id, video_id and videos_ORDER columns. It works nicely.

However, I read that Hibernate 6 doesn’t support ManyToMany + OrderColumn annotations at the same time and in fact, I couldn’t make it work.

So is there any workaround I can use so I don’t have to change the code or our database model? Or is this support coming in future versions of hibernate?

Where did you read that Hibernate 6 doesn’t support that? We have tests in our testsuite that do exactly that. What doesn’t work is the use of @OrderColumn on the inverse/non-owned side i.e. when you use @ManyToMany(mappedBy = "...")

Thanks for a quick reply, really appriciate it!

Sorry, I missed the part about mappedBy.

Anyway, if I keep @OrderColumn or @OrderColumn(name = "videos_ORDER") there, Im getting this during initialization:

caused by: java.lang.NullPointerException: Cannot invoke "org.hibernate.annotations.common.reflection.XClass.getName()" because the return value of "org.hibernate.annotations.common.reflection.XProperty.getMapKey()" is null at org.hibernate.cfg.ClassPropertyHolder$1.doSecondPass( ~[hibernate-core-6.1.7.Final.jar:6.1.7.Final]

I tried both set(AvailableSettings.DEFAULT_LIST_SEMANTICS, "BAG") and "LIST"

Runtime data if needed (its for images, but its exactly the same situation):

Any idea how to make it work?

That looks like a bug. Please create an issue in the issue tracker( with a test case(hibernate-test-case-templates/ at main · hibernate/hibernate-test-case-templates · GitHub) that reproduces the issue.