Return-Path: X-Original-To: apmail-openjpa-dev-archive@www.apache.org Delivered-To: apmail-openjpa-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 5801C9F0F for ; Wed, 22 Feb 2012 16:06:16 +0000 (UTC) Received: (qmail 41363 invoked by uid 500); 22 Feb 2012 16:06:16 -0000 Delivered-To: apmail-openjpa-dev-archive@openjpa.apache.org Received: (qmail 41319 invoked by uid 500); 22 Feb 2012 16:06:16 -0000 Mailing-List: contact dev-help@openjpa.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@openjpa.apache.org Delivered-To: mailing list dev@openjpa.apache.org Received: (qmail 41304 invoked by uid 99); 22 Feb 2012 16:06:16 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 22 Feb 2012 16:06:16 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED,T_RP_MATCHES_RCVD X-Spam-Check-By: apache.org Received: from [140.211.11.116] (HELO hel.zones.apache.org) (140.211.11.116) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 22 Feb 2012 16:06:10 +0000 Received: from hel.zones.apache.org (hel.zones.apache.org [140.211.11.116]) by hel.zones.apache.org (Postfix) with ESMTP id 04CB23342DB for ; Wed, 22 Feb 2012 16:05:49 +0000 (UTC) Date: Wed, 22 Feb 2012 16:05:49 +0000 (UTC) From: "Kevin Sutter (Resolved) (JIRA)" To: dev@openjpa.apache.org Message-ID: <732235946.4643.1329926749021.JavaMail.tomcat@hel.zones.apache.org> In-Reply-To: <827079333.31073.1329121139342.JavaMail.tomcat@hel.zones.apache.org> Subject: [jira] [Resolved] (OPENJPA-2127) Join table in unidirectional one-to-many relationship with Map does not follow JPA v2 specification MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/OPENJPA-2127?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Kevin Sutter resolved OPENJPA-2127. ----------------------------------- Resolution: Duplicate This looks to be a duplicate of OPENJPA-2126. The same explanations (and expectations) apply. The bonus with this JIRA is that it looks like it has already been verified that without the use of the Map and @MapKey, everything works as expected. > Join table in unidirectional one-to-many relationship with Map does not follow JPA v2 specification > --------------------------------------------------------------------------------------------------- > > Key: OPENJPA-2127 > URL: https://issues.apache.org/jira/browse/OPENJPA-2127 > Project: OpenJPA > Issue Type: Bug > Components: jdbc, jpa > Affects Versions: 2.1.1 > Reporter: Maria Jurcovicova > > According to JPA v2 specification page 50, the joining table name should be composed from entity names (e.g. class names) by default. The table should have two columns. > Table name: > * owner class name > * underscore "_" > * inverse class name. > Name of the column with inverses ids: > * the name of the relationship property or field of the owner > * underscore "_" > * the name of the primary key column in table inverse. > If the annotated property maps data into the map, OpenJPA assumes different database structure. > OpenJPA table name: > * owner class name <- OK > * underscore "_" <- OK > * the name of the relationship property or field of the owner <- WRONG > OpenJPA column with inverses id name: > * "element_id" <- WRONG > Name of the column with owners ids is correct. > Extract from the 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). This join table has two foreign key > columns. One foreign key column refers to table A and has the same type as the primary key of > table A. The name of this foreign key column is formed as the concatenation of the following: > the name of entity A; "_"; the name of the primary key column in table A. The other foreign > key column refers to table B and has the same type as the primary key of table B and there is a > unique key constraint on it. The name of this foreign key column is formed as the concatenation > of the following: the name of the relationship property or field of entity A; "_"; the name > of the primary key column in table B." > Example entities: > @Entity > public class MapOneToManyOwner { > @Id > private long id; > @OneToMany > @MapKey(name="mapKey") > private Map inverses; > } > @Entity > public class MapOneToManyInverse { > @Id > private long id; > private String mapKey; > } > Expected table name: MapOneToManyOwner_MapOneToManyInverse > OpenJPA table name: MapOneToManyOwner_inverses > Expected column name: inverses_id > OpenJPA column name: element_id > DB structure that works with JPA: > CREATE TABLE MapOneToManyOwner_inverses ( > MapOneToManyOwner_id INT NOT NULL, > element_id INT NOT NULL, > UNIQUE (element_id) > ); > Note: this happens only if the annotated property is a map. If it is a collection, join table structure is different. -- 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