openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Kevin Sutter (Commented) (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (OPENJPA-2125) Default join table name does not follow JPA v2 specification
Date Wed, 22 Feb 2012 14:49:48 GMT

    [ 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

        

Mime
View raw message