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 "Dali Project/specs/3.0/2.0ElementCollection"

(Requirements / Functionality)
(Requirements / Functionality)
 
(21 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
= Functional Specification: Dali Support for JPA 2.0 Element Collection mapping =
 
= Functional Specification: Dali Support for JPA 2.0 Element Collection mapping =
 
[[Talk:Dali_Project/specs/3.0/2.0ElementCollection | Feedback]]
 
  
 
[https://bugs.eclipse.org/258490 bug 258490] - element collection support
 
[https://bugs.eclipse.org/258490 bug 258490] - element collection support
Line 35: Line 33:
  
 
== Requirements / Functionality ==
 
== Requirements / Functionality ==
 +
 +
=== Element Collection with No Type ===
 +
* target-class - defaults to type of the Collection if generic, must be specified otherwise
 +
* fetch - defaults to Lazy
 +
* collection-table and @CollectionTable
 +
** name defaults to <Entity name>_<attribute name>
 +
* order-by and @OrderBy
 +
* order-column and @OrderColumn
 +
* Validation
 +
** Error that target class must be specified since collection is not generic
 +
 +
[[Image: ElementCollectionNoType.jpg]]
 +
  
 
=== Element Collection with Basic Type ===
 
=== Element Collection with Basic Type ===
  
* Target Class - defaults to type of the Collection if it is generic
+
* target-class - defaults to type of the Collection if generic, must be specified otherwise
* Fetch - defaults to Lazy
+
* fetch - defaults to Lazy
* Collection Table
+
* collection-table and @CollectionTable
** Name defaults to <Entity name>_<attribute name>
+
** name defaults to <Entity name>_<attribute name>
* Column
+
* column and @Column
** Name default to attribute name
+
** name defaults to attribute name
** Table defaults to collection table name and is not editable
+
** table defaults to collection table name and is not editable
 +
* temporal and @Temporal
 +
* enumerated and @Enumerated
 +
* lob and @Lob
 +
* convert and @Convert (EclipseLink)
 +
* order-by and @OrderBy
 +
* order-column and @OrderColumn
  
  
Line 55: Line 72:
  
 
[[Image:Ordering.jpg]]
 
[[Image:Ordering.jpg]]
 +
  
 
=== Element Collection with Embeddable Type ===
 
=== Element Collection with Embeddable Type ===
  
 +
* target-class - defaults to type of the Collection if generic, must be specified otherwise
 +
* fetch - defaults to Lazy
 +
* collection-table and @CollectionTable
 +
** name defaults to <Entity name>_<attribute name>
 
*Attribute and Association override names are derived from the Embeddable type
 
*Attribute and Association override names are derived from the Embeddable type
 
+
**Are we expected to support value dot notation here?  Could the attribute override be specified as name="value.street"?
 +
* order-by and @OrderBy
 +
* order-column and @OrderColumn
  
 
'''Element Collection Embeddable Type Details'''
 
'''Element Collection Embeddable Type Details'''
Line 66: Line 90:
  
  
=== Element Collection Map Basic Types ===
+
=== Element Collection with No Key Type Or Value Type===
* target-class
+
* target-class - defaults to type of the Map value if generic, must be specified otherwise
 +
* map-key-class and @MapKeyClass - defaults to the type of the Map key if generic, must be specified otherwise and if MapKey is not
 +
* map-key and @MapKey - this and MapKeyClass are mutually exclusive
 
* fetch - defaults to Lazy
 
* fetch - defaults to Lazy
 
* collection-table and @Collection Table
 
* collection-table and @Collection Table
 
** Name defaults to <Entity name>_<attribute name>
 
** Name defaults to <Entity name>_<attribute name>
* column and @Column
+
* order-by and @OrderBy
* map-key-column and @MapKeyColumn
+
* order-column and @OrderColumn
* map-key-temporal and @MapKeyTemporal
+
* Validation
* map-key-enumerated and @MapKeyEnumerated
+
** Error that target class must be specified since Map is not generic
* map-key-convert and @MapKeyConvert
+
** Error that map key class must be specified since Map is not generic
* map-key-class and @MapKeyClass
+
 
 +
[[Image: ElementCollectionMapNoKeyOrValueType.jpg]]
 +
 
 +
 
 +
=== Element Collection Map Basic Key and Basic Value ===
 +
* target-class - defaults to type of the Map value if generic, must be specified otherwise
 +
* map-key-class and @MapKeyClass - defaults to the type of the Map key if generic, must be specified otherwise and if MapKey is not
 
* map-key and @MapKey - this and MapKeyClass are mutually exclusive
 
* map-key and @MapKey - this and MapKeyClass are mutually exclusive
 +
* fetch - defaults to Lazy
 +
* collection-table and @Collection Table
 +
** Name defaults to <Entity name>_<attribute name>
 +
* Value column definition
 +
** column and @Column
 +
** temporal and @Temporal
 +
** enumerated and @Enumerated
 +
** lob and @Lob
 +
** convert and @Convert (EclipseLink)
 +
* Key column definition
 +
** map-key-column and @MapKeyColumn
 +
*** name defaults to <attribute name>_KEY
 +
** map-key-temporal and @MapKeyTemporal
 +
** map-key-enumerated and @MapKeyEnumerated
 +
** map-key-convert and @MapKeyConvert (EclipseLink)
 +
* order-by and @OrderBy
 +
* order-column and @OrderColumn
 
* Validation errors:
 
* Validation errors:
 
** MapKey and MapKeyClass are both specified
 
** MapKey and MapKeyClass are both specified
**
+
 
  
 
'''Element Collection Map with Basic Key and Basic Value Details'''
 
'''Element Collection Map with Basic Key and Basic Value Details'''
Line 86: Line 135:
 
[[Image: ElementCollectionMapBasicKeyAndValue.jpg]]
 
[[Image: ElementCollectionMapBasicKeyAndValue.jpg]]
  
=== Element Collection Map Embeddable Key ===
+
 
* Overrides
+
=== Element Collection Map Embeddable Key and Embeddable value ===
 +
* target-class - defaults to type of the Map value if generic, must be specified otherwise
 +
* map-key-class and @MapKeyClass - defaults to the type of the Map key if generic, must be specified otherwise and if MapKey is not
 +
* map-key and @MapKey - this and MapKeyClass are mutually exclusive
 +
* fetch - defaults to Lazy
 +
* collection-table and @Collection Table
 +
** Name defaults to <Entity name>_<attribute name>
 +
* Value overrides
 +
** In Xml attribute-override, in Java @AttributeOverride
 +
** In Xml association-override, in Java @AssociationOverride
 +
* Key overrides
 
** In Xml use map-key-attribute-override and map-key-association-override
 
** In Xml use map-key-attribute-override and map-key-association-override
 
** In Java use AttributeOverride(name="key.<name>") and AttributeOverride(name="value.<name>)
 
** In Java use AttributeOverride(name="key.<name>") and AttributeOverride(name="value.<name>)
 +
* order-by and @OrderBy
 +
* order-column and @OrderColumn
  
  
[[Image: ElementCollectionMapEmbeddableKeyAndBasicValue.jpg]]
+
[[Image: ElementCollectionMapEmbeddableKeyAndEmbeddableValue.jpg]]
  
=== Element Collection Map Entity Key ===
+
 
* MapKeyJoinColumn  
+
=== Element Collection Map Embeddable Key and Basic value ===
* MapKeyJoinColumns
+
* target-class - defaults to type of the Map value if generic, must be specified otherwise
 +
* map-key-class and @MapKeyClass - defaults to the type of the Map key if generic, must be specified otherwise and if MapKey is not
 +
* map-key and @MapKey - this and MapKeyClass are mutually exclusive
 +
* fetch - defaults to Lazy
 +
* collection-table and @Collection Table
 +
** Name defaults to <Entity name>_<attribute name>
 +
* Value column definition
 +
** column and @Column
 +
** temporal and @Temporal
 +
** enumerated and @Enumerated
 +
** lob and @Lob
 +
** convert and @Convert (EclipseLink)
 +
* Key overrides
 +
** In Xml use map-key-attribute-override and map-key-association-override
 +
** In Java use AttributeOverride(name="key.<name>") and AttributeOverride(name="value.<name>)
 +
* order-by and @OrderBy
 +
* order-column and @OrderColumn
 +
 
 +
Screen shot is similar to others with the Map Value section having column and type and the Map Key section having overrides
 +
 
 +
=== Element Collection Map Basic Key and Embeddable Value ===
 +
* target-class - defaults to type of the Map value if generic, must be specified otherwise
 +
* map-key-class and @MapKeyClass - defaults to the type of the Map key if generic, must be specified otherwise and if MapKey is not
 +
* map-key and @MapKey - this and MapKeyClass are mutually exclusive
 +
* fetch - defaults to Lazy
 +
* collection-table and @Collection Table
 +
** Name defaults to <Entity name>_<attribute name>
 +
* Value overrides
 +
** In Xml attribute-override, in Java @AttributeOverride
 +
** In Xml association-override, in Java @AssociationOverride
 +
* Key column definition
 +
** map-key-column and @MapKeyColumn
 +
*** name defaults to <attribute name>_KEY
 +
** map-key-temporal and @MapKeyTemporal
 +
** map-key-enumerated and @MapKeyEnumerated
 +
** map-key-convert and @MapKeyConvert (EclipseLink)
 +
* order-by and @OrderBy
 +
* order-column and @OrderColumn
 +
* Validation errors:
 +
** MapKey and MapKeyClass are both specified
 +
 
 +
Screen shot is similar to others with the Map Value section having overrides and the Map Key having column and type
 +
 
 +
=== Element Collection Map Entity Key and Basic Value ===
 +
* target-class - defaults to type of the Map value if generic, must be specified otherwise
 +
* fetch - defaults to Lazy
 +
* collection-table and @Collection Table
 +
** Name defaults to <Entity name>_<attribute name>
 +
* map-key-class and @MapKeyClass - defaults to the type of the Map key if generic, must be specified otherwise and if MapKey is not
 +
* map-key and @MapKey - this and MapKeyClass are mutually exclusive
 +
* Value column definition
 +
** column and @Column
 +
** temporal and @Temporal
 +
** enumerated and @Enumerated
 +
** lob and @Lob
 +
** convert and @Convert (EclipseLink)
 +
* Key column definition
 +
** map-key-join-column and @MapKeyJoinColumn  
 +
*** default name is <attribute name>_KEY
 +
*** default referenced column name is the primary key of the referenced table
 +
** @MapKeyJoinColumns
 +
* order-by and @OrderBy
 +
* order-column and @OrderColumn
  
 
[[Image: ElementCollectionMapEntityKeyAndBasicValue.jpg]]
 
[[Image: ElementCollectionMapEntityKeyAndBasicValue.jpg]]
 +
 +
 +
=== Element Collection Map Entity Key and Embeddable Value ===
 +
* target-class - defaults to type of the Map value if generic, must be specified otherwise
 +
* fetch - defaults to Lazy
 +
* collection-table and @Collection Table
 +
** Name defaults to <Entity name>_<attribute name>
 +
* map-key-class and @MapKeyClass - defaults to the type of the Map key if generic, must be specified otherwise and if MapKey is not
 +
* map-key and @MapKey - this and MapKeyClass are mutually exclusive
 +
* Value overrides
 +
** In Xml attribute-override, in Java @AttributeOverride
 +
** In Xml association-override, in Java @AssociationOverride
 +
* Key column definition
 +
** map-key-join-column and @MapKeyJoinColumn
 +
*** default name is <attribute name>_KEY
 +
*** default referenced column name is the primary key of the referenced table
 +
** @MapKeyJoinColumns
 +
* order-by and @OrderBy
 +
* order-column and @OrderColumn
 +
 +
Screen shot is similar to others with the 'Map Value' section having overrides and the 'Map Key' section having join columns
 +
 +
 +
=== Validation ===
 +
* From the spec: An embeddable class (including an embeddable class within another embeddable class) that is contained
 +
within an element collection must not contain an element collection, nor may it contain a relationship
 +
to an entity other than a many-to-one or one-to-one relationship. The embeddable class must be
 +
on the owning side of such a relationship and the relationship must be mapped by a foreign key mapping.
 +
*Bidirectional relationships represented as java.util.Map collections support the use of the Map
 +
datatype on one side of the relationship only.
 +
* ElementCollection specified but Map value type is an entity
 +
* ElementCollection specified but Collection type is an entity
 +
* Both MapKey and MapKeyClass specified on an element collection
 +
* Database validation
 +
** Column name and table
 +
** CollectionTable name, schema, catalog
 +
** MapKeyColumn name and table
 +
** MapKeyJoinColumn name, referencedColumnName, table
 +
** Attribute override name and column
 +
** Association override name and column
  
 
== API ==
 
== API ==

Latest revision as of 13:33, 16 December 2009

Functional Specification: Dali Support for JPA 2.0 Element Collection mapping

bug 258490 - element collection support


Document History

Date Author Version Description & Notes
12-9-2009 Karen Butzke Draft

Project overview

This feature covers the element collection mapping in the JPA 2.0 spec as well as any EclipseLink extensions.

Goals:

  • Add Generic 2.0 support for Element Collection
  • Add EclipseLink 3.0 support for Element Collection with relevant extensions
  • Provide the appropriate defaults and validation for these settings

Concepts

Present any concepts relevant to the feature.

EclipseLink Element Collection Functional Spec

Requirements / Functionality

Element Collection with No Type

  • target-class - defaults to type of the Collection if generic, must be specified otherwise
  • fetch - defaults to Lazy
  • collection-table and @CollectionTable
    • name defaults to <Entity name>_<attribute name>
  • order-by and @OrderBy
  • order-column and @OrderColumn
  • Validation
    • Error that target class must be specified since collection is not generic

ElementCollectionNoType.jpg


Element Collection with Basic Type

  • target-class - defaults to type of the Collection if generic, must be specified otherwise
  • fetch - defaults to Lazy
  • collection-table and @CollectionTable
    • name defaults to <Entity name>_<attribute name>
  • column and @Column
    • name defaults to attribute name
    • table defaults to collection table name and is not editable
  • temporal and @Temporal
  • enumerated and @Enumerated
  • lob and @Lob
  • convert and @Convert (EclipseLink)
  • order-by and @OrderBy
  • order-column and @OrderColumn


Element Collection Basic Type Details

ElementCollectionBasicType.jpg


Ordering Section

Ordering.jpg


Element Collection with Embeddable Type

  • target-class - defaults to type of the Collection if generic, must be specified otherwise
  • fetch - defaults to Lazy
  • collection-table and @CollectionTable
    • name defaults to <Entity name>_<attribute name>
  • Attribute and Association override names are derived from the Embeddable type
    • Are we expected to support value dot notation here? Could the attribute override be specified as name="value.street"?
  • order-by and @OrderBy
  • order-column and @OrderColumn

Element Collection Embeddable Type Details

ElementCollectionEmbeddableType.jpg


Element Collection with No Key Type Or Value Type

  • target-class - defaults to type of the Map value if generic, must be specified otherwise
  • map-key-class and @MapKeyClass - defaults to the type of the Map key if generic, must be specified otherwise and if MapKey is not
  • map-key and @MapKey - this and MapKeyClass are mutually exclusive
  • fetch - defaults to Lazy
  • collection-table and @Collection Table
    • Name defaults to <Entity name>_<attribute name>
  • order-by and @OrderBy
  • order-column and @OrderColumn
  • Validation
    • Error that target class must be specified since Map is not generic
    • Error that map key class must be specified since Map is not generic

ElementCollectionMapNoKeyOrValueType.jpg


Element Collection Map Basic Key and Basic Value

  • target-class - defaults to type of the Map value if generic, must be specified otherwise
  • map-key-class and @MapKeyClass - defaults to the type of the Map key if generic, must be specified otherwise and if MapKey is not
  • map-key and @MapKey - this and MapKeyClass are mutually exclusive
  • fetch - defaults to Lazy
  • collection-table and @Collection Table
    • Name defaults to <Entity name>_<attribute name>
  • Value column definition
    • column and @Column
    • temporal and @Temporal
    • enumerated and @Enumerated
    • lob and @Lob
    • convert and @Convert (EclipseLink)
  • Key column definition
    • map-key-column and @MapKeyColumn
      • name defaults to <attribute name>_KEY
    • map-key-temporal and @MapKeyTemporal
    • map-key-enumerated and @MapKeyEnumerated
    • map-key-convert and @MapKeyConvert (EclipseLink)
  • order-by and @OrderBy
  • order-column and @OrderColumn
  • Validation errors:
    • MapKey and MapKeyClass are both specified


Element Collection Map with Basic Key and Basic Value Details

ElementCollectionMapBasicKeyAndValue.jpg


Element Collection Map Embeddable Key and Embeddable value

  • target-class - defaults to type of the Map value if generic, must be specified otherwise
  • map-key-class and @MapKeyClass - defaults to the type of the Map key if generic, must be specified otherwise and if MapKey is not
  • map-key and @MapKey - this and MapKeyClass are mutually exclusive
  • fetch - defaults to Lazy
  • collection-table and @Collection Table
    • Name defaults to <Entity name>_<attribute name>
  • Value overrides
    • In Xml attribute-override, in Java @AttributeOverride
    • In Xml association-override, in Java @AssociationOverride
  • Key overrides
    • In Xml use map-key-attribute-override and map-key-association-override
    • In Java use AttributeOverride(name="key.<name>") and AttributeOverride(name="value.<name>)
  • order-by and @OrderBy
  • order-column and @OrderColumn


ElementCollectionMapEmbeddableKeyAndEmbeddableValue.jpg


Element Collection Map Embeddable Key and Basic value

  • target-class - defaults to type of the Map value if generic, must be specified otherwise
  • map-key-class and @MapKeyClass - defaults to the type of the Map key if generic, must be specified otherwise and if MapKey is not
  • map-key and @MapKey - this and MapKeyClass are mutually exclusive
  • fetch - defaults to Lazy
  • collection-table and @Collection Table
    • Name defaults to <Entity name>_<attribute name>
  • Value column definition
    • column and @Column
    • temporal and @Temporal
    • enumerated and @Enumerated
    • lob and @Lob
    • convert and @Convert (EclipseLink)
  • Key overrides
    • In Xml use map-key-attribute-override and map-key-association-override
    • In Java use AttributeOverride(name="key.<name>") and AttributeOverride(name="value.<name>)
  • order-by and @OrderBy
  • order-column and @OrderColumn

Screen shot is similar to others with the Map Value section having column and type and the Map Key section having overrides

Element Collection Map Basic Key and Embeddable Value

  • target-class - defaults to type of the Map value if generic, must be specified otherwise
  • map-key-class and @MapKeyClass - defaults to the type of the Map key if generic, must be specified otherwise and if MapKey is not
  • map-key and @MapKey - this and MapKeyClass are mutually exclusive
  • fetch - defaults to Lazy
  • collection-table and @Collection Table
    • Name defaults to <Entity name>_<attribute name>
  • Value overrides
    • In Xml attribute-override, in Java @AttributeOverride
    • In Xml association-override, in Java @AssociationOverride
  • Key column definition
    • map-key-column and @MapKeyColumn
      • name defaults to <attribute name>_KEY
    • map-key-temporal and @MapKeyTemporal
    • map-key-enumerated and @MapKeyEnumerated
    • map-key-convert and @MapKeyConvert (EclipseLink)
  • order-by and @OrderBy
  • order-column and @OrderColumn
  • Validation errors:
    • MapKey and MapKeyClass are both specified

Screen shot is similar to others with the Map Value section having overrides and the Map Key having column and type

Element Collection Map Entity Key and Basic Value

  • target-class - defaults to type of the Map value if generic, must be specified otherwise
  • fetch - defaults to Lazy
  • collection-table and @Collection Table
    • Name defaults to <Entity name>_<attribute name>
  • map-key-class and @MapKeyClass - defaults to the type of the Map key if generic, must be specified otherwise and if MapKey is not
  • map-key and @MapKey - this and MapKeyClass are mutually exclusive
  • Value column definition
    • column and @Column
    • temporal and @Temporal
    • enumerated and @Enumerated
    • lob and @Lob
    • convert and @Convert (EclipseLink)
  • Key column definition
    • map-key-join-column and @MapKeyJoinColumn
      • default name is <attribute name>_KEY
      • default referenced column name is the primary key of the referenced table
    • @MapKeyJoinColumns
  • order-by and @OrderBy
  • order-column and @OrderColumn

ElementCollectionMapEntityKeyAndBasicValue.jpg


Element Collection Map Entity Key and Embeddable Value

  • target-class - defaults to type of the Map value if generic, must be specified otherwise
  • fetch - defaults to Lazy
  • collection-table and @Collection Table
    • Name defaults to <Entity name>_<attribute name>
  • map-key-class and @MapKeyClass - defaults to the type of the Map key if generic, must be specified otherwise and if MapKey is not
  • map-key and @MapKey - this and MapKeyClass are mutually exclusive
  • Value overrides
    • In Xml attribute-override, in Java @AttributeOverride
    • In Xml association-override, in Java @AssociationOverride
  • Key column definition
    • map-key-join-column and @MapKeyJoinColumn
      • default name is <attribute name>_KEY
      • default referenced column name is the primary key of the referenced table
    • @MapKeyJoinColumns
  • order-by and @OrderBy
  • order-column and @OrderColumn

Screen shot is similar to others with the 'Map Value' section having overrides and the 'Map Key' section having join columns


Validation

  • From the spec: An embeddable class (including an embeddable class within another embeddable class) that is contained

within an element collection must not contain an element collection, nor may it contain a relationship to an entity other than a many-to-one or one-to-one relationship. The embeddable class must be on the owning side of such a relationship and the relationship must be mapped by a foreign key mapping.

  • Bidirectional relationships represented as java.util.Map collections support the use of the Map

datatype on one side of the relationship only.

  • ElementCollection specified but Map value type is an entity
  • ElementCollection specified but Collection type is an entity
  • Both MapKey and MapKeyClass specified on an element collection
  • Database validation
    • Column name and table
    • CollectionTable name, schema, catalog
    • MapKeyColumn name and table
    • MapKeyJoinColumn name, referencedColumnName, table
    • Attribute override name and column
    • Association override name and column

API

Issues

This section lists the open issues that are still pending that must be decided prior to fully implementing this project's requirements.

Issue # Owner Description / Notes Decision

Future Considerations

During the research for this project the following items were identified as out of scope but are captured here as potential future enhancements. If agreed upon during the review process these should be logged in the bug system.

Back to the top