Exemplo n.º 1
0
        /// <summary>
        /// Initializes a new instance of <see cref="CollectionEntry"/>.
        /// </summary>
        /// <remarks>
        /// For newly wrapped collections, or dereferenced collection wrappers
        /// </remarks>
        public CollectionEntry(ICollectionPersister persister, IPersistentCollection collection)
        {
            // new collections that get found + wrapped
            // during flush shouldn't be ignored
            ignore = false;

            collection.ClearDirty();             //a newly wrapped collection is NOT dirty (or we get unnecessary version updates)

            snapshot = persister.IsMutable ? collection.GetSnapshot(persister) : null;
            collection.SetSnapshot(loadedKey, role, snapshot);
        }
Exemplo n.º 2
0
        public virtual object ReplaceElements(object original, object target, object owner, IDictionary copyCache,
                                              ISessionImplementor session)
        {
            // TODO: does not work for EntityMode.DOM4J yet!
            object result = target;

            Clear(result);

            // copy elements into newly empty target collection
            IType       elemType = GetElementType(session.Factory);
            IEnumerable iter     = (IEnumerable)original;

            foreach (object obj in iter)
            {
                Add(result, elemType.Replace(obj, null, session, owner, copyCache));
            }

            // if the original is a PersistentCollection, and that original
            // was not flagged as dirty, then reset the target's dirty flag
            // here after the copy operation.
            // One thing to be careful of here is a "bare" original collection
            // in which case we should never ever ever reset the dirty flag
            // on the target because we simply do not know...
            IPersistentCollection originalPc = original as IPersistentCollection;
            IPersistentCollection resultPc   = result as IPersistentCollection;

            if (originalPc != null && resultPc != null)
            {
                if (!originalPc.IsDirty)
                {
                    resultPc.ClearDirty();
                }
            }

            return(result);
        }
Exemplo n.º 3
0
		/// <summary>
		/// Initializes a new instance of <see cref="CollectionEntry"/>.
		/// </summary>
		/// <remarks> 
		/// For newly wrapped collections, or dereferenced collection wrappers
		/// </remarks>
		public CollectionEntry(ICollectionPersister persister, IPersistentCollection collection)
		{
			// new collections that get found + wrapped
			// during flush shouldn't be ignored
			ignore = false;

			collection.ClearDirty(); //a newly wrapped collection is NOT dirty (or we get unnecessary version updates)

			snapshot = persister.IsMutable ? collection.GetSnapshot(persister) : null;
			collection.SetSnapshot(loadedKey, role, snapshot);
		}
		/// <summary>
		/// Initializes a new instance of <see cref="CollectionEntry"/>.
		/// </summary>
		/// <remarks> 
		/// The CollectionEntry is for a Collection that is not dirty and 
		/// has already been initialized.
		/// </remarks>
		public CollectionEntry(IPersistentCollection collection)
		{
			// New collections that get found and wrapped during flush shouldn't be ignored
			this.ignore = false;

			//a newly wrapped collection is NOT dirty (or we get unnecessary version updates)
			collection.ClearDirty();
			//this.initialized = true;
		}