Changeset 5067
- Timestamp:
- Aug 20, 2009, 8:24:48 AM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/core/net/sf/basedb/core/log/EntityDetails.java
r5052 r5067 27 27 28 28 import org.hibernate.EntityMode; 29 import org.hibernate.collection.PersistentCollection; 29 30 import org.hibernate.type.Type; 30 31 import org.hibernate.type.VersionType; … … 54 55 private final String[] properties; 55 56 private final Type[] types; 57 private final int[] dirty; 56 58 57 59 public EntityDetails(EntityLogger logger, Object entity, ChangeType changeType, … … 65 67 this.properties = properties; 66 68 this.types = types; 69 this.dirty = new int[types.length]; // 0 = not known, -1 = not dirty, 1 = dirty 70 findDirtyCollections(); 67 71 } 68 72 … … 147 151 for (int i = 0; i < types.length; ++i) 148 152 { 149 Type t = types[i]; 150 if (!t.isCollectionType() && !(t instanceof VersionType)) 153 if (dirty[i] == 0) 151 154 { 152 Object c = state[i]; 153 Object o = previousState[i]; 154 if (!t.isEqual(c, o, EntityMode.POJO)) 155 Type t = types[i]; 156 if (!t.isCollectionType() && !(t instanceof VersionType)) 155 157 { 156 modified.append(s).append(properties[i]);157 s = separator;158 numModified++;158 Object c = state[i]; 159 Object o = previousState[i]; 160 dirty[i] = t.isEqual(c, o, EntityMode.POJO) ? -1 : 1; 159 161 } 162 } 163 if (dirty[i] == 1) 164 { 165 modified.append(s).append(properties[i]); 166 s = separator; 167 numModified++; 160 168 } 161 169 } … … 200 208 return details; 201 209 } 210 211 /** 212 We must do this from the constructor since the "dirtyness" of a 213 collection is reset after flush the SQL to the database, which is 214 completed before the rest of the logging is done. 215 */ 216 private void findDirtyCollections() 217 { 218 for (int i = 0; i < types.length; ++i) 219 { 220 Type t = types[i]; 221 if (t.isCollectionType()) 222 { 223 Object c = state[i]; 224 if (c instanceof PersistentCollection) 225 { 226 dirty[i] = ((PersistentCollection)c).isDirty() ? 1 : -1; 227 } 228 } 229 } 230 } 231 202 232 }
Note: See TracChangeset
for help on using the changeset viewer.