Index annotation causing Runtime failure

Description

After switching from 4.3.7.Final to 5.4.x I got a problem caused by an index annotation "org.hibernate.annoations.Index" causing a runtime failure ,but was working fine with hibernate 4 , I tried to use the non deprecated JPA index "javax.persistence.Index" but got the same output,so I think it’s not related to the fact that the Index is deprecated, I'm facing this problem since so long and hope it gets resolved or at least I get an explanation why after I added the index annotation the ORM is “tricked” into expecting the accounts property to be present on the AccountEntity which doesn’t make any sense at all .
I created a sandbox project to trigger the bug and the stack is the following :

Adding column accounts on AccountEntity prevents the bug from appearing but it's not a proper solution to resolve the issue and the index is not generated as well.
I consider this a hibernate bug since it was working in 4.3.x and the index was created .

For the sandbox project link :
https://github.com/unholyhoper/HibernateIndex

 

Logged output and queries for both hibernate 5.4.17.Final and 4.3.7.Final

Thank you

Environment

None

Activity

Show:
Christian Beikov
March 29, 2021, 9:30 AM

I see that is the cause for this issue, but it doesn’t matter, you should move away from the deprecated annotation org.hibernate.annotations.Index anyway. Please remove all index annotation uses in your example and try the following mapping for AccountEntity:

As far as I can tell, what you are expecting there is simply not supported (anymore). Hibernate can’t figure out the columns for the index for one-to-many associations which declare join columns, so you will have to list the columns. Since the annotation is deprecated and will be removed anyway, I recommend you switch to the approach I suggested. I’ll close this issue as won’t do.

Won't Do

Assignee

Christian Beikov

Reporter

ben yahia haithem