Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "EclipseLink/Development/JPA2.0/Extended Map support"

Line 42: Line 42:
 
* Uses a CollectionTable
 
* Uses a CollectionTable
 
* CollectionTable contains foreign keys to the source, key and value
 
* CollectionTable contains foreign keys to the source, key and value
 +
* This works like our BasicMapMapping
  
 
=== Basic - Embeddable ===
 
=== Basic - Embeddable ===
Line 57: Line 58:
 
*** Value is the Target Entity
 
*** Value is the Target Entity
 
*** Target Entity maps join information
 
*** Target Entity maps join information
 +
** No Join Table (unidirectional OneToMany)
 +
*** Same config as bidirectional OneToMany, but with new unidirectional OneToManySupport
 
** Join Table with Key
 
** Join Table with Key
 
*** Join table contains foreign keys for each side of the relationship and the key
 
*** Join table contains foreign keys for each side of the relationship and the key
Line 64: Line 67:
 
*** Value is the target entity
 
*** Value is the target entity
 
*** Key is a mapped value of on the target entity
 
*** Key is a mapped value of on the target entity
 +
*** Our current MapKey support covers this case
  
 
=== Embeddable - Basic ===
 
=== Embeddable - Basic ===
Line 73: Line 77:
 
* Key is Embeddable, value is Embeddable
 
* Key is Embeddable, value is Embeddable
 
* Uses a Collection Table
 
* Uses a Collection Table
* Collection Table contains a forein key, all the fields of both embeddables (note key and value could be the same embeddable and then the table will only contain one set of information about the embeddable)
+
* Collection Table contains a forein key, all the fields of both embeddables (note: if key and value map to the same columns through overrides then the table will only contain one set of information about the embeddable)
  
 
=== Embeddable - Entity ===
 
=== Embeddable - Entity ===
 
* Key is Embdeddable, value is Entity
 
* Key is Embdeddable, value is Entity
 
* Several Possible use cases
 
* Several Possible use cases
** No Join Table
+
** No Join Table (bidirectional OneToMany)
 
*** Key is a Embedded within the Entity
 
*** Key is a Embedded within the Entity
 
*** Value is the Entity itself
 
*** Value is the Entity itself
 
*** Target Entity Maps Join information
 
*** Target Entity Maps Join information
 +
** No Join Table (unidirectional OneToMany)
 +
*** Same config as bidirectional OneToMany, but with new unidirectional OneToManySupport
 
** Join Table with Key
 
** Join Table with Key
 
*** Join table contains foreign keys for each Entity and fields of Embeddable
 
*** Join table contains foreign keys for each Entity and fields of Embeddable
Line 89: Line 95:
 
*** Key is Embedded in target Entity
 
*** Key is Embedded in target Entity
 
*** Value is target Entity
 
*** Value is target Entity
 +
*** Our Current MapKey support covers this case
  
 
=== Entity - Basic ===
 
=== Entity - Basic ===
 
* Key is Entity, value is Basic
 
* Key is Entity, value is Basic
 
* Uses a Collection Table
 
* Uses a Collection Table
* Two use cases
+
* Collection table contains foreign keys to the source, foreign keys to the key and the value
** Collection table contains foreign keys to the source, foreign keys to the key and the value
+
 
** Colleciton table contains foreign keys to the source and foreign keys to the key.  Value is a field on the key
+
  
 
=== Entity - Embeddable ===
 
=== Entity - Embeddable ===
 
* Key is Entity, value is Embeddable
 
* Key is Entity, value is Embeddable
 
* Uses a Colleciton Table
 
* Uses a Colleciton Table
* Two use cases
+
* Collection table contains foreign keys to the source, foreign keys to the key and all the values of the embedded value
** Collection table contains foreign keys to the source, foreign keys to the key and all the values of the embedded value
+
** Collection table contains foreign keys to the source and foreign keys to the key. The value is Embedded in the Key.
+
  
 
=== Entity - Entity ===
 
=== Entity - Entity ===

Revision as of 15:03, 30 July 2008

JPA 2.0 Map Support

Enhancement Request

Issue summary

Map support as defined in JPA 2.0 will require new mapping functionality for EclipseLink. The specification will allow any JPA 1.0 relationship mapping to be stored in a map with key being a primitive, an Embeddable or an Entity. For this support no user defined mapping or property exists on the target of the relationship as is the case in our current support. An additional complication is that the location of the Key fields exist on the relation table if one exists.

The Solution in General

The general approach to implementing this functionality will be to produce Map mappings that encapsulate two EclipseLink mappings. A generated mapping that represents the Key attribute and a user defined mapping that represents the value of the map. It is expected that two Map Mappings will be needed. A Mapping where the Key mapping columns are found in the target table and another where the Key mapping columns are found in the relation table.

The Details

Target Table Map Mapping
Enhancement Request
This support will cover the case where the Map key columns exist in the target table
EclipseLink Mappings Involved
- AggregateCollectionMapping
- Bi-directional OneToMany
- New Uni-directional OneToMany mapping
JPA Mappings
- Bi-directional OneToMany mapping
- Uni-directional OneToMany with @JoinColum
- ElementCollection<*, Primitive> mapping
- ElementCollection<*, Embeddable> mapping
Join Table Map Mapping
Enhancement Request
This support will cover the case where the Map key columns exist in the Join table
EclipseLink Mappings Involved
- ManyToMany mapping
JPA Mappings
- default Uni-directional OneToMany with @JoinColum
- ManyToMany mapping
- Note: The specification disallows both sides of a mapping using a Map collection but there is no technical reason to do this as one side will be read-only anyway.

Use Cases

Both keys and values can be either of the following types: Basic, Embeddable, Entity. This results in the following types of maps.

Basic - Basic

  • Both key and value are a basic
  • Uses a CollectionTable
  • CollectionTable contains foreign keys to the source, key and value
  • This works like our BasicMapMapping

Basic - Embeddable

  • Key is a basic, value is Embeddable
  • Uses a CollectionTable
  • Two possible use cases
    • CollectionTable contains - foreign keys to the source, key and all attributes of Embeddable
    • CollecitonTable contains - foreign keys to the source, and all attributes of Embeddable, Key is made up of attributes of Embeddable

Basic - Entity

  • Key is a basic, value is Entity
  • Several possible use cases
    • No Join Table (bidirectional OneToMany)
      • Key is a Mapped value in Target Entity
      • Value is the Target Entity
      • Target Entity maps join information
    • No Join Table (unidirectional OneToMany)
      • Same config as bidirectional OneToMany, but with new unidirectional OneToManySupport
    • Join Table with Key
      • Join table contains foreign keys for each side of the relationship and the key
      • Value is the target entity
    • Join Table with Key on Target
      • Join table contains foreign keys for each side of the relationship
      • Value is the target entity
      • Key is a mapped value of on the target entity
      • Our current MapKey support covers this case

Embeddable - Basic

  • Key is Embeddable, value is Basic
  • Uses a Collection Table
  • CollectionTable contains foreign keys to the source, all the fields of the embeddable and the value

Embeddable - Embeddable

  • Key is Embeddable, value is Embeddable
  • Uses a Collection Table
  • Collection Table contains a forein key, all the fields of both embeddables (note: if key and value map to the same columns through overrides then the table will only contain one set of information about the embeddable)

Embeddable - Entity

  • Key is Embdeddable, value is Entity
  • Several Possible use cases
    • No Join Table (bidirectional OneToMany)
      • Key is a Embedded within the Entity
      • Value is the Entity itself
      • Target Entity Maps Join information
    • No Join Table (unidirectional OneToMany)
      • Same config as bidirectional OneToMany, but with new unidirectional OneToManySupport
    • Join Table with Key
      • Join table contains foreign keys for each Entity and fields of Embeddable
      • Value is the target entity
    • Join Table no key
      • Join table contains foreign keys for each Entity
      • Key is Embedded in target Entity
      • Value is target Entity
      • Our Current MapKey support covers this case

Entity - Basic

  • Key is Entity, value is Basic
  • Uses a Collection Table
  • Collection table contains foreign keys to the source, foreign keys to the key and the value


Entity - Embeddable

  • Key is Entity, value is Embeddable
  • Uses a Colleciton Table
  • Collection table contains foreign keys to the source, foreign keys to the key and all the values of the embedded value

Entity - Entity

  • Key is Entity, value is Entity
  • Uses a Join table
  • Join table contains foreign keys to the source, foreign keys to the key and foreign keys to the value

Back to the top