prefetching & restrictingQualifier implemented with DataContextDelegate.willPerformSelect()

From: Mike Kienenberger (mkienen..laska.net)
Date: Mon Oct 06 2003 - 15:47:52 EDT

  • Next message: Borys Burnayev: "A Modeller Question"

    Even though I've gotten past the prefetching problems caused by missing
    reverse dbRelationships, I'm still having to disable prefetching because I
    cannot figure out how to apply restrictingQualifiers to them.

    For the simple non-prefetch case, GenericSelectQuery.getRoot() contains the
    class of the DataObject which can be used to look up the
    restrictingQualifier.

    For the prefetch case, GenericSelectQuery.getRoot() returns an ObjEntity,
    but I've been unable to determine how to get a list of all of the
    ObjEntities in order to apply all of the appropriate restrictingQualifers.
    At best, I only get one of them using anObjEntity.getClassName().

    Maybe this is because there is no such list available yet?

    -Mike

            public GenericSelectQuery willPerformSelect(
                    DataContext aDataContext,
                    GenericSelectQuery aGenericSelectQuery)
            {
                    if (aGenericSelectQuery instanceof SelectQuery)
                    {
                            SelectQuery aSelectQuery = (SelectQuery)aGenericSelectQuery;
                            Object aSelectQueryRoot = aSelectQuery.getRoot();
                                            
                            if (aSelectQueryRoot instanceof Class)
                            {
                                    // called with no prefetching -- aSelectQueryRoot is class to restrict.
                                    Class aClass = (Class)aSelectQueryRoot;
                                            
                                    Expression restrictingQualifer = getRestrictingQualifier(aClass);
                                    if (null != restrictingQualifer)
                                    {
                                            aSelectQuery.andQualifier(restrictingQualifer);
                                            return aSelectQuery;
                                    }
                            }
                            else if (aSelectQueryRoot instanceof ObjEntity)
                            {
                                    // called with prefetching -- aSelectQueryRoot is ObjEntity
                                    // anObjEntity.getClassName() is only one of the classes to restrict
                                    ObjEntity anObjEntity = (ObjEntity)aSelectQueryRoot;
                            }
                            else // ?
                    }

                    return aGenericSelectQuery;
            }



    This archive was generated by hypermail 2.0.0 : Mon Oct 06 2003 - 15:47:27 EDT