Re:Re:Re: Prefetched Query

From: emre.yilma..r.net
Date: Mon Feb 27 2006 - 10:13:48 EST

  • Next message: Borut Bolčin: "Maven"

    Andrus,

    I attached the DataMap files but you should use the below code with this
    attachments.

    Example:
     set the attributes as below
    PersonelCard.badgeNo = 12,
    PersonelCard.personelRel.personelIdentityRel.firstName = emre

    run the main metod

    output :
    getBadgeNo 12
    getFirstName emre

    set:
    PersonelCard.badgeNo = 12,
    PersonelCard.personelRel.personelIdentityRel.firstName = sam

    output :
    getBadgeNo 12
    getFirstName sam

    set:
    PersonelCard.badgeNo = 12,
    PersonelCard.personelRel.personelIdentityRel.firstName = emre

    output :
    getBadgeNo 12
    getFirstName emre =====>>>> This outputs correct but

    set:
    PersonelCard.badgeNo = 11,
    PersonelCard.personelRel.personelIdentityRel.firstName = sam

    output :
    not Found :12

    set:
    PersonelCard.badgeNo = 12,
    PersonelCard.personelRel.personelIdentityRel.firstName = sam

    output :
    not Found :12 ====>This output wrong because badgeNo = 12 but not found

    public static void main(String[]arg){
               DbObject.setContext();
               while(true){
                       List list = getLists(); //refresh
                       int badgeNo = 12;
                       Expression qualifier = ExpressionFactory.matchExp(
                                       BADGE_NO_PROPERTY, new Integer(badgeNo));
                       List list1 = qualifier.filterObjects(list);
                       if((list1 != null) && (list1.size() > 0)){
                               
                               PersonelCard card = (PersonelCard)list1.get(0);
                               System.err.println("getBadgeNo "+card.getBadgeNo());
                               System.err.println("getFirstName "+card.getPersonelRel().
    getPersonelIdentityRel().getFirstName());
                       } else{
                               System.err.println("not Found :"+badgeNo);
                       }
                       try{
                               Thread.sleep(2000);
                       }catch(Exception e){
                               
                       }
               }
       }

    public static List getLists() {

               SelectQuery query = new SelectQuery(PersonelCard.class);
               Expression qualifier = ExpressionFactory.matchExp(ASSIGNED_PROPERTY, new
               Boolean(true));
               query.setQualifier(qualifier);
               qualifier = ExpressionFactory.noMatchExp(BADGE_NO_PROPERTY, null);
               query.andQualifier(qualifier);
               qualifier = ExpressionFactory.noMatchExp(BADGE_NO_PROPERTY, new Integer
    (0));
               query.andQualifier(qualifier);
               qualifier = ExpressionFactory.noMatchExp(TRANSPONDER_NO_PROPERTY, null);
               query.andQualifier(qualifier);
               qualifier = ExpressionFactory.noMatchExp(PERSONEL_REL_PROPERTY, null);
               query.andQualifier(qualifier);
               qualifier = ExpressionFactory.matchExp("personelRel.deleted", new Boolean
               (false));
               query.andQualifier(qualifier);

               query.setRefreshingObjects(true);
               query.setCachePolicy(QueryMetadata.LOCAL_CACHE_REFRESH);
               query.removePrefetch("personelRel");
               query.removePrefetch("personelRel.personelIdentityRel");
               query.removePrefetch("cardValidtyRel");
               query.addPrefetch("personelRel").setSemantics(
               PrefetchTreeNode.JOINT_PREFETCH_SEMANTICS);
               query.addPrefetch("personelRel.personelIdentityRel").setSemantics(
                               PrefetchTreeNode.JOINT_PREFETCH_SEMANTICS);
               query.addPrefetch("cardValidtyRel").setSemantics(
               PrefetchTreeNode.JOINT_PREFETCH_SEMANTICS);
               return context.performQuery(query);
               }



    This archive was generated by hypermail 2.0.0 : Mon Feb 27 2006 - 10:13:13 EST