[
https://issues.apache.org/jira/browse/CAY-2667?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Nikita Timofeev closed CAY-2667.
--------------------------------
Resolution: Fixed
> Fix Issues with Generic Vertical Inheritance
> --------------------------------------------
>
> Key: CAY-2667
> URL: https://issues.apache.org/jira/browse/CAY-2667
> Project: Cayenne
> Issue Type: Bug
> Components: Core Library
> Reporter: Matt Watson
> Assignee: Nikita Timofeev
> Priority: Major
> Labels: Generic, inheritance, vertical
> Fix For: 5.0-M1
>
> Time Spent: 50m
> Remaining Estimate: 0h
>
> I discovered a couple issues when trying to implement Vertical Inheritance
> using Generic Persistent Classes (Java-less)
> *The 1st issue* is that one of the Subclasses will get the wrong Qualifier
> assigned because the wrong ObjEntity is returned during
> BaseContext.injectInitialValue because the
> MappingCache.objEntitiesByClassName is keyed by class-name so it can only
> hold one of the possible many generic ObjEntities.
> See Test and DataMap implementing a Generic Student that has sub Entities of
> a Generic Boy and a Generic Girl.
> It inserts 2 records into [gen_student], 1 record into [gen_boy], 1 record
> into [gen_girl], but the [type] on both student records is "G", instead of
> one "B" and one "G".
> When creating the GenBoy ... the line:
> getEntityResolver().getObjEntity(object.getClass()) its returning the "Girl"
> ObjEntity
> the MappingCache.objEntitiesByClassName holds an entry for
> "CayenneDataObject" with value for Girl ObjEntity. When using Generics there
> will be many ObjEntities that use CayenneDataObject, so we shouldn't be
> asking for it from this cache Map.
> instead we should use: getEntityResolver().getObjEntity((Persistent)object)
> because that one is properly getting the correct ObjEntity from the ObjectId,
> in MappingCache.getObjEntity(Persistent object)
> *The 2nd issue* is that when querying for GenStudents, it returns the correct
> records, but only the Girl is populated and the Boy is HOLLOW, because the
> query generated does not do a left join to gen_boy.
> {code:java}
> ObjectSelect.query(DataObject.class, "GenStudent").select(context);
> {code}
> This happens because PersistentDescriptor.subclassDescriptors is a map keyed
> by a class name, so the 2nd one overwrites the first one. This map should be
> keyed by the ObjEntity name to support Generic Persistent Classes.
> There is a test included that will show that with my fixes the
> PersistentDescriptor.subclassDescriptors now can hold the 2 ClassDescriptors
> for the 2 generic Sub ObjEntities.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)