You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@openjpa.apache.org by "Kevin Sutter (Commented) (JIRA)" <ji...@apache.org> on 2012/02/22 15:49:48 UTC

[jira] [Commented] (OPENJPA-2125) Default join table name does not follow JPA v2 specification

    [ https://issues.apache.org/jira/browse/OPENJPA-2125?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13213665#comment-13213665 ] 

Kevin Sutter commented on OPENJPA-2125:
---------------------------------------

I think you answered your own question.  If you look at the specification excerpt you quoted, it says that "Entity A is mapped to *table* named A.  Entity B is mapped to a *table* named B."  So, the join table name is the concatenation of those two table names (A_B).  If the Entity has an @Table annotation, then that Entity would be mapped to the *table* identified by that @Table annotation.  So, I believe this is working as designed.
                
> Default join table name does not follow JPA v2 specification
> ------------------------------------------------------------
>
>                 Key: OPENJPA-2125
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-2125
>             Project: OpenJPA
>          Issue Type: Bug
>          Components: jdbc, jpa
>    Affects Versions: 2.1.1
>            Reporter: Maria Jurcovicova
>
> According to JPA v2 specification, two types of relationship use join table to keep relational data: 
> * many-to-many described in page 48,
> * unidirectional one-to-many described in page 50.
> In both cases, the joining table name should be composed from entity names (e.g. class names) by default. OpenJPA uses entity table names by default.
> Quote from JPA v2 specification:
> "Entity A is mapped to a table named A. 
> Entity B is mapped to a table named B. 
> There is a join table that is named A_B (owner name first). The join table has ..."
> Example entities:
> @Entity
> @Table(name="tblMtmOwner")
> public class MtmOwner {
>   @Id
>   private long id;
>   private String name;
>   @ManyToMany
>   private Collection<MtmInverse> inverses = new ArrayList<MtmInverse>();
> }
>  
> @Entity
> public class MtmInverse{
>   @Id
>   private long id;
>   @ManyToMany(mappedBy="inverses")
>   @MapKey(name="name")
>   private Map<String, MtmOwner> owners = new HashMap<String, MtmOwner>();
> }
> Expected join table name: MtmOwner_MtmInverse
> OpenJPA join table name:  tblMtmOwner_MtmInverse

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira