Could not resolve attribute 'aaNbo' of 'test' due to the attribute being declared in multiple subtypes

Hello, we’ve migrate our project from 5 to 6.6.0 final.
We have main entity class test and subclasses test$aa and test$bb. In both subclasses we have field aaNbo annotated manyToMany to the same other class
We use single_table mapptig for test class.
Before upgrade we can use hql like this:

def hql = “”"
SELECT a.id
FROM test a
LEFT JOIN a.aaNbo g
But now we have exception:
“”"IllegalArgumentException, message: org.hibernate.query.PathException: Could not resolve attribute ‘aaNbo’ of ‘test’ due to the attribute being declared in multiple subtypes ‘test$aa’ and ‘test$bb’

How we can rewrite our entities or maybe rewrite hql to get correct result?
Why in prev version of hibernate that hql worked fine? What changes inside hibernate?

Because in Hibernate 5 there was a lot less validation happening at runtime, leaving possible problems to happen on the database side or even after running the query. Hibernate 6 does a lot more to fail early and highlight problems with application logic before they might cause problems.

I would suggest never using the same attribute name in two different subtypes as you will run into problems like this. If you want a temporary workaround, using the treat operator in your HQL query to downcast test into the subtype you desire might work, see the user guide for more info.

Thanks for Your help