Community
Participate
Working Groups
As part of the dynamic persistence solution, mapping attributes will need a way to specify their attribute-type in the eclipselink-orm.xml
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"/>
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>
Created attachment 161316 [details] Proposed changes
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.
Changes have been submitted Reviewed by: Chris Delahunt New test (testAttributeTypeSpecifications) added to EntityMappingsAdvancedJUnitTestCase.java which is run under the JPA extended test suite.
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink