Uploaded image for project: 'Cayenne'
  1. Cayenne
  2. CAY-2778

Inheritance: queries on superclass should support subclass prefetches

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 4.2.RC1
    • 5.0-M2
    • None
    • None

    Description

      For an entity inheritance hierarchy, fetching on superclass should allow prefetches on subclasses. Semantically they can be resolved as DbRelationships, and the results can be applied only to the right subclasses.

      E.g. in our unit tests (where somewhat weirdly, User inherits from Role), the following code throws, while it should succeed (see attached patch with a full test) :

      ObjectSelect.query(Role.class)
         .prefetch(User.USER_PROPERTIES.joint())
         .select(context)
      

      This would allow to properly deep-refresh objects across the inheritance hierarchy.

      I suspect that we may eventually decide to similarly support orderings and qualifiers based on subclass attributes (so any common SQL translator algorithms should be generalized across use cases). But prefetching seems like the most useful initial case.

      Attachments

        1. diff.txt
          3 kB
          Andrus Adamchik

        Activity

          People

            Unassigned Unassigned
            andrus Andrus Adamchik
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: