private void InitFieldData(bool justLoading) { if (!InsertMode && GetTransaction().CachingPolicy.ShouldCacheObject(this)) { SoodaCacheEntry cachedData = GetTransaction().Cache.Find(GetClassInfo().GetRootClass().Name, _primaryKeyValue); if (cachedData != null) { GetTransaction().Statistics.RegisterCacheHit(); SoodaStatistics.Global.RegisterCacheHit(); if (logger.IsTraceEnabled) { logger.Trace("Initializing object {0}({1}) from cache.", this.GetType().Name, _primaryKeyValue); } _fieldValues = cachedData.Data; _dataLoadedMask = cachedData.DataLoadedMask; FromCache = true; return; } // we don't register a cache miss when we're just loading if (!justLoading) { GetTransaction().Statistics.RegisterCacheMiss(); SoodaStatistics.Global.RegisterCacheMiss(); if (logger.IsTraceEnabled) { logger.Trace("Cache miss. Object {0}({1}) not found in cache.", this.GetType().Name, _primaryKeyValue); } } } ClassInfo ci = GetClassInfo(); int fieldCount = ci.UnifiedFields.Count; _fieldValues = InitFieldValues(fieldCount, ci.OrderedFieldNames); GetTransaction().Statistics.RegisterFieldsInited(); SoodaStatistics.Global.RegisterFieldsInited(); // primary key was set before the fields - propagate the value // back to the field(s) if (_primaryKeyValue != null) { PropagatePrimaryKeyToFields(); } if (InsertMode) { SetDefaultNotNullValues(); } }
internal void CopyOnWrite() { if (FromCache) { _fieldValues = _fieldValues.Clone(); FromCache = false; } }