|
46 | 46 | */ |
47 | 47 | public class PersistentDescriptor implements ClassDescriptor { |
48 | 48 |
|
49 | | - static final Integer TRANSIENT_STATE = PersistenceState.TRANSIENT; |
50 | 49 | static final Integer HOLLOW_STATE = PersistenceState.HOLLOW; |
51 | | - static final Integer COMMITTED_STATE = PersistenceState.COMMITTED; |
52 | 50 |
|
53 | 51 | protected ClassDescriptor superclassDescriptor; |
54 | 52 |
|
@@ -85,7 +83,7 @@ public PersistentDescriptor() { |
85 | 83 | this.subclassDescriptors = new HashMap<>(); |
86 | 84 |
|
87 | 85 | // must be a set as duplicate addition attempts are expected... |
88 | | - this.rootDbEntities = new HashSet<DbEntity>(1); |
| 86 | + this.rootDbEntities = new HashSet<>(1); |
89 | 87 | } |
90 | 88 |
|
91 | 89 | public void setDiscriminatorColumns(Collection<ObjAttribute> columns) { |
@@ -213,14 +211,11 @@ public void removeDeclaredProperty(String propertyName) { |
213 | 211 | /** |
214 | 212 | * Adds a subclass descriptor that maps to a given class name. |
215 | 213 | */ |
216 | | - public void addSubclassDescriptor(String className, ClassDescriptor subclassDescriptor) { |
217 | | - // note that 'className' should be used instead of |
218 | | - // "subclassDescriptor.getEntity().getClassName()", as this method is |
219 | | - // called in |
220 | | - // the early phases of descriptor initialization and we do not want to |
221 | | - // trigger |
222 | | - // subclassDescriptor resolution just yet to prevent stack overflow. |
223 | | - subclassDescriptors.put(className, subclassDescriptor); |
| 214 | + public void addSubclassDescriptor(String entityName, ClassDescriptor subclassDescriptor) { |
| 215 | + // NOTE: 'entityName' should be used instead of "subclassDescriptor.getEntity().getName()", |
| 216 | + // as this method is called in the early phases of descriptor initialization, and we do not want to |
| 217 | + // trigger subclassDescriptor resolution just yet to prevent stack overflow. |
| 218 | + subclassDescriptors.put(entityName, subclassDescriptor); |
224 | 219 | } |
225 | 220 |
|
226 | 221 | public ObjEntity getEntity() { |
@@ -259,31 +254,21 @@ void setObjectClass(Class<?> objectClass) { |
259 | 254 | this.objectClass = objectClass; |
260 | 255 | } |
261 | 256 |
|
262 | | - public ClassDescriptor getSubclassDescriptor(Class<?> objectClass) { |
263 | | - if (objectClass == null) { |
| 257 | + public ClassDescriptor getSubclassDescriptor(String entityName) { |
| 258 | + if (entityName == null) { |
264 | 259 | throw new IllegalArgumentException("Null objectClass"); |
265 | 260 | } |
266 | 261 |
|
267 | 262 | if (subclassDescriptors.isEmpty()) { |
268 | 263 | return this; |
269 | 264 | } |
270 | 265 |
|
271 | | - ClassDescriptor subclassDescriptor = subclassDescriptors.get(objectClass.getName()); |
272 | | - |
273 | | - // ascend via the class hierarchy (only doing it if there are multiple |
274 | | - // choices) |
275 | | - if (subclassDescriptor == null) { |
276 | | - Class<?> currentClass = objectClass; |
277 | | - while (subclassDescriptor == null && (currentClass = currentClass.getSuperclass()) != null) { |
278 | | - subclassDescriptor = subclassDescriptors.get(currentClass.getName()); |
279 | | - } |
280 | | - } |
281 | | - |
| 266 | + ClassDescriptor subclassDescriptor = subclassDescriptors.get(entityName); |
282 | 267 | return subclassDescriptor != null ? subclassDescriptor : this; |
283 | 268 | } |
284 | 269 |
|
285 | 270 | public Collection<ObjAttribute> getDiscriminatorColumns() { |
286 | | - return allDiscriminatorColumns != null ? allDiscriminatorColumns : Collections.<ObjAttribute> emptyList(); |
| 271 | + return allDiscriminatorColumns != null ? allDiscriminatorColumns : Collections.emptyList(); |
287 | 272 | } |
288 | 273 |
|
289 | 274 | public Collection<AttributeProperty> getIdProperties() { |
|
0 commit comments