Example #1
0
 public ShardedFilterImpl(IShardedSessionImplementor shardedSession, string name)
 {
     Preconditions.CheckNotNull(shardedSession);
     Preconditions.CheckNotNull(name);
     this.shardedSession = shardedSession;
     this.filterName     = name;
 }
 /// <summary>
 /// Creates new <see cref="ShardedQueryImpl"/> instance.
 /// </summary>
 /// <param name="session">The Sharded session on which this query is to be executed.</param>
 /// <param name="queryFactory">Factory method for creation of shard-local <see cref="IQuery"/> instances.</param>
 protected ShardedQueryImpl(IShardedSessionImplementor session, Func <ISession, IQuery> queryFactory)
 {
     Preconditions.CheckNotNull(session);
     Preconditions.CheckNotNull(queryFactory);
     this.session      = session;
     this.queryFactory = queryFactory;
 }
 public ShardedFilterImpl(IShardedSessionImplementor shardedSession, string name)
 {
     Preconditions.CheckNotNull(shardedSession);
     Preconditions.CheckNotNull(name);
     this.shardedSession = shardedSession;
     this.filterName = name;
 }
Example #4
0
 public ShardImpl(IShardedSessionImplementor shardedSession, IShardMetadata shardMetadata)
     : base(shardMetadata.ShardIds)
 {
     // make a copy to be safe
     this.shardedSession = shardedSession;
     this.sessionFactory = shardMetadata.SessionFactory;
 }
Example #5
0
 public ShardImpl(IShardedSessionImplementor shardedSession, IShardMetadata shardMetadata)
     : base(shardMetadata.ShardIds)
 {
     // make a copy to be safe
     this.shardedSession = shardedSession;
     this.sessionFactory = shardMetadata.SessionFactory;
 }
 /// <summary>
 /// Creates new <see cref="ShardedQueryImpl"/> instance.
 /// </summary>
 /// <param name="session">The Sharded session on which this query is to be executed.</param>
 /// <param name="unshardedQueryExpressionPlan">A shard-local <see cref="IQueryExpressionPlan"/> that represents
 /// a parsed HQL string or the HQL equivalent of a Linq expression.</param>
 public ShardedQueryImpl(IShardedSessionImplementor session, IQueryExpressionPlan unshardedQueryExpressionPlan)
 {
     Preconditions.CheckNotNull(session);
     Preconditions.CheckNotNull(unshardedQueryExpressionPlan);
     this.session = session;
     this.unshardedQueryExpressionPlan = unshardedQueryExpressionPlan;
     this.queryFactory = s => ApplyLimits(s.GetSessionImplementation().CreateQuery(this.QueryExpression));
 }
 public ShardImpl(IShardedSessionImplementor shardedSession, IShardMetadata shardMetadata)
     : base(shardMetadata.ShardIds)
 {
     Preconditions.CheckNotNull(shardedSession);
     Preconditions.CheckNotNull(shardMetadata);
     this.shardedSession = shardedSession;
     this.sessionFactory = shardMetadata.SessionFactory;
 }
Example #8
0
 public ShardedCriteriaImpl(IShardedSessionImplementor session, Func <ISession, ICriteria> criteriaFactory)
 {
     Preconditions.CheckNotNull(session);
     Preconditions.CheckNotNull(criteriaFactory);
     this.session         = session;
     this.criteriaFactory = criteriaFactory;
     this.subcriteriaByAlias[CriteriaSpecification.RootAlias] = this;
 }
		public ShardImpl(IShardedSessionImplementor shardedSession, IShardMetadata shardMetadata)
			: base(shardMetadata.ShardIds)
		{
			Preconditions.CheckNotNull(shardedSession);
			Preconditions.CheckNotNull(shardMetadata);
			this.shardedSession = shardedSession;
			this.sessionFactory = shardMetadata.SessionFactory;
		}
        /// <summary>
        /// Creates new <see cref="ShardedQueryImpl"/> instance.
        /// </summary>
        /// <param name="session">The Sharded session on which this query is to be executed.</param>
        /// <param name="hql">An HQL query string.</param>
        public static ShardedQueryImpl CreateQuery(IShardedSessionImplementor session, string hql)
        {
            var anySessionImplementor    = (AbstractSessionImpl)session.AnyShard.EstablishSession();
            var unshardedQueryExpression = new StringQueryExpression(hql);
            var unshardedQueryPlan       = anySessionImplementor.Factory.QueryPlanCache.GetHQLQueryPlan(
                unshardedQueryExpression, false, anySessionImplementor.EnabledFilters);

            return(new ShardedQueryImpl(session, unshardedQueryPlan));
        }
        public static ShardedQueryImpl GetNamedQuery(IShardedSessionImplementor session, string queryName)
        {
            var anySession = session.AnyShard.EstablishSession();
            var query      = anySession.GetNamedQuery(queryName);

            return(query is ISQLQuery
                                ? new ShardedQueryImpl(session, s => s.GetNamedQuery(queryName))
                                : CreateQuery(session, query.QueryString));
        }
        private void AfterTransactionCompletion(bool?success)
        {
            if (this.shardedSession != null)
            {
                shardedSession.AfterTransactionCompletion(this, success);
                this.shardedSession = null;
            }

            begun = false;
            NotifyLocalSynchsAfterTransactionCompletion(success);
        }
        private Task AfterTransactionCompletionAsync(bool?success, CancellationToken cancellationToken)
        {
            if (this.shardedSession != null)
            {
                shardedSession.AfterTransactionCompletion(this, success);
                this.shardedSession = null;
            }

            begun = false;
            return(NotifyLocalSynchsAfterTransactionCompletionAsync(success, cancellationToken));
        }
Example #14
0
        public ShardedCriteriaImpl(ShardedCriteriaImpl other)
        {
            Preconditions.CheckNotNull(other);

            this.session              = other.session;
            this.criteriaFactory      = other.criteriaFactory;
            this.exitOperationBuilder = new ExitOperationBuilder(other.exitOperationBuilder);
            this.establishActions     = other.establishActions;
            this.subcriteriaByAlias   = new Dictionary <string, ICriteria>(other.subcriteriaByAlias);
            this.subcriteriaByPath    = new Dictionary <string, Subcriteria>(other.subcriteriaByPath);
        }
 public ShardedCriteriaImpl(IShardedSessionImplementor session, Func <ISession, ICriteria> criteriaFactory)
 {
     Preconditions.CheckNotNull(session);
     Preconditions.CheckNotNull(criteriaFactory);
     this.session                  = session;
     this.criteriaFactory          = criteriaFactory;
     this.listExitOperationBuilder = new ListExitOperationBuilder();
     this.establishActions         = new List <Action <ICriteria> >();
     this.subcriteriaByAlias       = new Dictionary <string, ICriteria> {
         { CriteriaSpecification.RootAlias, this }
     };
     this.subcriteriaByPath = new Dictionary <string, Subcriteria>();
 }
Example #16
0
 public ShardedCriteriaImpl(IShardedSessionImplementor session, string entityName, Func <ISession, ICriteria> criteriaFactory)
 {
     Preconditions.CheckNotNull(session);
     Preconditions.CheckNotNull(entityName);
     Preconditions.CheckNotNull(criteriaFactory);
     this.session              = session;
     this.entityName           = entityName;
     this.criteriaFactory      = criteriaFactory;
     this.exitOperationBuilder = new ExitOperationBuilder();
     this.subcriteriaByAlias   = new Dictionary <string, ICriteria> {
         { CriteriaSpecification.RootAlias, this }
     };
     this.subcriteriaByPath = new Dictionary <string, Subcriteria>();
 }
        public void Dispose()
        {
            if (!disposed)
            {
                disposed = true;
                DisposeShardTransactions();
                transactions = null;

                // Assume transaction rollback
                if (this.IsActive)
                {
                    shardedSession.AfterTransactionCompletion(this, false);
                }
                shardedSession = null;
            }
        }
Example #18
0
 public ShardedSessionStatistics(IShardedSessionImplementor session)
 {
     sessionStats = new HashedSet <ISessionStatistics>();
     foreach (IShard shard in session.Shards)
     {
         if (shard.Session != null)
         {
             sessionStats.Add(shard.Session.Statistics);
         }
         else
         {
             IOpenSessionEvent ose = new StatOpenSessionEvent(sessionStats);
             shard.AddOpenSessionEvent(ose);
         }
     }
 }
 public ShardedTransactionImpl(IShardedSessionImplementor ssi)
 {
     IOpenSessionEvent osEvent = new SetupTransactionOpenSessionEvent(this);
     transactions = new SynchronizedCollection<ITransaction>();
     foreach (IShard shard in ssi.Shards)
     {
         if (shard.Session != null)
         {
             transactions.Add(shard.Session.Transaction);
         }
         else
         {
             shard.AddOpenSessionEvent(osEvent);
         }
     }
 }
 public ShardedSessionStatistics(IShardedSessionImplementor session)
 {
     sessionStats = new HashedSet<ISessionStatistics>();
     foreach(IShard shard in session.Shards)
     {
         if(shard.Session != null)
         {
             sessionStats.Add(shard.Session.Statistics);
         }
         else
         {
             IOpenSessionEvent ose = new StatOpenSessionEvent(sessionStats);
             shard.AddOpenSessionEvent(ose);
         }
     }
 }
Example #21
0
        public ShardedTransactionImpl(IShardedSessionImplementor ssi)
        {
            IOpenSessionEvent osEvent = new SetupTransactionOpenSessionEvent(this);

            transactions = new SynchronizedCollection <ITransaction>();
            foreach (IShard shard in ssi.Shards)
            {
                if (shard.Session != null)
                {
                    transactions.Add(shard.Session.Transaction);
                }
                else
                {
                    shard.AddOpenSessionEvent(osEvent);
                }
            }
        }
Example #22
0
 public FutureValueShardOperation(ShardedCriteriaImpl shardedCriteria)
 {
     this.session        = shardedCriteria.session;
     this.futuresByShard = shardedCriteria.session.Shards
                           .ToDictionary(s => s, s => shardedCriteria.EstablishFor(s).FutureValue <T>());
 }
Example #23
0
 public ShardedTransactionImpl(IShardedSessionImplementor ssi, IsolationLevel isoLevel) : this(ssi)
 {
     this.isoLevel = isoLevel;
 }
Example #24
0
 public ShardedTransactionImpl(IShardedSessionImplementor ssi, IsolationLevel isoLevel)
     : this(ssi)
 {
     this.isoLevel = isoLevel;
 }
		public ShardedSQLQueryImpl(IShardedSessionImplementor session, string queryString)
			: base(session, s => s.CreateSQLQuery(queryString))
		{}
        public void Dispose()
        {
            if (!disposed)
            {
                disposed = true;
                DisposeShardTransactions();
                transactions = null;

                // Assume transaction rollback
                if (this.IsActive)
                {
                    shardedSession.AfterTransactionCompletion(this, false);
                }
                shardedSession = null;
            }
        }
Example #27
0
 /// <summary>
 /// Creates new <see cref="ShardedQueryImpl"/> instance.
 /// </summary>
 /// <param name="session">The Sharded session on which this query is to be executed.</param>
 /// <param name="hql">An HQL query string.</param>
 public static ShardedQueryImpl CreateQuery(IShardedSessionImplementor session, string hql)
 {
     return(new ShardedQueryImpl(session, s => s.CreateQuery(hql)));
 }
Example #28
0
 public static ShardedQueryImpl GetNamedQuery(IShardedSessionImplementor session, string queryName)
 {
     return(new ShardedQueryImpl(session, s => s.GetNamedQuery(queryName)));
 }
 public ShardedTransactionImpl(IShardedSessionImplementor shardedSession)
     : this(shardedSession, IsolationLevel.Unspecified)
 {
 }
 public ShardedTransactionImpl(IShardedSessionImplementor shardedSession)
     : this(shardedSession, IsolationLevel.Unspecified)
 {
 }
Example #31
0
        private static ICriteria ToShardedCriteria(CriteriaImpl other, IShardedSessionImplementor shardedSession)
        {
            Preconditions.CheckNotNull(other);
            Preconditions.CheckNotNull(shardedSession);

            var entityName = other.EntityOrClassName;
            var alias      = other.Alias;

            ICriteria CriteriaFactory(ISession s) =>
            alias != null
                                        ? s.CreateCriteria(entityName, alias)
                                        : s.CreateCriteria(entityName);

            var result = new ShardedCriteriaImpl(shardedSession, other.EntityOrClassName, CriteriaFactory);

            foreach (var entry in other.IterateSubcriteria())
            {
                result.CreateCriteria(entry.Path, entry.Alias, entry.JoinType, entry.WithClause);
            }
            foreach (var entry in other.IterateExpressionEntries())
            {
                result.Add(entry.Criterion);
            }
            foreach (var entry in other.LockModes)
            {
                result.SetLockMode(entry.Key, entry.Value);
            }
            foreach (var entry in other.IterateOrderings())
            {
                result.AddOrder(entry.Order);
            }

            if (other.Cacheable)
            {
                result.SetCacheable(true);
                if (other.CacheMode != null)
                {
                    result.SetCacheMode(other.CacheMode.Value);
                }
                if (other.CacheRegion != null)
                {
                    result.SetCacheRegion(other.CacheRegion);
                }
            }

            if (other.Comment != null)
            {
                result.SetComment(other.Comment);
            }
            if (other.FetchSize > 0)
            {
                result.SetFetchSize(other.FetchSize);
            }
            if (other.FirstResult > 0)
            {
                result.SetFirstResult(other.FirstResult);
            }
            if (other.MaxResults > 0)
            {
                result.SetMaxResults(other.MaxResults);
            }
            if (other.Projection != null)
            {
                result.SetProjection(other.Projection);
            }
            if (other.ResultTransformer != null)
            {
                result.SetResultTransformer(other.ResultTransformer);
            }
            if (other.Timeout > 0)
            {
                result.SetTimeout(other.Timeout);
            }
            if (other.IsReadOnlyInitialized)
            {
                result.SetReadOnly(other.IsReadOnly);
            }

            return(result);
        }
 public ShardedSQLQueryImpl(IShardedSessionImplementor session, string queryString)
     : base(session, s => s.CreateSQLQuery(queryString))
 {
 }
 public ShardedTransactionImpl(IShardedSessionImplementor shardedSession, IsolationLevel isolationLevel)
 {
     this.shardedSession = shardedSession;
     this.currentIsolationLevel = isolationLevel;
 }
        private void AfterTransactionCompletion(bool? success)
        {
            if (this.shardedSession != null)
            {
                shardedSession.AfterTransactionCompletion(this, success);
                this.shardedSession = null;
            }

            begun = false;
            NotifyLocalSynchsAfterTransactionCompletion(success);
        }
Example #35
0
 internal static ICriteria GetExecutableCriteria(this DetachedCriteria criteria, IShardedSessionImplementor shardedSession)
 {
     Preconditions.CheckNotNull(criteria);
     Preconditions.CheckNotNull(shardedSession);
     return(ToShardedCriteria(GetCriteriaImpl(criteria), shardedSession));
 }
 public ShardedTransactionImpl(IShardedSessionImplementor shardedSession, IsolationLevel isolationLevel)
 {
     this.shardedSession        = shardedSession;
     this.currentIsolationLevel = isolationLevel;
 }
 /// <summary>
 /// Creates new <see cref="ShardedQueryImpl"/> instance.
 /// </summary>
 /// <param name="session">The Sharded session on which this query is to be executed.</param>
 public ShardedBatch(IShardedSessionImplementor session)
 {
     this.session = session;
 }
 /// <summary>
 /// Creates new <see cref="ShardedQueryImpl"/> instance.
 /// </summary>
 /// <param name="session">The Sharded session on which this query is to be executed.</param>
 public ShardedMultiQueryImpl(IShardedSessionImplementor session)
 {
     this.session = session;
 }
 /// <summary>
 /// Creates new <see cref="ShardedCriteriaImpl"/> instance.
 /// </summary>
 /// <param name="session">The Sharded session on which this query is to be executed.</param>
 public ShardedMultiCriteriaImpl(IShardedSessionImplementor session)
 {
     this.session = session;
 }