Formula cannot be cast to Column when mappedBy contains formula

Description

If @OneToMany has mappedBy which is mapped using @JoinColumnsOrFormulas with formula, then there is ClassCastException.

I have seen some similar bugs, but they all are fixed/closed. Maybe it is a duplicate. Simple example attached.

Environment

None

Activity

Show:
Nikita Metzger
June 28, 2016, 9:09 AM

It looks like trying to map OneToMany directly over JoinColumnsOrFormulas fails with the same exception.

Ivo Steinmann
January 8, 2019, 11:37 AM

Years later, hibernate version 5.4.0, the bug still exists....

Ivo Steinmann
January 8, 2019, 12:17 PM

The following code block of TableBinder:java:584 is simply dangerous, since the iterator mappedByColumns returns org.hibernate.mapping.Selectable instances, which are either implemented by org.hibernate.mapping.Column or org.hibernate.mapping.Formula. Therefore, a cast to Column without any check is a bad idea. I guess Formula need some special treatment or at least a decend error message.

TableBinder.java:584 (5.4.0)

Assignee

Unassigned

Reporter

Nikita Metzger

Fix versions

Labels

None

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Components

Affects versions

Priority

Major
Configure