Beispiel #1
0
        /// <summary>
        /// Determine if any of the given field values are modified,
        /// returning an array containing indexes of
        /// the dirty fields or null if no fields are modified.
        /// </summary>
        public static int[] FindModified(
            StandardProperty[] properties,
            object[] x,
            object[] y,
            bool[][] includeColumns,
            bool anyUninitializedProperties,
            ISessionImplementor session)
        {
            int[] results = null;
            int count = 0;
            int span = properties.Length;

            for (int i = 0; i < span; i++)
            {
                bool dirty =
                    // TODO H3: x[ i ] != LazyPropertyInitializer.UnfetchedProperty && //x is the "current" state
                    properties[i].IsDirtyCheckable(anyUninitializedProperties)
                    && properties[i].Type.IsModified(y[i], x[i], includeColumns[i], session);

                if (dirty)
                {
                    if (results == null)
                    {
                        results = new int[span];
                    }
                    results[count++] = i;
                }
            }
            if (count == 0)
            {
                return null;
            }
            else
            {
                int[] trimmed = new int[count];
                System.Array.Copy(results, 0, trimmed, 0, count);
                return trimmed;
            }
        }
		private ValueInclusion DetermineUpdateValueGenerationType(Mapping.Property mappingProperty, StandardProperty runtimeProperty)
		{
			if (runtimeProperty.IsUpdateGenerated)
			{
				return ValueInclusion.Full;
			}
			else if (mappingProperty.Value is Component)
			{
				if (HasPartialUpdateComponentGeneration((Component) mappingProperty.Value))
				{
					return ValueInclusion.Partial;
				}
			}
			return ValueInclusion.None;
		}
Beispiel #3
0
		private static bool Dirty(StandardProperty[] properties, object[] currentState, object[] previousState, bool[][] includeColumns, bool anyUninitializedProperties, ISessionImplementor session, int i)
		{
			if (Equals(LazyPropertyInitializer.UnfetchedProperty, currentState[i]))
				return false;
			if (Equals(LazyPropertyInitializer.UnfetchedProperty, previousState[i]))
				return true;
			return properties[i].IsDirtyCheckable(anyUninitializedProperties) &&
				   properties[i].Type.IsDirty(previousState[i], currentState[i], includeColumns[i], session);
		}
Beispiel #4
0
		/// <summary>
		/// <para>Determine if any of the given field values are modified, returning an array containing
		/// indices of the modified fields.</para>
		/// <para>If it is determined that no fields are dirty, null is returned.</para>
		/// </summary>
		/// <param name="properties">The property definitions</param>
		/// <param name="currentState">The current state of the entity</param>
		/// <param name="previousState">The baseline state of the entity</param>
		/// <param name="includeColumns">Columns to be included in the mod checking, per property</param>
		/// <param name="anyUninitializedProperties">Does the entity currently hold any uninitialized property values?</param>
		/// <param name="session">The session from which the dirty check request originated.</param>
		/// <returns>Array containing indices of the modified properties, or null if no properties considered modified.</returns>
		public static int[] FindModified(StandardProperty[] properties,
											object[] currentState,
											object[] previousState,
											bool[][] includeColumns,
											bool anyUninitializedProperties,
											ISessionImplementor session)
		{
			int[] results = null;
			int count = 0;
			int span = properties.Length;

			for (int i = 0; i < span; i++)
			{
				bool dirty =
					!Equals(LazyPropertyInitializer.UnfetchedProperty, currentState[i]) &&
					properties[i].IsDirtyCheckable(anyUninitializedProperties)
					&& properties[i].Type.IsModified(previousState[i], currentState[i], includeColumns[i], session);

				if (dirty)
				{
					if (results == null)
					{
						results = new int[span];
					}
					results[count++] = i;
				}
			}
			if (count == 0)
			{
				return null;
			}
			else
			{
				int[] trimmed = new int[count];
				Array.Copy(results, 0, trimmed, 0, count);
				return trimmed;
			}
		}
Beispiel #5
0
		/// <summary>
		/// <para>Determine if any of the given field values are dirty, returning an array containing
		/// indices of the dirty fields.</para>
		/// <para>If it is determined that no fields are dirty, null is returned.</para>
		/// </summary>
		/// <param name="properties">The property definitions</param>
		/// <param name="currentState">The current state of the entity</param>
		/// <param name="previousState">The baseline state of the entity</param>
		/// <param name="includeColumns">Columns to be included in the dirty checking, per property</param>
		/// <param name="anyUninitializedProperties">Does the entity currently hold any uninitialized property values?</param>
		/// <param name="session">The session from which the dirty check request originated.</param>
		/// <returns>Array containing indices of the dirty properties, or null if no properties considered dirty.</returns>
		public static int[] FindDirty(StandardProperty[] properties,
										object[] currentState,
										object[] previousState,
										bool[][] includeColumns,
										bool anyUninitializedProperties,
										ISessionImplementor session)
		{
			int[] results = null;
			int count = 0;
			int span = properties.Length;

			for (int i = 0; i < span; i++)
			{
				var dirty = Dirty(properties, currentState, previousState, includeColumns, anyUninitializedProperties, session, i);
				if (dirty)
				{
					if (results == null)
					{
						results = new int[span];
					}
					results[count++] = i;
				}
			}
			if (count == 0)
			{
				return null;
			}
			else
			{
				int[] trimmed = new int[count];
				Array.Copy(results, 0, trimmed, 0, count);
				return trimmed;
			}
		}