Hibernate-processor 7: incorrect field type in generated metamodel class when field is of custom class type with same name as jakarta one

The issue started appearing after migrating to Hibernate 7.2 from 6.6.28.Final. I have tried 7.2.4.Final and 7.1.16.Final, both releases have the same issue.

I have this entity:

@Entity
public class EntityType implements Serializable {
    // class body 
}

the above entity is used in another entity like this:

@Entity
public class FormType implements Serializable {

    private EntityType entityType;
} 

The problem is with the generated static metamodel of FormType. Instead of declaring the field entityType in FormType_ of type my EntityType, it is of type jakarta.persistence.metamodel.EntityType<X>.

import jakarta.persistence.metamodel.EntityType

@StaticMetamodel(FormType.class)
@Generated("org.hibernate.proccessor.HibernateProcessor")
public abstract class FormType_ {

    public static volatile SingularAtribute<FormType, EntityType> entityType
} 

My question is, why did this issue started appearing in after upgrading to Hibernate 7, while it worked fine in 6?
Can I fix it without having to rename my entity EntityType?

This is just a bug that happened by accident. Renaming the type certainly would help avoid this, but please try to create a reproducer with our test case template and if you are able to reproduce the issue, create a bug ticket in our issue tracker and attach that reproducer.

Sadly renaming is not feasible. So, I hope the issue will be fixed soon in a future minor version.

here is the ticket: Jira
Please let me know if I need to make any corrections in my report.

1 Like