JPA Metamodel: EntityType.getName != @Entity.name

Description

I was working recently on the implementation that uses JPA2 meta-model. It was rather surprise to me when I found out that name of the entity on EntityType is different than name of the entity specified with @Entity annotation.

The specification is not explicit about the entity names, so it could be interpreted differently, but I think it is reasonable to implicitly assume that entity name specified with @Entity is used as entity name with JPA2 meta-model.

10.1 Entity
The Entity annotation specifies that the class is an entity. This annotation is applied to the entity
class.

The name annotation element specifies the entity name. If the name element is not specified, the entity
name defaults to the unqualified name of the entity class. This name is used to refer to the entity in queries.

I know that in Hibernate the entity name if FQN of persistent class and the abbreviated name (without the package) can be only used within the HQL queries. I guess this was OK prior JPA2 when there was no such think like meta-model.

This topic has been already discussed several times, but I couldn't find any discussion in the context of JPA meta-model, thus I've decided to create a new ticket. The other issues related to this topic are: HHH-4375, and HHH-4465.

Environment

None

Assignee

Steve Ebersole

Reporter

Tomasz Blachowicz

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