From b01f5718f9ee88246f3f771c7b63306802732ce7 Mon Sep 17 00:00:00 2001 From: Milosz Tylenda Date: Sun, 7 Mar 2010 13:15:17 +0000 Subject: [PATCH] OPENJPA-1510: Move map related sections into 7.8 Maps section - they were out of context. git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@919984 13f79535-47bb-0310-9956-ffa450edef68 --- .../src/doc/manual/ref_guide_mapping.xml | 240 +++++++++--------- 1 file changed, 120 insertions(+), 120 deletions(-) diff --git a/openjpa-project/src/doc/manual/ref_guide_mapping.xml b/openjpa-project/src/doc/manual/ref_guide_mapping.xml index 985ad5777..7d977543d 100644 --- a/openjpa-project/src/doc/manual/ref_guide_mapping.xml +++ b/openjpa-project/src/doc/manual/ref_guide_mapping.xml @@ -2244,6 +2244,126 @@ We detailed the ContainerTable annotation in . Custom map mappings may also use this annotation to represent a map table. +
+ Key Columns + + KeyColumn + mapping metadata + + + Key columns serve the same role for map keys as the element + join columns described in + serve for + collection elements. OpenJPA's + + org.apache.openjpa.persistence.jdbc.KeyColumn + annotation represents a map key. To map custom + multi-column keys, use the + + org.apache.openjpa.persistence.jdbc.KeyColumns + annotation, whose value is an array of KeyColumns. + + + A KeyColumn always resides in + a container table, so it does not have the table + property of a standard Column. Otherwise, the + KeyColumn and standard Column + annotations are equivalent. See + in the JPA + Overview for a review of the Column annotation. + +
+
+ Key Join Columns + + KeyJoinColumn + mapping metadata + + + Key join columns are equivalent to standard JPA + join columns, except that they represent a join to a map key entity rather than a direct relation. You represent + a key join column with OpenJPA's + + org.apache.openjpa.persistence.jdbc.KeyJoinColumn annotation. To declare a compound join, enclose an + array of KeyJoinColumns in the + + org.apache.openjpa.persistence.jdbc.KeyJoinColumns + annotation. + + + A KeyJoinColumn always resides in + a container table, so it does not have the table property + of a standard JoinColumn. Like XJoinColumns above, + KeyJoinColumns can reference a linked field + rather than a static linked column. Otherwise, the KeyJoinColumn + and standard JoinColumn annotations are equivalent. See + in the JPA + Overview for a review of the JoinColumn annotation. + +
+
+ Key Embedded Mapping + + KeyEmbeddedMapping + mapping metadata + + + The + + org.apache.openjpa.persistence.jdbc.KeyEmbeddedMapping + annotation allows you to map your map field's embedded + key type to your container table. This annotation has exactly + the same properties as the + EmbeddedMapping annotation described + above. + +
+
+ Examples + + + + + + + + Map mapping in OpenJPA uses the same principles you saw in + collection mapping. The example below maps the + Article.authors map according to the diagram above. + + + String Key, Entity Value Map Mapping + +package org.mag.pub; + +import org.apache.openjpa.persistence.*; +import org.apache.openjpa.persistence.jdbc.*; + +@Entity +@Table(name="AUTH") +@DataStoreIdColumn(name="AID", columnDefinition="INTEGER64") +public class Author { + ... +} + +package org.mag; + +@Entity +@Table(name="ART") +public class Article { + @Id private long id; + + @PersistentMap + @ContainerTable(name="ART_AUTHS", joinColumns=@XJoinColumn(name="ART_ID")) + @KeyColumn(name="LNAME") + @ElementJoinColumn(name="AUTH_ID") + private Map<String,Author> authors; + + ... +} + + +
@@ -2861,126 +2981,6 @@ public class Employee { </example> </section> </section> - <section id="ref_guide_mapping_jpa_map_keycols"> - <title>Key Columns - - KeyColumn - mapping metadata - - - Key columns serve the same role for map keys as the element - join columns described in - serve for - collection elements. OpenJPA's - - org.apache.openjpa.persistence.jdbc.KeyColumn - annotation represents a map key. To map custom - multi-column keys, use the - - org.apache.openjpa.persistence.jdbc.KeyColumns - annotation, whose value is an array of KeyColumns. - - - A KeyColumn always resides in - a container table, so it does not have the table - property of a standard Column. Otherwise, the - KeyColumn and standard Column - annotations are equivalent. See - in the JPA - Overview for a review of the Column annotation. - -
-
- Key Join Columns - - KeyJoinColumn - mapping metadata - - - Key join columns are equivalent to standard JPA - join columns, except that they represent a join to a map key entity rather than a direct relation. You represent - a key join column with OpenJPA's - - org.apache.openjpa.persistence.jdbc.KeyJoinColumn annotation. To declare a compound join, enclose an - array of KeyJoinColumns in the - - org.apache.openjpa.persistence.jdbc.KeyJoinColumns - annotation. - - - A KeyJoinColumn always resides in - a container table, so it does not have the table property - of a standard JoinColumn. Like XJoinColumns above, - KeyJoinColumns can reference a linked field - rather than a static linked column. Otherwise, the KeyJoinColumn - and standard JoinColumn annotations are equivalent. See - in the JPA - Overview for a review of the JoinColumn annotation. - -
-
- Key Embedded Mapping - - KeyEmbeddedMapping - mapping metadata - - - The - - org.apache.openjpa.persistence.jdbc.KeyEmbeddedMapping - annotation allows you to map your map field's embedded - key type to your container table. This annotation has exactly - the same properties as the - EmbeddedMapping annotation described - above. - -
-
- Examples - - - - - - - - Map mapping in OpenJPA uses the same principles you saw in - collection mapping. The example below maps the - Article.authors map according to the diagram above. - - - String Key, Entity Value Map Mapping - -package org.mag.pub; - -import org.apache.openjpa.persistence.*; -import org.apache.openjpa.persistence.jdbc.*; - -@Entity -@Table(name="AUTH") -@DataStoreIdColumn(name="AID", columnDefinition="INTEGER64") -public class Author { - ... -} - -package org.mag; - -@Entity -@Table(name="ART") -public class Article { - @Id private long id; - - @PersistentMap - @ContainerTable(name="ART_AUTHS", joinColumns=@XJoinColumn(name="ART_ID")) - @KeyColumn(name="LNAME") - @ElementJoinColumn(name="AUTH_ID") - private Map<String,Author> authors; - - ... -} - - -
Mapping Limitations