|
Lines 14-19
Link Here
|
| 14 |
* - 266912: JPA 2.0 Metamodel API (part of Criteria API) |
14 |
* - 266912: JPA 2.0 Metamodel API (part of Criteria API) |
| 15 |
* Add Set<RelationalDescriptor> mappedSuperclassDescriptors |
15 |
* Add Set<RelationalDescriptor> mappedSuperclassDescriptors |
| 16 |
* to support the Metamodel API |
16 |
* to support the Metamodel API |
|
|
17 |
* 06/17/2009-2.0 Michael O'Brien |
| 18 |
* - 266912: change mappedSuperclassDescriptors Set to a Map |
| 19 |
* keyed on MetadataClass - avoiding the use of a hashCode/equals |
| 20 |
* override on RelationalDescriptor, but requiring a contains check prior to a put |
| 17 |
* |
21 |
* |
| 18 |
******************************************************************************/ |
22 |
******************************************************************************/ |
| 19 |
package org.eclipse.persistence.sessions; |
23 |
package org.eclipse.persistence.sessions; |
|
Lines 89-97
Link Here
|
| 89 |
protected transient List<DatabaseQuery> queries = null; |
93 |
protected transient List<DatabaseQuery> queries = null; |
| 90 |
|
94 |
|
| 91 |
/** |
95 |
/** |
| 92 |
* Mapped Superclasses (JPA 2) collection of parent non-relational descriptors |
96 |
* Mapped Superclasses (JPA 2) collection of parent non-relational descriptors keyed on MetadataClass |
|
|
97 |
* without creating a compile time dependency onJPA |
| 93 |
*/ |
98 |
*/ |
| 94 |
protected Set<RelationalDescriptor> mappedSuperclassDescriptors; |
99 |
protected Map<Object, RelationalDescriptor> mappedSuperclassDescriptors; |
| 95 |
|
100 |
|
| 96 |
/** |
101 |
/** |
| 97 |
* PUBLIC: |
102 |
* PUBLIC: |
|
Lines 107-113
Link Here
|
| 107 |
this.hasProxyIndirection = false; |
112 |
this.hasProxyIndirection = false; |
| 108 |
this.jpqlParseCache = new ConcurrentFixedCache(200); |
113 |
this.jpqlParseCache = new ConcurrentFixedCache(200); |
| 109 |
this.queries = new ArrayList<DatabaseQuery>(); |
114 |
this.queries = new ArrayList<DatabaseQuery>(); |
| 110 |
this.mappedSuperclassDescriptors = new HashSet<RelationalDescriptor>(2); |
115 |
this.mappedSuperclassDescriptors = new HashMap<Object, RelationalDescriptor>(2); |
| 111 |
} |
116 |
} |
| 112 |
|
117 |
|
| 113 |
/** |
118 |
/** |
|
Lines 968-1021
Link Here
|
| 968 |
|
973 |
|
| 969 |
/** |
974 |
/** |
| 970 |
* INTERNAL: |
975 |
* INTERNAL: |
| 971 |
* 266912: Add a descriptor to the Set of mappedSuperclass descriptors |
976 |
* 266912: Add a descriptor to the Map of mappedSuperclass descriptors |
|
|
977 |
* @param key (Metadata class) |
| 972 |
* @param value (RelationalDescriptor) |
978 |
* @param value (RelationalDescriptor) |
| 973 |
*/ |
979 |
*/ |
| 974 |
public void addMappedSuperclass(RelationalDescriptor value) { |
980 |
public void addMappedSuperclass(Object key, RelationalDescriptor value) { |
| 975 |
// Lazy initialization of the mappedSuperclassDescriptors field. |
981 |
// Lazy initialization of the mappedSuperclassDescriptors field. |
| 976 |
if(null == this.mappedSuperclassDescriptors) { |
982 |
if(null == this.mappedSuperclassDescriptors) { |
| 977 |
this.mappedSuperclassDescriptors = new HashSet<RelationalDescriptor>(2); |
983 |
this.mappedSuperclassDescriptors = new HashMap<Object, RelationalDescriptor>(2); |
| 978 |
} |
984 |
} |
| 979 |
// duplicates are avoided with use of a Set and overriding equals()/hashCode() |
985 |
// Avoid replacing the current RelationalDescriptor that may have mappings set |
| 980 |
this.mappedSuperclassDescriptors.add(value); |
986 |
if(!this.mappedSuperclassDescriptors.containsKey(key)) { |
|
|
987 |
this.mappedSuperclassDescriptors.put(key, value); |
| 988 |
} |
| 981 |
} |
989 |
} |
| 982 |
|
990 |
|
| 983 |
/** |
991 |
/** |
| 984 |
* INTERNAL: |
992 |
* INTERNAL: |
| 985 |
* Use the javaClassName from the Class key parameter to lookup the |
993 |
* Use the Metadata key parameter to lookup the |
| 986 |
* Descriptor from the Set of mappedSuperclass descriptors |
994 |
* Descriptor from the Map of mappedSuperclass descriptors |
| 987 |
* @param key - the String name of the metadata class |
995 |
* @param key - theMetadata class |
| 988 |
* @return |
996 |
* @return |
| 989 |
*/ |
997 |
*/ |
| 990 |
public RelationalDescriptor getMappedSuperclass(String key) { |
998 |
public RelationalDescriptor getMappedSuperclass(Object key) { |
| 991 |
// TODO: this implementation may have side effects when we have the same class in different class loaders. |
999 |
// TODO: this implementation may have side effects when we have the same class |
| 992 |
RelationalDescriptor descriptor = null; |
1000 |
// in different class loaders - however currently there is only one classLoader per project |
| 993 |
// Lazy initialization of the mappedSuperclassDescriptors field. |
1001 |
// Lazy initialization of the mappedSuperclassDescriptors field. |
| 994 |
if(null == this.mappedSuperclassDescriptors) { |
1002 |
if(null == this.mappedSuperclassDescriptors) { |
| 995 |
this.mappedSuperclassDescriptors = new HashSet<RelationalDescriptor>(2); |
1003 |
this.mappedSuperclassDescriptors = new HashMap<Object, RelationalDescriptor>(2); |
|
|
1004 |
return null; |
| 996 |
} |
1005 |
} |
| 997 |
// iterate the set of mappedSuperclasses and return the value that has a matching javaClass key |
1006 |
// iterate the set of mappedSuperclasses and return the value that has a matching javaClass key |
| 998 |
for(Iterator<RelationalDescriptor> anIterator = |
1007 |
return this.mappedSuperclassDescriptors.get(key); |
| 999 |
this.mappedSuperclassDescriptors.iterator(); anIterator.hasNext();) { |
|
|
| 1000 |
descriptor = anIterator.next(); |
| 1001 |
// return descriptor that matches the name set in EntityAccessor |
| 1002 |
if(descriptor.getJavaClassName().equals(key)) { |
| 1003 |
return descriptor; |
| 1004 |
} |
| 1005 |
} |
| 1006 |
return null; |
| 1007 |
} |
1008 |
} |
| 1008 |
|
1009 |
|
| 1009 |
|
1010 |
|
| 1010 |
/** |
1011 |
/** |
| 1011 |
* INTERNAL: |
1012 |
* INTERNAL: |
| 1012 |
* Return the Set of RelationalDescriptor objects representing mapped superclass parents |
1013 |
* Return the Map of RelationalDescriptor objects representing mapped superclass parents |
| 1013 |
* @return Set |
1014 |
* keyed by className of the metadata class |
|
|
1015 |
* @return Map |
| 1014 |
*/ |
1016 |
*/ |
| 1015 |
public Set<RelationalDescriptor> getMappedSuperclassDescriptors() { |
1017 |
public Map<Object, RelationalDescriptor> getMappedSuperclassDescriptors() { |
| 1016 |
// Lazy initialization of the mappedSuperclassDescriptors field. |
1018 |
// Lazy initialization of the mappedSuperclassDescriptors field. |
| 1017 |
if(null == this.mappedSuperclassDescriptors) { |
1019 |
if(null == this.mappedSuperclassDescriptors) { |
| 1018 |
this.mappedSuperclassDescriptors = new HashSet<RelationalDescriptor>(2); |
1020 |
this.mappedSuperclassDescriptors = new HashMap<Object, RelationalDescriptor>(2); |
| 1019 |
} |
1021 |
} |
| 1020 |
return this.mappedSuperclassDescriptors; |
1022 |
return this.mappedSuperclassDescriptors; |
| 1021 |
} |
1023 |
} |