Bug 303632 - Add attribute-type for mapping attributes to EclipseLink-ORM
Summary: Add attribute-type for mapping attributes to EclipseLink-ORM
Status: RESOLVED FIXED
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Eclipselink (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows XP
: P2 enhancement (vote)
Target Milestone: ---   Edit
Assignee: Nobody - feel free to take it CLA
QA Contact:
URL:
Whiteboard: dynamic eclipselink-orm.xml
Keywords:
Depends on:
Blocks: 253083
  Show dependency tree
 
Reported: 2010-02-23 10:34 EST by Guy Pelletier CLA
Modified: 2022-06-09 10:21 EDT (History)
3 users (show)

See Also:


Attachments
Proposed changes (96.92 KB, patch)
2010-03-08 11:44 EST, Guy Pelletier CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Guy Pelletier CLA 2010-02-23 10:34:06 EST
As part of the dynamic persistence solution, mapping attributes will need a way to specify their attribute-type in the eclipselink-orm.xml
Comment 1 Guy Pelletier CLA 2010-02-24 09:57:08 EST
A new attribute named 'attribute-type' (should we just call it 'type'?) will be
added to the following mapping elements:

  <id>
  <basic>
  <version>
  <embedded>
  <embedded-id>
  <transformation>

Deprecation:

  We should deprecate the following mapping elements (users should use 
  element collection):

    <basic-map>
    <basic-collection>

Other mapping elements:
  
  Examining the other mapping elements, they currently have a way of
  specifying the attribute type equivalent:

  - target-entity (mapping reference class)
    
      <many-to-one>
      <one-to-many>
      <one-to-one>
      <many-to-many>

   - target-class (mapping reference class)

       <variable-one-to-one>

   - map-key-class and target-class

       <element-collection> 
    
       For dynamic persistence if the map key class is specified we would use
       a Map otherwise we would use a Collection.

Metadata processing:

  When the attribute-type is specified, it will be the type used to map the
  element internally and the type from the class attribute will not be 
  used/inspected. This functionality is primarily for dynamic persistence, 
  however, outside of dynamic persistence users may still use this 
  functionality to further describe their attributes.

  For id, basic and version the attribute-type will be set on the mapping's 
  database field (overriding any current behavior)

  For embedded and embedded-id the attribute-type will override the 
  reference class (raw class from the accessible object)

  For transformation we will set the attribute-type directly on the mapping.

Examples:

  <basic name="age" attribute-type="Integer"/>
  <basic name="firstName" attribute-type="java.lang.String"/>

  The attribute-type will be appended to the <package> specification when
  applicable (we do not append this package to primitive and primitive 
  wrapper types etc.)

  <package>my.model</package>
  <embedded name="period" attribute-type="EmploymentPeriod"/>
Comment 2 Guy Pelletier CLA 2010-02-24 11:55:09 EST
We'll go with the name 'attribute-type' and it will also need to be added to the following mapping elements (since we rely on it when processing the indirection policy)

<one-to-many>
<many-to-many>
<element-collection>
Comment 3 Guy Pelletier CLA 2010-03-08 11:44:19 EST
Created attachment 161316 [details]
Proposed changes
Comment 4 Guy Pelletier CLA 2010-03-08 12:05:16 EST
To elaborate/correct the metadata processing, it does the following:

For id, basic and version the attribute-type will be set as the attribute-classification on the mapping.

For element collection when the attribute-type is set, the attribute classification will be set for the direct and direct key fields and direct key mapping (where appropritate). The attribute-type will be used to determine the correct indirection policy on the mapping.

For embedded and embedded-id the attribute-type will override the 
reference class (raw class from the accessible object) and be used at the reference class on the mapping.
Comment 5 Guy Pelletier CLA 2010-03-09 08:23:30 EST
Changes have been submitted

Reviewed by: Chris Delahunt

New test (testAttributeTypeSpecifications) added to EntityMappingsAdvancedJUnitTestCase.java which is run under the JPA extended test suite.
Comment 6 Eclipse Webmaster CLA 2022-06-09 10:21:29 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink