Project

General

Profile

change_broker_lazy.patch

Alexandru Lungu, 03/09/2023 05:50 AM

Download (3.2 KB)

View differences:

src/com/goldencode/p2j/persist/AdaptiveQuery.java 2023-03-09 10:49:47 +0000
349 349
**                           set is created, ProgressiveResults can no longer be the type returned.
350 350
**     RAA 20230221          If the query will be executed lazy, then it is no longer registered as a 
351 351
**                           listener.
352
**     RAA 20230302          Added a condition that checks if the buffer is active before seeing if the query
353
**                           supports lazy mode. This is part of the registration as a listener process.
352 354
*/
353 355

  
354 356
/*
......
559 561
      
560 562
      adapter = new ResultsAdapter(new ResultsSource());
561 563
      
562
      ChangeBroker.get().addListener(this);
564
      registerRecordChangeListeners(null);
563 565
      
564 566
      TransactionManager.registerOffEndQuery(this);
565 567
      
......
592 594
      
593 595
      adapter = new ResultsAdapter(new ResultsSource());
594 596
      
595
      ChangeBroker.get().addListener(this);
597
      registerRecordChangeListeners(null);
596 598
      
597 599
      TransactionManager.registerOffEndQuery(this);
598 600
      
......
665 667
         addWhereExpression(whereExpr);
666 668
      }
667 669
      
668
      ChangeBroker.get().addListener(this);
669
//      buffer persistence may not be active yet - what do we do? what about scrolling?
670
//      if (buffer == null || !buffer.getPersistence().supportsLazyQueryResultsMode())
671
//      {
672
//         ChangeBroker.get().addListener(this);
673
//      }
670
      // Queries over temporary tables have their invalidation dealt with by the
671
      // lazy mechanism, so there is no need to register them as listeners.
672
      if (buffer == null || 
673
          !buffer.isActive() || 
674
          !buffer.getPersistence().supportsLazyQueryResultsMode() || 
675
          getTableCount() > 1)
676
      {
677
         registerRecordChangeListeners(null);
678
      }
674 679
      
675 680
      return this;
676 681
   }
......
1145 1150
    *          Scope at which listeners should be registered with the change
1146 1151
    *          broker.
1147 1152
    */
1148
   public void registerRecordChangeListeners(int scope)
1153
   public void registerRecordChangeListeners(Integer scope)
1149 1154
   {
1155
      if (scope == null)
1156
      {
1157
         ChangeBroker.get().addListener(this);
1158
         return;
1159
      }
1160
      
1150 1161
      ChangeBroker.get().addListener(this, scope);
1151 1162
      
1152 1163
      // if these were added as global listeners in ChangeBroker remember to remove them
......
2237 2248
   throws PersistenceException
2238 2249
   {      
2239 2250
      ArrayList<QueryComponent> components = components();
2240
      // rather check persistence if supports this
2241
      if (components.size() == 1 && components.get(0).getBuffer().isTemporary() && !isScrolling())
2242
      {
2243
         return;
2244
      }
2251

  
2245 2252
      boolean preselect = isPreselect();
2246 2253
      boolean invalidate = true;
2247 2254
      boolean cacheAll = false;
......
3006 3013
   {
3007 3014
      Results results = null;
3008 3015
      boolean lazyMode = persistence.supportsLazyQueryResultsMode();
3009
      if (lazyMode && !isScrolling())
3016
      if (lazyMode)
3010 3017
      {
3011 3018
         Long templateRowid = getTemplateQueryRowid(args);
3012 3019
         if (templateRowid != null)