Exemple #1
0
 public CriteriaImpl(System.Type persistentClass, SessionImpl session)
 {
     this.persistentClass = persistentClass;
     this.session         = session;
     this.classByAlias[CriteriaUtil.RootAlias] = persistentClass;
     this.cacheable = false;
 }
Exemple #2
0
        protected override object ProcessCollection(object collection, PersistentCollectionType type)
        {
            SessionImpl          session   = Session;
            object               key       = Key;
            ICollectionPersister persister = session.GetCollectionPersister(type.Role);

            session.RemoveCollection(persister, key);

            if (collection != null && (collection is PersistentCollection))
            {
                PersistentCollection wrapper = collection as PersistentCollection;
                wrapper.SetCurrentSession(session);
                if (wrapper.WasInitialized)
                {
                    session.AddNewCollection(wrapper, persister);
                }
                else
                {
                    session.ReattachCollection(wrapper, wrapper.CollectionSnapshot);
                }
            }
            else
            {
                // otherwise a null or brand new collection
                // this will also (inefficiently) handle arrays, which
                // have no snapshot, so we can't do any better
                //processArrayOrNewCollection(collection, type);
            }

            return(null);
        }
        protected override object ProcessCollection(object collection, PersistentCollectionType type)
        {
            if (collection != null)
            {
                SessionImpl          session = Session;
                PersistentCollection coll;

                if (type.IsArrayType)
                {
                    coll = session.GetArrayHolder(collection);
                    // if no array holder we found an unwrappered array (this can't occur,
                    // because we now always call wrap() before getting to here)
                    // return (ah==null) ? true : searchForDirtyCollections(ah, type);
                }
                else
                {
                    // if not wrappered yet, its dirty (this can't occur, because
                    // we now always call wrap() before getting to here)
                    // return ( ! (obj is PersistentCollection) ) ?
                    //	true : SearchForDirtyCollections( (PersistentCollection) obj, type );
                    coll = (PersistentCollection)collection;
                }

                if (session.CollectionIsDirty(coll))
                {
                    _dirty = true;
                    return(null);                    // NOTE: early exit
                }
            }
            return(null);
        }
Exemple #4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MultiCriteriaImpl"/> class.
        /// </summary>
        /// <param name="session">The session.</param>
        /// <param name="factory">The factory.</param>
        internal MultiCriteriaImpl(SessionImpl session, ISessionFactoryImplementor factory)
        {
            IDriver driver = session.Factory.ConnectionProvider.Driver;

            dialect           = session.Factory.Dialect;
            resultSetsCommand = driver.GetResultSetsCommand(session);
            this.session      = session;
            this.factory      = factory;
        }
Exemple #5
0
		/// <summary>
		/// Initializes a new instance of the <see cref="MultiCriteriaImpl"/> class.
		/// </summary>
		/// <param name="session">The session.</param>
		/// <param name="factory">The factory.</param>
		internal MultiCriteriaImpl(SessionImpl session, SessionFactoryImpl factory)
		{
			dialect = session.Factory.Dialect;
			if (!session.Factory.ConnectionProvider.Driver.SupportsMultipleQueries)
			{
				throw new NotSupportedException(
					string.Format("The dialect {0} does not support multiple queries.", dialect.GetType().FullName));
			}
			this.session = session;
			this.factory = factory;
		}
Exemple #6
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MultiCriteriaImpl"/> class.
        /// </summary>
        /// <param name="session">The session.</param>
        /// <param name="factory">The factory.</param>
        internal MultiCriteriaImpl(SessionImpl session, ISessionFactoryImplementor factory)
        {
            IDriver driver = session.Factory.ConnectionProvider.Driver;

            if (!driver.SupportsMultipleQueries)
            {
                throw new NotSupportedException(
                          string.Format("The driver {0} does not support multiple queries.", driver.GetType().FullName));
            }
            dialect      = session.Factory.Dialect;
            this.session = session;
            this.factory = factory;
        }
Exemple #7
0
        private SessionImpl OpenSession(IDbConnection connection, bool autoClose, long timestamp, IInterceptor sessionLocalInterceptor)
        {
            SessionImpl session = new SessionImpl(connection, this, autoClose, timestamp, sessionLocalInterceptor ?? interceptor,
                                                  settings.DefaultEntityMode, settings.IsFlushBeforeCompletionEnabled,
                                                  settings.IsAutoCloseSessionEnabled, settings.ConnectionReleaseMode);

            if (sessionLocalInterceptor != null)
            {
                // NH specific feature
                sessionLocalInterceptor.SetSession(session);
            }
            return(session);
        }
Exemple #8
0
        protected override object ProcessCollection(object collection, PersistentCollectionType type)
        {
            ICollectionPersister persister = Session.GetCollectionPersister(type.Role);

            if (collection == null)
            {
                // Do nothing
            }
            else if (collection is PersistentCollection)
            {
                PersistentCollection coll = (PersistentCollection)collection;

                if (coll.SetCurrentSession(Session))
                {
                    ICollectionSnapshot snapshot = coll.CollectionSnapshot;
                    if (SessionImpl.IsOwnerUnchanged(snapshot, persister, this.Key))
                    {
                        // a "detached" collection that originally belonged to the same entity
                        if (snapshot.Dirty)
                        {
                            throw new HibernateException("reassociated object has dirty collection");
                        }
                        Session.ReattachCollection(coll, snapshot);
                    }
                    else
                    {
                        // a "detached" collection that belonged to a different entity
                        throw new HibernateException("reassociated object has dirty collection reference");
                    }
                }
                else
                {
                    // a collection loaded in the current session
                    // can not possibly be the collection belonging
                    // to the entity passed to update()
                    throw new HibernateException("reassociated object has dirty collection reference");
                }
            }
            else
            {
                // brand new collection
                //TODO: or an array!! we can't lock objects with arrays now??
                throw new HibernateException("reassociated object has dirty collection reference");
            }

            return(null);
        }
        private SessionImpl OpenSession(IDbConnection connection, bool autoClose, long timestamp, IInterceptor sessionLocalInterceptor)
        {
#pragma warning disable 618
            var isInterceptorsBeforeTransactionCompletionIgnoreExceptionsEnabled = settings.IsInterceptorsBeforeTransactionCompletionIgnoreExceptionsEnabled;
#pragma warning restore 618

            SessionImpl session = new SessionImpl(connection, this, autoClose, timestamp, sessionLocalInterceptor ?? interceptor,
                                                  settings.DefaultEntityMode, settings.IsFlushBeforeCompletionEnabled,
                                                  settings.IsAutoCloseSessionEnabled, isInterceptorsBeforeTransactionCompletionIgnoreExceptionsEnabled,
                                                  settings.ConnectionReleaseMode);
            if (sessionLocalInterceptor != null)
            {
                // NH specific feature
                sessionLocalInterceptor.SetSession(session);
            }
            return(session);
        }
Exemple #10
0
        protected override object ProcessCollection(object collection, PersistentCollectionType type)
        {
            ICollectionPersister persister = Session.GetCollectionPersister(type.Role);

            if (collection is PersistentCollection)
            {
                PersistentCollection wrapper = (PersistentCollection)collection;

                if (wrapper.SetCurrentSession(Session))
                {
                    //a "detached" collection!
                    ICollectionSnapshot snapshot = wrapper.CollectionSnapshot;

                    if (!SessionImpl.IsOwnerUnchanged(snapshot, persister, Key))
                    {
                        // if the collection belonged to a different entity,
                        // clean up the existing state of the collection
                        Session.RemoveCollection(persister, Key);
                    }

                    Session.ReattachCollection(wrapper, snapshot);
                }
                else
                {
                    // a collection loaded in the current session
                    // can not possibly be the collection belonging
                    // to the entity passed to update()
                    Session.RemoveCollection(persister, Key);
                }
            }
            else
            {
                // null or brand new collection
                // this will also (inefficiently) handle arrays, which have
                // no snapshot, so we can't do any better
                Session.RemoveCollection(persister, Key);
                //processArrayOrNewCollection(collection, type);
            }

            return(null);
        }
Exemple #11
0
        /// <summary>
        /// Copy all the internal attributes of the given CriteriaImpl
        /// except alter the root persistent class type to be the given one.
        /// </summary>
        /// <param name="persistentClass"></param>
        /// <param name="original"></param>
        public CriteriaImpl(System.Type persistentClass, CriteriaImpl original)
        {
            this.persistentClass = persistentClass;

            this.classByAlias = original.classByAlias;
            this.classByAlias[CriteriaUtil.RootAlias] = persistentClass;

            this.criteria               = original.criteria;
            this.orderings              = original.orderings;
            this.fetchModes             = original.fetchModes;
            this.associationPathByAlias = original.associationPathByAlias;
            this.aliasByAssociationPath = original.aliasByAssociationPath;
            this.lockModes              = original.lockModes;
            this.maxResults             = original.maxResults;
            this.firstResult            = original.firstResult;
            this.timeout           = original.timeout;
            this.fetchSize         = original.fetchSize;
            this.session           = original.session;
            this.resultTransformer = original.resultTransformer;
            this.counter           = original.counter;
            this.cacheable         = original.cacheable;
            this.cacheRegion       = original.cacheRegion;
        }
Exemple #12
0
		private ISession OpenSession(IDbConnection connection, long timestamp, IInterceptor interceptor,
									 ConnectionReleaseMode connectionReleaseMode)
		{
			SessionImpl sessionImpl = new SessionImpl(connection, this, timestamp, interceptor, connectionReleaseMode);
			bool isSessionScopedInterceptor = this.interceptor!=interceptor;
			if(isSessionScopedInterceptor)
				interceptor.SetSession(sessionImpl);
			return sessionImpl;
		}
		public ProxyVisitor(SessionImpl session) : base(session)
		{
		}
Exemple #14
0
 public ReattachVisitor(SessionImpl session, object key)
     : base(session)
 {
     _key = key;
 }
 public WrapVisitor(SessionImpl session) : base(session)
 {
 }
		private SessionImpl OpenSession(IDbConnection connection, bool autoClose, long timestamp, IInterceptor sessionLocalInterceptor)
		{
#pragma warning disable 618
			var isInterceptorsBeforeTransactionCompletionIgnoreExceptionsEnabled = settings.IsInterceptorsBeforeTransactionCompletionIgnoreExceptionsEnabled;
#pragma warning restore 618

			SessionImpl session = new SessionImpl(connection, this, autoClose, timestamp, sessionLocalInterceptor ?? interceptor,
												  settings.DefaultEntityMode, settings.IsFlushBeforeCompletionEnabled,
												  settings.IsAutoCloseSessionEnabled, isInterceptorsBeforeTransactionCompletionIgnoreExceptionsEnabled,
												  settings.ConnectionReleaseMode, settings.DefaultFlushMode);

			if (sessionLocalInterceptor != null)
			{
				// NH specific feature
				sessionLocalInterceptor.SetSession(session);
			}
			return session;
		}
 public EvictVisitor(SessionImpl session)
     : base(session)
 {
 }
 public DirtyCollectionSearchVisitor(SessionImpl session)
     : base(session)
 {
 }
		public FlushVisitor(SessionImpl session, object owner)
			: base(session)
		{
			_owner = owner;
		}
		private SessionImpl OpenSession(IDbConnection connection, bool autoClose, long timestamp, IInterceptor sessionLocalInterceptor)
		{
			SessionImpl session = new SessionImpl(connection, this, autoClose, timestamp, sessionLocalInterceptor ?? interceptor,
			                                      settings.DefaultEntityMode, settings.IsFlushBeforeCompletionEnabled,
			                                      settings.IsAutoCloseSessionEnabled, settings.ConnectionReleaseMode);
			if (sessionLocalInterceptor != null)
			{
				// NH specific feature
				sessionLocalInterceptor.SetSession(session);
			}
			return session;
		}
 protected FutureBatch(SessionImpl session)
 {
     this.session = session;
 }
		public WrapVisitor(SessionImpl session) : base(session)
		{
		}
		public ReattachVisitor(SessionImpl session, object key)
			: base( session )
		{
			_key = key;
		}
		public DirtyCollectionSearchVisitor(SessionImpl session)
			: base( session )
		{
		}
		protected AbstractVisitor(SessionImpl session)
		{
			_session = session;
		}
		public DirtyCollectionSearchVisitor(SessionImpl session, bool[] propertyVersionability)
			: base(session)
		{
			_propertyVersionability = propertyVersionability;
		}
		public OnReplicateVisitor( SessionImpl session, object key ) : base( session, key )
		{
		}
		public OnLockVisitor(SessionImpl session, object key)
			: base(session, key)
		{
		}
Exemple #29
0
 public OnUpdateVisitor(SessionImpl session, object key)
     : base(session, key)
 {
 }
		public EvictVisitor(SessionImpl session)
			: base( session )
		{
		}
 public FutureCriteriaBatch(SessionImpl session) : base(session)
 {
 }
Exemple #32
0
 public ProxyVisitor(SessionImpl session) : base(session)
 {
 }
 public FutureQueryBatch(SessionImpl session) : base(session)
 {
 }
 protected AbstractVisitor(SessionImpl session)
 {
     _session = session;
 }
 public FlushVisitor(SessionImpl session, object owner)
     : base(session)
 {
     _owner = owner;
 }
Exemple #36
0
 public OnLockVisitor(SessionImpl session, object key)
     : base(session, key)
 {
 }