[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-5709) JPA Metamodel: EntityType.getName != @Entity.name

Tomasz Blachowicz (JIRA) noreply at atlassian.com
Mon Nov 1 12:53:47 EDT 2010


    [ http://opensource.atlassian.com/projects/hibernate/browse/HHH-5709?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=38960#action_38960 ] 

Tomasz Blachowicz commented on HHH-5709:
----------------------------------------

I also did some further investigation and found out that in OpenJPA and EclipseLink, which seems to be the reference implementation, this works as I'd expect, so the {{EntityType.getName() == @Entity.name}}.

> JPA Metamodel: EntityType.getName != @Entity.name
> -------------------------------------------------
>
>                 Key: HHH-5709
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5709
>             Project: Hibernate Core
>          Issue Type: Bug
>          Components: metamodel
>    Affects Versions: 3.6.0
>            Reporter: Tomasz Blachowicz
>
> 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.
> {quote}
> *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.
> {code:java} 
> @Documented @Target(TYPE) @Retention(RUNTIME)
> public @interface Entity {
> String name() default "";
> }
> {code}
> {quote}
> 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, HHH-2597 and HHH-4465.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the hibernate-issues mailing list