From bc72d754f082fe30ef0d7aeff54f29c64553f02a Mon Sep 17 00:00:00 2001 From: nhauge Date: Fri, 4 May 2007 19:55:48 +0000 Subject: 178911 - Initial check-in for user.doc plugin for Dali 1.0. --- jpa/plugins/org.eclipse.jpt.doc.user/tasks013.htm | 186 ++++++++++++++++++++++ 1 file changed, 186 insertions(+) create mode 100644 jpa/plugins/org.eclipse.jpt.doc.user/tasks013.htm (limited to 'jpa/plugins/org.eclipse.jpt.doc.user/tasks013.htm') diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/tasks013.htm b/jpa/plugins/org.eclipse.jpt.doc.user/tasks013.htm new file mode 100644 index 0000000000..b115ef0ff5 --- /dev/null +++ b/jpa/plugins/org.eclipse.jpt.doc.user/tasks013.htm @@ -0,0 +1,186 @@ + + + + + +One-to-many mapping + + + + + + + + + + + + + + + +

+
+ + + + +
+

One-to-many mapping

+
+

Use a One-to-Many Mapping to define a relationship with one-to-many multiplicity.

+
    +
  1. +

    In the JPA Structure view, select the field to map. The JPA Details view (for attributes) displays the properties for the selected.

    +
  2. +
  3. +

    In the Map As field, select One-to-many.

    +
  4. +
  5. +

    Use this table to complete the General information fields JPA Details view.

    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    PropertyDescriptionDefault
    Target EntityThe entity to which this attribute is mapped.
    Cascade TypeSee "Cascade Type" for details. +
      +
    • +

      Default

      +
    • +
    • +

      All

      +
    • +
    • +

      Persist

      +
    • +
    • +

      Merge

      +
    • +
    • +

      Remove

      +
    • +
    +

    Fetch TypeDefines how data is loaded from the database. See "Fetch Type" for details. +
      +
    • +

      Eager

      +
    • +
    • +

      Lazy

      +
    • +
    +
    Eager
    Mapped ByThe database field that owns the relationship.
    Order BySpecify the default order for objects returned from a query. See "Order By" for details. +
      +
    • +

      Primary key

      +
    • +
    +
    Primary key
    +
    +
  6. +
  7. +

    Use this table to complete the Join Table Information fields in the JPA Details view.

    +
    + + + + + + + + + + + + + + + + + + + + + + + + + +
    PropertyDescriptionDefault
    NameName of the join tableBy default, the name is assumed to be the primary tables associated with the entities concatenated with an underscore.
    Join ColumnsSpecify two or more join columns (that is, a primary key).
    Inverse Join ColumnsThe join column on the owned (or inverse) side of the association: the owned entity's primary key column.
    +
    +
  8. +
+

Eclipse adds the following annotations to the field:

+
+@OneToMany(targetEntity=<TARGET_ENTITY>)
+@Column(name="<COLUMN>")
+
+
+@OneToMany(targetEntity=<TARGET_ENTITY>.class, cascade=CascadeType.<CASCADE_TYPE>, 
+    fetch = FetchType.<FETCH_TYPE>, mappedBy = "<MAPPED_BY>")@OrderBy("<ORDER_BY>")
+@JoinTable(name="<JOIN_TABLE_NAME>", joinColumns=@JoinColumn(name=
+    "<JOIN_COLUMN_NAME>", referencedColumnName="<JOIN_COLUMN_REFERENCED_COLUMN>"), 
+    inverseJoinColumns=@JoinColumn(name="<INVERSE_JOIN_COLUMN_NAME>", 
+    referencedColumnName="<INVERSE_JOIN_COLUMN_REFERENCED_COLUMN>"))
+
+
+
+

 

+Related task
+
+Mapping an entity +

 

+Related reference
+
+JPA Structure view
+JPA Details view (for attributes) +

 

+Related concept
+
+Understanding OR mappings
+Understanding EJB 3.0 Java Persistence API
+ + + + + + -- cgit v1.2.3