public CollectionFetchReturn(string alias, NonScalarReturn owner, string ownerProperty,
		                             ICollectionAliases collectionAliases, IEntityAliases elementEntityAliases,
		                             LockMode lockMode) : base(owner, ownerProperty, alias, lockMode)
		{
			this.collectionAliases = collectionAliases;
			this.elementEntityAliases = elementEntityAliases;
		}
		public override object ReadFrom(IDataReader reader, ICollectionPersister role, ICollectionAliases descriptor,
		                                object owner)
		{
			object element = role.ReadElement(reader, owner, descriptor.SuffixedElementAliases, Session);
			bag.Add(element);
			return element;
		}
		public CollectionReturn(string alias, string ownerEntityName, string ownerProperty,
		                        ICollectionAliases collectionAliases, IEntityAliases elementEntityAliases, LockMode lockMode)
			: base(alias, lockMode)
		{
			this.ownerEntityName = ownerEntityName;
			this.ownerProperty = ownerProperty;
			this.collectionAliases = collectionAliases;
			this.elementEntityAliases = elementEntityAliases;
		}
		public override object ReadFrom(IDataReader reader, ICollectionPersister role, ICollectionAliases descriptor,
		                                object owner)
		{
			// note that if we load this collection from a cartesian product
			// the multiplicity would be broken ... so use an idbag instead
			object element = role.ReadElement(reader, owner, descriptor.SuffixedElementAliases, Session);
			// NH Different behavior : we don't check for null
			// The NH-750 test show how checking for null we are ignoring the not-found tag and
			// the DB may have some records ignored by NH. This issue may need some more deep consideration.
			//if (element != null)
				bag.Add(element);
			return element;
		}
        public override object ReadFrom(DbDataReader rs, ICollectionPersister role, ICollectionAliases descriptor, object owner)
        {
            var element = (T)role.ReadElement(rs, owner, descriptor.SuffixedElementAliases, Session);
            int index   = (int)role.ReadIndex(rs, descriptor.SuffixedIndexAliases, Session);

            //pad with nulls from the current last element up to the new index
            for (int i = WrappedList.Count; i <= index; i++)
            {
                WrappedList.Insert(i, DefaultForType);
            }

            WrappedList[index] = element;
            return(element);
        }
		public NonScalarReturn(SQLQueryContext context, bool queryHasAliases, string alias, LockMode lockMode, NonScalarReturn owner)
		{
			if (context == null)
			{
				throw new ArgumentNullException("context");
			}
			if (string.IsNullOrEmpty(alias))
			{
				throw new HibernateException("alias must be specified");
			}

			this.alias = alias;
			this.lockMode = lockMode;
			this.owner = owner;

			this.collectionPersister = context.GetCollectionPersister(alias);
			if (this.collectionPersister != null)
			{
				var collectionPropertyResultMap = context.GetCollectionPropertyResultsMap(alias);
				this.collectionAliases = queryHasAliases
					? new GeneratedCollectionAliases(collectionPropertyResultMap, this.collectionPersister, context.GetCollectionSuffix(alias))
					: (ICollectionAliases)new ColumnCollectionAliases(collectionPropertyResultMap, this.collectionPersister);
			}

			if (this.collectionPersister == null || this.CollectionPersister.ElementType.IsEntityType)
			{
				this.entityPersister = context.GetEntityPersister(alias);
				if (this.entityPersister != null)
				{
					var entityPropertyResultMap = context.GetEntityPropertyResultsMap(alias);
					this.entityAliases = queryHasAliases
						? new DefaultEntityAliases(entityPropertyResultMap, this.entityPersister, context.GetEntitySuffix(alias))
						: new ColumnEntityAliases(entityPropertyResultMap, this.entityPersister);
				}
			}
		}
		public override object ReadFrom(IDataReader reader, ICollectionPersister persister, ICollectionAliases descriptor,
		                                object owner)
		{
			object element = persister.ReadElement(reader, owner, descriptor.SuffixedElementAliases, Session);
			object tempObject = GetIdentifier(values.Count);
			identifiers[values.Count] = persister.ReadIdentifier(reader, descriptor.SuffixedIdentifierAlias, Session);
			object old = tempObject;
			if (old == null)
			{
				values.Add(element); //maintain correct duplication if loaded in a cartesian product			
			}
			return element;
		}
        public override async Task <object> ReadFromAsync(DbDataReader reader, ICollectionPersister role, ICollectionAliases descriptor, object owner, CancellationToken cancellationToken)
        {
            cancellationToken.ThrowIfCancellationRequested();
            // note that if we load this collection from a cartesian product
            // the multiplicity would be broken ... so use an idbag instead
            var element = await(role.ReadElementAsync(reader, owner, descriptor.SuffixedElementAliases, Session, cancellationToken)).ConfigureAwait(false);

            if (element != null)
            {
                _gbag.Add((T)element);
            }
            return(element);
        }
		public override object ReadFrom(IDataReader rs, ICollectionPersister role, ICollectionAliases descriptor, object owner)
		{
			object element = role.ReadElement(rs, owner, descriptor.SuffixedElementAliases, Session);
			int index = (int) role.ReadIndex(rs, descriptor.SuffixedIndexAliases, Session);
			for (int i = tempList.Count; i <= index; i++)
			{
				tempList.Add(null);
			}
			tempList[index] = element;
			return element;
		}
        public override object ReadFrom(IDataReader reader, ICollectionPersister persister, ICollectionAliases descriptor,
                                        object owner)
        {
            object element    = persister.ReadElement(reader, owner, descriptor.SuffixedElementAliases, Session);
            object tempObject = GetIdentifier(values.Count);

            identifiers[values.Count] = persister.ReadIdentifier(reader, descriptor.SuffixedIdentifierAlias, Session);
            object old = tempObject;

            if (old == null)
            {
                values.Add(element);                 //maintain correct duplication if loaded in a cartesian product
            }
            return(element);
        }
Example #11
0
        public override object ReadFrom(DbDataReader reader, ICollectionPersister role, ICollectionAliases descriptor, object owner)
        {
            // note that if we load this collection from a cartesian product
            // the multiplicity would be broken ... so use an idbag instead
            var element = role.ReadElement(reader, owner, descriptor.SuffixedElementAliases, Session);

            // NH Different behavior : we don't check for null
            // The NH-750 test show how checking for null we are ignoring the not-found tag and
            // the DB may have some records ignored by NH. This issue may need some more deep consideration.
            //if (element != null)
            _gbag.Add((T)element);
            return(element);
        }
        public override async Task <object> ReadFromAsync(DbDataReader rs, ICollectionPersister role, ICollectionAliases descriptor, object owner, CancellationToken cancellationToken)
        {
            cancellationToken.ThrowIfCancellationRequested();
            object element = await(role.ReadElementAsync(rs, owner, descriptor.SuffixedElementAliases, Session, cancellationToken)).ConfigureAwait(false);
            int    index   = (int)await(role.ReadIndexAsync(rs, descriptor.SuffixedIndexAliases, Session, cancellationToken)).ConfigureAwait(false);

            for (int i = tempList.Count; i <= index; i++)
            {
                tempList.Add(null);
            }
            tempList[index] = element;
            return(element);
        }
Example #13
0
        public override async Task <object> ReadFromAsync(DbDataReader reader, ICollectionPersister persister, ICollectionAliases descriptor, object owner, CancellationToken cancellationToken)
        {
            cancellationToken.ThrowIfCancellationRequested();
            object element = await(persister.ReadElementAsync(reader, owner, descriptor.SuffixedElementAliases, Session, cancellationToken)).ConfigureAwait(false);
            object id      = await(persister.ReadIdentifierAsync(reader, descriptor.SuffixedIdentifierAlias, Session, cancellationToken)).ConfigureAwait(false);

            // eliminate duplication if loaded in a cartesian product
            if (!_identifiers.ContainsValue(id))
            {
                _identifiers[_values.Count] = id;
                _values.Add((T)element);
            }
            return(element);
        }
Example #14
0
		public override object ReadFrom(IDataReader reader, ICollectionPersister role, ICollectionAliases descriptor,
		                                object owner)
		{
			object element = role.ReadElement(reader, owner, descriptor.SuffixedElementAliases, Session);
			values.Add(element);
			identifiers[values.Count - 1] = role.ReadIdentifier(reader, descriptor.SuffixedIdentifierAlias, Session);
			return element;
		}
Example #15
0
        public override object ReadFrom(DbDataReader reader, ICollectionPersister role, ICollectionAliases descriptor, object owner)
        {
            // note that if we load this collection from a cartesian product
            // the multiplicity would be broken ... so use an idbag instead
            var element = role.ReadElement(reader, owner, descriptor.SuffixedElementAliases, Session);

            if (element != null)
            {
                _gbag.Add((T)element);
            }
            return(element);
        }
Example #16
0
        public override async Task <object> ReadFromAsync(DbDataReader rs, ICollectionPersister role, ICollectionAliases descriptor, object owner, CancellationToken cancellationToken)
        {
            cancellationToken.ThrowIfCancellationRequested();
            object element = await(role.ReadElementAsync(rs, owner, descriptor.SuffixedElementAliases, Session, cancellationToken)).ConfigureAwait(false);
            object index   = await(role.ReadIndexAsync(rs, descriptor.SuffixedIndexAliases, Session, cancellationToken)).ConfigureAwait(false);

            AddDuringInitialize(index, element);
            return(element);
        }
 /// <summary>
 /// Reads the row from the <see cref="DbDataReader"/>.
 /// </summary>
 /// <param name="reader">The DbDataReader that contains the value of the Identifier</param>
 /// <param name="role">The persister for this Collection.</param>
 /// <param name="descriptor">The descriptor providing result set column names</param>
 /// <param name="owner">The owner of this Collection.</param>
 /// <param name="cancellationToken">A cancellation token that can be used to cancel the work</param>
 /// <returns>The object that was contained in the row.</returns>
 public abstract Task <object> ReadFromAsync(DbDataReader reader, ICollectionPersister role, ICollectionAliases descriptor,
                                             object owner, CancellationToken cancellationToken);
		public override object ReadFrom(IDataReader rs, ICollectionPersister role, ICollectionAliases descriptor, object owner)
		{
			object element = role.ReadElement(rs, owner, descriptor.SuffixedElementAliases, Session);
			int index = (int) role.ReadIndex(rs, descriptor.SuffixedIndexAliases, Session);

			//pad with nulls from the current last element up to the new index
			for (int i = list.Count; i <= index; i++)
			{
				list.Insert(i, DefaultForType);
			}

			list[index] = element;
			return element;
		}
Example #19
0
 /// <summary>
 /// Reads the row from the <see cref="IDataReader"/>.
 /// </summary>
 /// <param name="reader">The IDataReader that contains the value of the Identifier</param>
 /// <param name="role">The persister for this Collection.</param>
 /// <param name="descriptor">The descriptor providing result set column names</param>
 /// <param name="owner">The owner of this Collection.</param>
 /// <returns>The object that was contained in the row.</returns>
 public abstract object ReadFrom(IDataReader reader, ICollectionPersister role, ICollectionAliases descriptor,
                                 object owner);
Example #20
0
        public override object ReadFrom(IDataReader rs, ICollectionPersister role, ICollectionAliases descriptor, object owner)
        {
            object element = role.ReadElement(rs, owner, descriptor.SuffixedElementAliases, Session);
            object index = role.ReadIndex(rs, descriptor.SuffixedIndexAliases, Session);

            map[index] = element;
            return element;
        }
Example #21
0
        public override async Task <object> ReadFromAsync(DbDataReader rs, ICollectionPersister role, ICollectionAliases descriptor, object owner, CancellationToken cancellationToken)
        {
            cancellationToken.ThrowIfCancellationRequested();
            var element = (T)await(role.ReadElementAsync(rs, owner, descriptor.SuffixedElementAliases, Session, cancellationToken)).ConfigureAwait(false);
            int index   = (int)await(role.ReadIndexAsync(rs, descriptor.SuffixedIndexAliases, Session, cancellationToken)).ConfigureAwait(false);

            //pad with nulls from the current last element up to the new index
            for (int i = WrappedList.Count; i <= index; i++)
            {
                WrappedList.Insert(i, DefaultForType);
            }

            WrappedList[index] = element;
            return(element);
        }
Example #22
0
        public override object ReadFrom(IDataReader reader, ICollectionPersister persister, ICollectionAliases descriptor, object owner)
        {
            object element = persister.ReadElement(reader, owner, descriptor.SuffixedElementAliases, Session);
            object id      = persister.ReadIdentifier(reader, descriptor.SuffixedIdentifierAlias, Session);

            // eliminate duplication if loaded in a cartesian product
            if (!identifiers.ContainsValue(id))
            {
                identifiers[values.Count] = id;
                values.Add(element);
            }
            return(element);
        }
Example #23
0
		public override object ReadFrom(IDataReader rs, ICollectionPersister role, ICollectionAliases descriptor, object owner)
		{
			object element = role.ReadElement(rs, owner, descriptor.SuffixedElementAliases, Session);
			if (element != null)
			{
				tempList.Add(element);
			}
			return element;
		}
Example #24
0
        public override async Task <object> ReadFromAsync(DbDataReader reader, ICollectionPersister role, ICollectionAliases descriptor, object owner, CancellationToken cancellationToken)
        {
            cancellationToken.ThrowIfCancellationRequested();
            // note that if we load this collection from a cartesian product
            // the multiplicity would be broken ... so use an idbag instead
            var element = await(role.ReadElementAsync(reader, owner, descriptor.SuffixedElementAliases, Session, cancellationToken)).ConfigureAwait(false);

            // NH Different behavior : we don't check for null
            // The NH-750 test show how checking for null we are ignoring the not-found tag and
            // the DB may have some records ignored by NH. This issue may need some more deep consideration.
            //if (element != null)
            _gbag.Add((T)element);
            return(element);
        }
        public override async Task <object> ReadFromAsync(DbDataReader rs, ICollectionPersister role, ICollectionAliases descriptor, object owner, CancellationToken cancellationToken)
        {
            cancellationToken.ThrowIfCancellationRequested();
            var element = await(role.ReadElementAsync(rs, owner, descriptor.SuffixedElementAliases, Session, cancellationToken)).ConfigureAwait(false);

            if (element != null)
            {
                _tempList.Add((T)element);
            }
            return(element);
        }
		public override object ReadFrom(IDataReader reader, ICollectionPersister persister, ICollectionAliases descriptor, object owner)
		{
			object element = persister.ReadElement(reader, owner, descriptor.SuffixedElementAliases, Session);
			object id = persister.ReadIdentifier(reader, descriptor.SuffixedIdentifierAlias, Session);
			
			// eliminate duplication if loaded in a cartesian product
			if (!identifiers.ContainsValue(id))
			{
				identifiers[values.Count] = id;
				values.Add(element);
			}
			return element;
		}
Example #27
0
		/// <summary>
		/// Read one collection element from the current row of the ADO.NET result set
		/// </summary>
		private static void ReadCollectionElement(object optionalOwner, object optionalKey, ICollectionPersister persister,
		                                          ICollectionAliases descriptor, IDataReader rs, ISessionImplementor session)
		{
			IPersistenceContext persistenceContext = session.PersistenceContext;

			object collectionRowKey = persister.ReadKey(rs, descriptor.SuffixedKeyAliases, session);

			if (collectionRowKey != null)
			{
				// we found a collection element in the result set

				if (log.IsDebugEnabled)
				{
					log.Debug("found row of collection: " + MessageHelper.InfoString(persister, collectionRowKey));
				}

				object owner = optionalOwner;
				if (owner == null)
				{
					owner = persistenceContext.GetCollectionOwner(collectionRowKey, persister);
					if (owner == null)
					{
						//TODO: This is assertion is disabled because there is a bug that means the
						//      original owner of a transient, uninitialized collection is not known 
						//      if the collection is re-referenced by a different object associated 
						//      with the current Session
						//throw new AssertionFailure("bug loading unowned collection");
					}
				}
				IPersistentCollection rowCollection =
					persistenceContext.LoadContexts.GetCollectionLoadContext(rs).GetLoadingCollection(persister, collectionRowKey);

				if (rowCollection != null)
				{
					rowCollection.ReadFrom(rs, persister, descriptor, owner);
				}
			}
			else if (optionalKey != null)
			{
				// we did not find a collection element in the result set, so we
				// ensure that a collection is created with the owner's identifier,
				// since what we have is an empty collection

				if (log.IsDebugEnabled)
				{
					log.Debug("result set contains (possibly empty) collection: " + MessageHelper.InfoString(persister, optionalKey));
				}
				persistenceContext.LoadContexts.GetCollectionLoadContext(rs).GetLoadingCollection(persister, optionalKey);
				// handle empty collection
			}

			// else no collection element, but also no owner
		}
		/// <summary>
		/// Reads the row from the <see cref="IDataReader"/>.
		/// </summary>
		/// <param name="reader">The IDataReader that contains the value of the Identifier</param>
		/// <param name="role">The persister for this Collection.</param>
		/// <param name="descriptor">The descriptor providing result set column names</param>
		/// <param name="owner">The owner of this Collection.</param>
		/// <returns>The object that was contained in the row.</returns>
		public abstract object ReadFrom(IDataReader reader, ICollectionPersister role, ICollectionAliases descriptor,
		                                object owner);