cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Nikita Timofeev (Jira)" <>
Subject [jira] [Updated] (CAY-2667) Fix Issues with Generic Vertical Inheritance
Date Tue, 06 Oct 2020 12:45:00 GMT


Nikita Timofeev updated CAY-2667:
    Fix Version/s: 4.2.M3

> Fix Issues with Generic Vertical Inheritance
> --------------------------------------------
>                 Key: CAY-2667
>                 URL:
>             Project: Cayenne
>          Issue Type: Bug
>          Components: Core Library
>            Reporter: Matt Watson
>            Priority: Major
>              Labels: Generic, inheritance, vertical
>             Fix For: 4.2.M3
>          Time Spent: 0.5h
>  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
> *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

View raw message