Ejemplo n.º 1
0
		private void ScheduleBatchLoadIfNeeded(object id, ISessionImplementor session)
		{
			//cannot batch fetch by unique key (property-ref associations)
			if (uniqueKeyPropertyName == null && id != null)
			{
				IEntityPersister persister = session.Factory.GetEntityPersister(AssociatedClass);
				EntityKey entityKey = new EntityKey(id, persister);
				if (!session.ContainsEntity(entityKey))
				{
					session.BatchFetchQueue.AddBatchLoadableEntityKey(entityKey);
				}
			}
		}
		private ICollectionInitializer GetSubselectInitializer(object key, ISessionImplementor session)
		{
			if (!IsSubselectLoadable)
			{
				return null;
			}

			SubselectFetch subselect = session.BatchFetchQueue.GetSubselect(new EntityKey(key, OwnerEntityPersister));

			if (subselect == null)
			{
				return null;
			}
			else
			{
				// Take care of any entities that might have
				// been evicted!
				ArrayList keysToRemove = new ArrayList();
				foreach (EntityKey entityKey in subselect.Result)
				{
					if (!session.ContainsEntity(entityKey))
					{
						keysToRemove.Add(entityKey);
					}
				}
				subselect.Result.RemoveAll(keysToRemove);

				// Run a subquery loader
				return CreateSubselectInitializer(subselect, session);
			}
		}