=== modified file 'src/com/goldencode/p2j/persist/AbstractQuery.java'
--- old/src/com/goldencode/p2j/persist/AbstractQuery.java	2024-11-28 03:26:23 +0000
+++ new/src/com/goldencode/p2j/persist/AbstractQuery.java	2025-01-08 07:53:15 +0000
@@ -258,6 +258,7 @@
 ** 104 OM  20241128          Multi-tenant runtime support: selected the proper persistence context, eventually
 **                           based on [sharedDb] parameter.
 **                           Implementation of [setMultiTenantAlternative] method.
+** 105 SP  20250108          Added dmo interfaces to the SortCacheKey.
 */
 
 /*
@@ -681,7 +682,11 @@
          return null;
       }
 
-      SortCacheKey sortCacheKey = new SortCacheKey(bound.getDMOAlias(), definition.getDMOAlias(), sort);
+      SortCacheKey sortCacheKey = new SortCacheKey(bound.getDMOAlias(),
+                                                   definition.getDMOAlias(),
+                                                   bound.getDMOInterface(),
+                                                   definition.getDMOInterface(),
+                                                   sort);
       String translatedSort;
 
       synchronized (sortCache)
@@ -4704,6 +4709,12 @@
       /** Definition buffer alias */
       private final String defAlias;
 
+      /** Bound buffer dmo interface */
+      private final Class<?> boundDmoIface;
+
+      /** Definition buffer dmo interface */
+      private final Class<?> defDmoIface;
+
       /** The sort clause to be translated */
       private final String sort;
 
@@ -4720,10 +4731,16 @@
        * @param   sort
        *          The sort clause to be translated.
        */
-      SortCacheKey(String boundAlias, String defAlias, String sort)
+      SortCacheKey(String boundAlias,
+                   String defAlias,
+                   Class<?> boundDmoIface,
+                   Class<?> defDmoIface,
+                   String sort)
       {
          this.boundAlias = boundAlias;
          this.defAlias = defAlias;
+         this.boundDmoIface = boundDmoIface;
+         this.defDmoIface = defDmoIface;
          this.sort = sort;
          // since this object is immutable (all fields are private/final) we can compute now the
          // hash code and cache it for when needed, to improve performance
@@ -4757,8 +4774,10 @@
 
          AbstractQuery.SortCacheKey that = (AbstractQuery.SortCacheKey) o;
 
-         if (!boundAlias.equals(that.boundAlias) ||
-             !defAlias.equals(that.defAlias) ||
+         if (!boundAlias.equals(that.boundAlias)       ||
+             !defAlias.equals(that.defAlias)           ||
+             !boundDmoIface.equals(that.boundDmoIface) ||
+             !defDmoIface.equals(that.defDmoIface)     ||
              !sort.equals(that.sort))
          {
             return false;
@@ -4778,6 +4797,8 @@
          result = 37 * result + sort.hashCode();
          result = 37 * result + boundAlias.hashCode();
          result = 37 * result + defAlias.hashCode();
+         result = 37 * result + boundDmoIface.hashCode();
+         result = 37 * result + defDmoIface.hashCode();
          return result;
       }
    }

=== modified file 'src/com/goldencode/p2j/persist/FQLPreprocessor.java'
--- old/src/com/goldencode/p2j/persist/FQLPreprocessor.java	2024-10-18 06:24:51 +0000
+++ new/src/com/goldencode/p2j/persist/FQLPreprocessor.java	2025-01-08 07:53:15 +0000
@@ -342,6 +342,7 @@
 ** 115 SP  20241016          Added caching of translate() output.
 ** 116 SP  20241018          If the where clause is null in translate(), just exit and return null,
 **                           as there is nothing to translate or cache.
+** 117 SP  20250108          Added dmo interfaces to the TranslateCacheKey.
 */
 
 /*
@@ -1095,14 +1096,24 @@
       }
       String[] boundAliases = new String[bounds];
       String[] defAliases = new String[bounds];
+      Class<?>[] boundDmoIfaces = new Class<?>[bounds];
+      Class<?>[] defDmoIfaces = new Class<?>[bounds];
 
       for (int i = 0; i < bounds; i++)
       {
-         boundAliases[i] = bound.get(i).getDMOAlias();
-         defAliases[i] = definition.get(i).getDMOAlias();
+         RecordBuffer boundBuf = bound.get(i);
+         RecordBuffer defBuf = bound.get(i);
+         boundAliases[i] = boundBuf.getDMOAlias();
+         defAliases[i] = defBuf.getDMOAlias();
+         boundDmoIfaces[i] = boundBuf.getDMOInterface();
+         defDmoIfaces[i] = defBuf.getDMOInterface();
       }
 
-      TranslateCacheKey translateCacheKey = new TranslateCacheKey(boundAliases, defAliases, where);
+      TranslateCacheKey translateCacheKey = new TranslateCacheKey(boundAliases,
+                                                                  defAliases,
+                                                                  boundDmoIfaces,
+                                                                  defDmoIfaces,
+                                                                  where);
 
       String finalTranslate;
       synchronized (translateCache)
@@ -6915,6 +6926,12 @@
       /** Definition buffers aliases */
       private final String[] defAliases;
 
+      /** Bound buffers dmo interfaces */
+      private final Class<?>[] boundDmoIfaces;
+
+      /** Definition buffers dmo interfaces */
+      private final Class<?>[] defDmoIfaces;
+
       /** Where clause */
       private final String where;
 
@@ -6931,10 +6948,16 @@
       * @param   where
       *          Where clause.
       */
-      TranslateCacheKey(String[] boundAliases, String[] defAliases, String where)
+      TranslateCacheKey(String[] boundAliases,
+                        String[] defAliases,
+                        Class<?>[] boundDmoIfaces,
+                        Class<?>[] defDmoIfaces,
+                        String where)
       {
          this.boundAliases = boundAliases;
          this.defAliases = defAliases;
+         this.boundDmoIfaces = boundDmoIfaces;
+         this.defDmoIfaces = defDmoIfaces;
          this.where = where;
          // since this object is immutable (all fields are private/final) we can compute now the
          // hash code and cache it for when needed, to improve performance
@@ -6968,8 +6991,10 @@
 
          TranslateCacheKey that = (TranslateCacheKey) o;
 
-         if (!Arrays.equals(boundAliases, that.boundAliases) ||
-             !Arrays.equals(defAliases, that.defAliases) ||
+         if (!Arrays.equals(boundAliases, that.boundAliases)     ||
+             !Arrays.equals(defAliases, that.defAliases)         ||
+             !Arrays.equals(boundDmoIfaces, that.boundDmoIfaces) ||
+             !Arrays.equals(defDmoIfaces, that.defDmoIfaces)     ||
              !where.equals(that.where))
          {
              return false;
@@ -6989,6 +7014,8 @@
          result = 37 * result + where.hashCode();
          result = 37 * result + Arrays.hashCode(boundAliases);
          result = 37 * result + Arrays.hashCode(defAliases);
+         result = 37 * result + Arrays.hashCode(boundDmoIfaces);
+         result = 37 * result + Arrays.hashCode(defDmoIfaces);
          return result;
       }
    }

