Project

General

Profile

9251c.patch

Stefanel Pezamosca, 01/08/2025 03:03 AM

Download (6.98 KB)

View differences:

new/src/com/goldencode/p2j/persist/AbstractQuery.java 2025-01-08 07:53:15 +0000
258 258
** 104 OM  20241128          Multi-tenant runtime support: selected the proper persistence context, eventually
259 259
**                           based on [sharedDb] parameter.
260 260
**                           Implementation of [setMultiTenantAlternative] method.
261
** 105 SP  20250108          Added dmo interfaces to the SortCacheKey.
261 262
*/
262 263

  
263 264
/*
......
681 682
         return null;
682 683
      }
683 684

  
684
      SortCacheKey sortCacheKey = new SortCacheKey(bound.getDMOAlias(), definition.getDMOAlias(), sort);
685
      SortCacheKey sortCacheKey = new SortCacheKey(bound.getDMOAlias(),
686
                                                   definition.getDMOAlias(),
687
                                                   bound.getDMOInterface(),
688
                                                   definition.getDMOInterface(),
689
                                                   sort);
685 690
      String translatedSort;
686 691

  
687 692
      synchronized (sortCache)
......
4704 4709
      /** Definition buffer alias */
4705 4710
      private final String defAlias;
4706 4711

  
4712
      /** Bound buffer dmo interface */
4713
      private final Class<?> boundDmoIface;
4714

  
4715
      /** Definition buffer dmo interface */
4716
      private final Class<?> defDmoIface;
4717

  
4707 4718
      /** The sort clause to be translated */
4708 4719
      private final String sort;
4709 4720

  
......
4720 4731
       * @param   sort
4721 4732
       *          The sort clause to be translated.
4722 4733
       */
4723
      SortCacheKey(String boundAlias, String defAlias, String sort)
4734
      SortCacheKey(String boundAlias,
4735
                   String defAlias,
4736
                   Class<?> boundDmoIface,
4737
                   Class<?> defDmoIface,
4738
                   String sort)
4724 4739
      {
4725 4740
         this.boundAlias = boundAlias;
4726 4741
         this.defAlias = defAlias;
4742
         this.boundDmoIface = boundDmoIface;
4743
         this.defDmoIface = defDmoIface;
4727 4744
         this.sort = sort;
4728 4745
         // since this object is immutable (all fields are private/final) we can compute now the
4729 4746
         // hash code and cache it for when needed, to improve performance
......
4757 4774

  
4758 4775
         AbstractQuery.SortCacheKey that = (AbstractQuery.SortCacheKey) o;
4759 4776

  
4760
         if (!boundAlias.equals(that.boundAlias) ||
4761
             !defAlias.equals(that.defAlias) ||
4777
         if (!boundAlias.equals(that.boundAlias)       ||
4778
             !defAlias.equals(that.defAlias)           ||
4779
             !boundDmoIface.equals(that.boundDmoIface) ||
4780
             !defDmoIface.equals(that.defDmoIface)     ||
4762 4781
             !sort.equals(that.sort))
4763 4782
         {
4764 4783
            return false;
......
4778 4797
         result = 37 * result + sort.hashCode();
4779 4798
         result = 37 * result + boundAlias.hashCode();
4780 4799
         result = 37 * result + defAlias.hashCode();
4800
         result = 37 * result + boundDmoIface.hashCode();
4801
         result = 37 * result + defDmoIface.hashCode();
4781 4802
         return result;
4782 4803
      }
4783 4804
   }
new/src/com/goldencode/p2j/persist/FQLPreprocessor.java 2025-01-08 07:53:15 +0000
342 342
** 115 SP  20241016          Added caching of translate() output.
343 343
** 116 SP  20241018          If the where clause is null in translate(), just exit and return null,
344 344
**                           as there is nothing to translate or cache.
345
** 117 SP  20250108          Added dmo interfaces to the TranslateCacheKey.
345 346
*/
346 347

  
347 348
/*
......
1095 1096
      }
1096 1097
      String[] boundAliases = new String[bounds];
1097 1098
      String[] defAliases = new String[bounds];
1099
      Class<?>[] boundDmoIfaces = new Class<?>[bounds];
1100
      Class<?>[] defDmoIfaces = new Class<?>[bounds];
1098 1101

  
1099 1102
      for (int i = 0; i < bounds; i++)
1100 1103
      {
1101
         boundAliases[i] = bound.get(i).getDMOAlias();
1102
         defAliases[i] = definition.get(i).getDMOAlias();
1104
         RecordBuffer boundBuf = bound.get(i);
1105
         RecordBuffer defBuf = bound.get(i);
1106
         boundAliases[i] = boundBuf.getDMOAlias();
1107
         defAliases[i] = defBuf.getDMOAlias();
1108
         boundDmoIfaces[i] = boundBuf.getDMOInterface();
1109
         defDmoIfaces[i] = defBuf.getDMOInterface();
1103 1110
      }
1104 1111

  
1105
      TranslateCacheKey translateCacheKey = new TranslateCacheKey(boundAliases, defAliases, where);
1112
      TranslateCacheKey translateCacheKey = new TranslateCacheKey(boundAliases,
1113
                                                                  defAliases,
1114
                                                                  boundDmoIfaces,
1115
                                                                  defDmoIfaces,
1116
                                                                  where);
1106 1117

  
1107 1118
      String finalTranslate;
1108 1119
      synchronized (translateCache)
......
6915 6926
      /** Definition buffers aliases */
6916 6927
      private final String[] defAliases;
6917 6928

  
6929
      /** Bound buffers dmo interfaces */
6930
      private final Class<?>[] boundDmoIfaces;
6931

  
6932
      /** Definition buffers dmo interfaces */
6933
      private final Class<?>[] defDmoIfaces;
6934

  
6918 6935
      /** Where clause */
6919 6936
      private final String where;
6920 6937

  
......
6931 6948
      * @param   where
6932 6949
      *          Where clause.
6933 6950
      */
6934
      TranslateCacheKey(String[] boundAliases, String[] defAliases, String where)
6951
      TranslateCacheKey(String[] boundAliases,
6952
                        String[] defAliases,
6953
                        Class<?>[] boundDmoIfaces,
6954
                        Class<?>[] defDmoIfaces,
6955
                        String where)
6935 6956
      {
6936 6957
         this.boundAliases = boundAliases;
6937 6958
         this.defAliases = defAliases;
6959
         this.boundDmoIfaces = boundDmoIfaces;
6960
         this.defDmoIfaces = defDmoIfaces;
6938 6961
         this.where = where;
6939 6962
         // since this object is immutable (all fields are private/final) we can compute now the
6940 6963
         // hash code and cache it for when needed, to improve performance
......
6968 6991

  
6969 6992
         TranslateCacheKey that = (TranslateCacheKey) o;
6970 6993

  
6971
         if (!Arrays.equals(boundAliases, that.boundAliases) ||
6972
             !Arrays.equals(defAliases, that.defAliases) ||
6994
         if (!Arrays.equals(boundAliases, that.boundAliases)     ||
6995
             !Arrays.equals(defAliases, that.defAliases)         ||
6996
             !Arrays.equals(boundDmoIfaces, that.boundDmoIfaces) ||
6997
             !Arrays.equals(defDmoIfaces, that.defDmoIfaces)     ||
6973 6998
             !where.equals(that.where))
6974 6999
         {
6975 7000
             return false;
......
6989 7014
         result = 37 * result + where.hashCode();
6990 7015
         result = 37 * result + Arrays.hashCode(boundAliases);
6991 7016
         result = 37 * result + Arrays.hashCode(defAliases);
7017
         result = 37 * result + Arrays.hashCode(boundDmoIfaces);
7018
         result = 37 * result + Arrays.hashCode(defDmoIfaces);
6992 7019
         return result;
6993 7020
      }
6994 7021
   }