|
Lines 19-26
Link Here
|
| 19 |
import javax.persistence.metamodel.MapAttribute; |
19 |
import javax.persistence.metamodel.MapAttribute; |
| 20 |
import javax.persistence.metamodel.Type; |
20 |
import javax.persistence.metamodel.Type; |
| 21 |
|
21 |
|
|
|
22 |
import org.eclipse.persistence.descriptors.ClassDescriptor; |
| 23 |
import org.eclipse.persistence.descriptors.RelationalDescriptor; |
| 22 |
import org.eclipse.persistence.internal.queries.MapContainerPolicy; |
24 |
import org.eclipse.persistence.internal.queries.MapContainerPolicy; |
|
|
25 |
import org.eclipse.persistence.internal.queries.MappedKeyMapContainerPolicy; |
| 23 |
import org.eclipse.persistence.mappings.CollectionMapping; |
26 |
import org.eclipse.persistence.mappings.CollectionMapping; |
|
|
27 |
import org.eclipse.persistence.mappings.DatabaseMapping; |
| 28 |
import org.eclipse.persistence.mappings.foundation.MapKeyMapping; |
| 24 |
|
29 |
|
| 25 |
/** |
30 |
/** |
| 26 |
* <p> |
31 |
* <p> |
|
Lines 50-63
Link Here
|
| 50 |
super(managedType, mapping); |
55 |
super(managedType, mapping); |
| 51 |
|
56 |
|
| 52 |
MapContainerPolicy policy = (MapContainerPolicy) mapping.getContainerPolicy(); |
57 |
MapContainerPolicy policy = (MapContainerPolicy) mapping.getContainerPolicy(); |
| 53 |
Object policyKeyType = policy.getKeyType(); // both cases return a Class<?> |
58 |
Object policyKeyType = policy.getKeyType(); // returns a Class<?> or descriptor (via AggregateObjectMapping) |
|
|
59 |
Type<?> aKeyType = null; |
| 60 |
// Default to Object class for any variant cases that are not handled |
| 61 |
Class<?> javaClass = Object.class; |
| 54 |
if(null == policyKeyType) { |
62 |
if(null == policyKeyType) { |
| 55 |
// no key type, use Object - test case required |
63 |
// No policy key type = IdClass (use CMP3Policy.pkClass) |
| 56 |
this.keyType = getMetamodel().getType((Class<K>)Object.class); |
64 |
if(managedType.isIdentifiableType()) { |
| 57 |
} else { |
65 |
// Use the CMPPolicy on the element not the one on the managedType |
| 58 |
Type<?> keyType = managedType.getMetamodel().getType((Class)policyKeyType); |
66 |
if(policy.getElementDescriptor() != null && policy.getElementDescriptor().getCMPPolicy() != null) { |
| 59 |
this.keyType = (Type<K>) keyType; |
67 |
javaClass = policy.getElementDescriptor().getCMPPolicy().getPKClass(); |
|
|
68 |
} else { |
| 69 |
if(null == policy.getElementDescriptor()) { |
| 70 |
// check for a keyMapping on the mapping |
| 71 |
if(policy.isMappedKeyMapPolicy()) { |
| 72 |
MapKeyMapping mapKeyMapping = ((MappedKeyMapContainerPolicy)policy).getKeyMapping(); |
| 73 |
RelationalDescriptor descriptor = (RelationalDescriptor)((DatabaseMapping)mapKeyMapping).getDescriptor(); |
| 74 |
// If the reference descriptor is null then we are on a direct mapping |
| 75 |
if(null == descriptor) { |
| 76 |
throw new IllegalArgumentException("Unsupported operation on " + managedType); |
| 77 |
} else { |
| 78 |
if(null == descriptor.getCMPPolicy()) { // for __PK_METAMODEL_RESERVED_IN_MEM_ONLY_FIELD_NAME |
| 79 |
//throw new IllegalArgumentException("Unsupported operation on " + managedType); |
| 80 |
javaClass = Object.class; |
| 81 |
} else { |
| 82 |
javaClass = descriptor.getCMPPolicy().getPKClass(); |
| 83 |
} |
| 84 |
} |
| 85 |
} |
| 86 |
} else { |
| 87 |
} |
| 88 |
} |
| 89 |
} else { |
| 90 |
// Handle EmbeddableType |
| 91 |
} |
| 92 |
} else { |
| 93 |
if(policyKeyType instanceof ClassDescriptor) { // from AggregateObjectMapping |
| 94 |
javaClass = (Class<?>)((ClassDescriptor)policyKeyType).getJavaClass(); |
| 95 |
} else { |
| 96 |
javaClass = (Class<?>)policyKeyType; |
| 97 |
} |
| 60 |
} |
98 |
} |
|
|
99 |
aKeyType = getMetamodel().getType(javaClass); |
| 100 |
this.keyType = (Type<K>) aKeyType; |
| 61 |
} |
101 |
} |
| 62 |
|
102 |
|
| 63 |
/** |
103 |
/** |