Project

General

Profile

6720_fix.patch

Teodor Gorghe, 05/07/2026 08:40 AM

Download (5.28 KB)

View differences:

new/src/com/goldencode/p2j/persist/orm/BaseRecord.java 2026-05-07 12:39:49 +0000
2 2
** Module   : BaseRecord.java
3 3
** Abstract : The abstract base class for all business data model object classes.
4 4
**
5
** Copyright (c) 2019-2025, Golden Code Development Corporation.
5
** Copyright (c) 2019-2026, Golden Code Development Corporation.
6 6
**
7 7
** -#- -I- --Date-- ---------------------------------------Description---------------------------------------
8 8
** 001 ECF 20191001 Created initial version with basic data and accessors.
......
58 58
**     AL2 20231102 Added computeIndexForHydrator for lazy hydration. Reworked getDatum.
59 59
**     AL2 20231106 Set liveProps only when actively doing lazy hydration. Compute cardinality separately.
60 60
**     AL2 20231218 Fixed lazy hydration to honor refreshing. Fixed getUnhydratedFields to honor incomplete.
61
** 017 AP  20250807 Adapted equalData for lazy hydration. 
61
**     AP  20250807 Adapted equalData for lazy hydration. 
62
**     TG  20260407 Added clearHydrator method. NPE fix on setAllLiveProps.
62 63
*/
63 64

  
64 65
/*
......
1021 1022
   
1022 1023
   protected void setAllLiveProps()
1023 1024
   {
1025
      if (liveProps == null)
1026
      {
1027
         return;
1028
      }
1024 1029
      for (int i = 0; i < data.length; i++)
1025 1030
      {
1026 1031
         liveProps.set(i);
......
1262 1267
         unhydratedIndex = unhydratedFields.nextSetBit(unhydratedIndex + 1);
1263 1268
      }
1264 1269
   }
1270

  
1271
   /**
1272
    * Set the {@link BaseRecord#hydrator} to {@code #Null}.
1273
    */
1274
   public void clearHydrator()
1275
   {
1276
      hydrator = null;
1277
   }
1265 1278
   
1266 1279
   /**
1267 1280
    * Get the static record metadata for the concrete subclass.
new/src/com/goldencode/p2j/persist/orm/SQLQuery.java 2026-05-07 12:40:07 +0000
2 2
** Module   : SQLQuery.java
3 3
** Abstract : Object which performs an SQL query and processes the results.
4 4
**
5
** Copyright (c) 2019-2025, Golden Code Development Corporation.
5
** Copyright (c) 2019-2026, Golden Code Development Corporation.
6 6
**
7 7
** -#- -I- --Date-- ---------------------------------------Description---------------------------------------
8 8
** 001 ECF 20191001 Created initial version with stubbed methods.
......
73 73
** 022 LS  20250714 Do not reload an INCOMPLETE record in 'hydrateRecordImpl' if the needed fields are
74 74
**                  already set.
75 75
** 023 ECF 20230803 Prototyped lazy hydration.
76
** 024 AL2 20231211 Refactor to use new getters for row structure count and DMO iface. 
76
**     AL2 20231211 Refactor to use new getters for row structure count and DMO iface. 
77 77
**     AL2 20231102 Reworked hydration to better support lazy with partial. 
78 78
**     AL2 20231103 Added JMX to track lazy hydration.
79 79
**     AL2 20231101 Allow the some result-sets to be owned by the session to make it live longer and honor
80 80
**                  lazy hydration.
81 81
**     AL2 20231214 Fixed lazy hydration to work with partial hydration as well. Fixed rebase mismatches.
82
**     TG  20260407 Added updateIncompleteState which updates cached INCOMPLETE dmo.
82 83
*/
83 84

  
84 85
/*
......
1127 1128
               NEW_LAZY_RECORD.update(1);
1128 1129
               session.associate(r);
1129 1130
            }
1131
            else
1132
            {
1133
               updateIncompleteState(r, rowStructure, session);
1134
            }
1130 1135
            
1131 1136
            return r;
1132 1137
         }
1138
         else if (cachedRec != null)
1139
         {
1140
            // We are not in lazy mode, but in Session cache we have a DMO which was not hydrated yet,
1141
            // or we have an INCOMPLETE DMO that needs further hydration.
1142
            rowStructure.hydrate(session, resultSet, rsOffset, r);
1143

  
1144
            updateIncompleteState(r, rowStructure, session);
1145

  
1146
            return r;
1147
         }
1133 1148

  
1134 1149
         NON_LAZY_HYDRATE_RECORD.update(1);
1135 1150
      }
......
1162 1177
         
1163 1178
         // cache the hydrated record
1164 1179
         session.associate(r);
1165
      }      catch (ReflectiveOperationException exc)
1180
      }
1181
      catch (ReflectiveOperationException exc)
1166 1182
      {
1167 1183
         throw new PersistenceException("Error creating record", exc);
1168 1184
      }
......
1181 1197
      
1182 1198
      return r;
1183 1199
   }
1184
   
1200

  
1201
   /**
1202
    * Check the {@link BaseRecord} is it should still be marked as INCOMPLETE or not.
1203
    * If it still INCOMPLETE, update {@link BaseRecord#readFields} to match with the current
1204
    * {@link RowStructure}.
1205
    *
1206
    * @param   r
1207
    *          Record to check
1208
    * @param   rowStructure
1209
    *          Used if is INCOMPLETE and to get the loaded fields.
1210
    * @param   session
1211
    *          Current Session
1212
    */
1213
   private static void updateIncompleteState(BaseRecord r, RowStructure rowStructure, Session session)
1214
   {
1215
      if (r.checkState(DmoState.INCOMPLETE))
1216
      {
1217
         if (!rowStructure.isIncomplete())
1218
         {
1219
            r.updateState(session, DmoState.INCOMPLETE, false);
1220
         }
1221
         else if (r._getReadFields() != null)
1222
         {
1223
            r._getReadFields().or(rowStructure.getLoadedFields());
1224
         }
1225
      }
1226
   }
1227

  
1185 1228
   /**
1186 1229
    * Closes this object by releasing all acquired resources.
1187 1230
    */