This Bugzilla instance is deprecated, and most Eclipse projects now use GitHub or Eclipse GitLab. Please see the deprecation plan for details.
View | Details | Raw Unified | Return to bug 294765 | Differences between
and this patch

Collapse All | Expand All

(-)foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/mappings/foundation/AbstractDirectMapping.java (-1 / +9 lines)
Lines 9-14 Link Here
9
 *
9
 *
10
 * Contributors:
10
 * Contributors:
11
 *     Oracle - initial API and implementation from Oracle TopLink
11
 *     Oracle - initial API and implementation from Oracle TopLink
12
 *     11/13/2009-2.0  mobrien - 294765: MapKey keyType DirectToField processing 
13
 *       should return attributeClassification class in getMapKeyTargetType when 
14
 *       accessor.attributeField is null in the absence of a MapKey annotation
12
 ******************************************************************************/  
15
 ******************************************************************************/  
13
package org.eclipse.persistence.mappings.foundation;
16
package org.eclipse.persistence.mappings.foundation;
14
17
Lines 852-858 Link Here
852
     * @return
855
     * @return
853
     */
856
     */
854
    public Class getMapKeyTargetType(){
857
    public Class getMapKeyTargetType(){
855
        return getAttributeAccessor().getAttributeClass();
858
        Class aClass = getAttributeAccessor().getAttributeClass();
859
        // 294765: check the attributeClassification when the MapKey annotation is not specified
860
        if(null == aClass) {
861
            aClass = getAttributeClassification();
862
        }
863
        return aClass;
856
    }
864
    }
857
    
865
    
858
    /**
866
    /**
(-)jpa/org.eclipse.persistence.jpa/src/org/eclipse/persistence/internal/jpa/metamodel/MapAttributeImpl.java (-13 / +4 lines)
Lines 19-25 Link Here
19
 *         keep workaround for bug# 294765 for Basic keyType when MapKey annotation not specified.
19
 *         keep workaround for bug# 294765 for Basic keyType when MapKey annotation not specified.
20
 *         keep workaround for bug# 294811 for Entity, Embeddable, Transient keyType support 
20
 *         keep workaround for bug# 294811 for Entity, Embeddable, Transient keyType support 
21
 *           when MapKey name attribute not specified (MapContainerPolicy) 
21
 *           when MapKey name attribute not specified (MapContainerPolicy) 
22
 *         add BasicMap support via DirectMapContainerPolicy         
22
 *         add BasicMap support via DirectMapContainerPolicy
23
 *     13/10/2009-2.0  mobrien - 294765 - fix allows removal of workaround for
24
 *        when MapKey annotation not specified          
23
 ******************************************************************************/
25
 ******************************************************************************/
24
package org.eclipse.persistence.internal.jpa.metamodel;
26
package org.eclipse.persistence.internal.jpa.metamodel;
25
27
Lines 150-166 Link Here
150
                // The cast below is unavoidable because getKeyMapping() is not overridden from the MapContainerPolicy superclass
152
                // The cast below is unavoidable because getKeyMapping() is not overridden from the MapContainerPolicy superclass
151
                keyMapping = ((MappedKeyMapContainerPolicy)policy).getKeyMapping();
153
                keyMapping = ((MappedKeyMapContainerPolicy)policy).getKeyMapping();
152
                policyKeyType = keyMapping.getMapKeyTargetType();
154
                policyKeyType = keyMapping.getMapKeyTargetType();
153
                /**
154
                 * If the policyKeyType is not found - it is because the keyMapping is a Basic (DirectToFieldMapping implements MapKeyMapping).
155
                 * Normally we get the pk type via the referenceClass on a OneToOneMapping for example.
156
                 * However, in this case MappedKeyMapContainerPolicy.keyMapping.attributeAccessor.attributeField is null - 
157
                 * we workaround this by getting the key from the attributeClassification instead.
158
                 * See UC1a, UC7
159
                 */
160
                if(null == policyKeyType) {
161
                    // This workaround for bug# 294765 should be moved up into AbstractDirectMapping.getMapKeyTargetType
162
                    policyKeyType = ((DatabaseMapping)keyMapping).getAttributeClassification();
163
                }
164
            } else {
155
            } else {
165
                /**
156
                /**
166
                 * Assume we have a MapContainerPolicy general superclass with a lazy-loaded keyType 
157
                 * Assume we have a MapContainerPolicy general superclass with a lazy-loaded keyType 
Lines 187-193 Link Here
187
            // Use the PK of the element - not the one on the managedType
178
            // Use the PK of the element - not the one on the managedType
188
            // Case: @MapKey private Map<K,V> // no name column specified
179
            // Case: @MapKey private Map<K,V> // no name column specified
189
            if(policyElementDescriptor != null && policyElementDescriptor.getCMPPolicy() != null) {
180
            if(policyElementDescriptor != null && policyElementDescriptor.getCMPPolicy() != null) {
190
                // See UC9, UC10, UC12(embeddable), UC13
181
                // See UC10, UC12(embeddable), UC13
191
                // This workaround for bug# 294811 should be moved up into the MapKeyMapping.getMapKeyTargetType() interface method
182
                // This workaround for bug# 294811 should be moved up into the MapKeyMapping.getMapKeyTargetType() interface method
192
                javaClass = policy.getElementDescriptor().getCMPPolicy().getPKClass();
183
                javaClass = policy.getElementDescriptor().getCMPPolicy().getPKClass();
193
            }
184
            }

Return to bug 294765