예제 #1
0
 /**
  * Construct a ShardedCriteriaImpl
  *
  * @param criteriaId unique id for this ShardedCriteria
  * @param shards the shards that this ShardedCriteria is aware of
  * @param criteriaFactory factory that knows how to create concrete {@link Criteria} objects
  * @param shardAccessStrategy the access strategy we use when we execute this
  * ShardedCriteria across multiple shards.
  */
 public ShardedCriteriaImpl(CriteriaId criteriaId, IList <IShard> shards, ICriteriaFactory criteriaFactory, IShardAccessStrategy shardAccessStrategy)
 {
     this.criteriaId          = criteriaId;
     this.shards              = shards;
     this.criteriaFactory     = criteriaFactory;
     this.shardAccessStrategy = shardAccessStrategy;
     this.criteriaCollector   = new ExitOperationsCriteriaCollector();
     criteriaCollector.SetSessionFactory(shards[0].SessionFactoryImplementor);
 }
예제 #2
0
 /// <summary>
 /// @see Criteria#uniqueResult()
 /// </summary>
 /// <param name="criteriaId"></param>
 /// <returns></returns>
 public object UniqueResult(CriteriaId criteriaId)
 {
     throw new System.NotImplementedException();
 }
예제 #3
0
 /// <summary>
 /// @see Criteria#list()
 /// </summary>
 /// <param name="criteriaId"></param>
 /// <returns></returns>
 public IList<object> List(CriteriaId criteriaId)
 {
     throw new System.NotImplementedException();
 }
예제 #4
0
        public void TestAddCriteriaEvent()
        {
            ShardImpl shard = new ShardImpl(new ShardId(1), Stub<ISessionFactoryImplementor>());//new SessionFactoryDefaultMock()
            try
            {
                shard.AddCriteriaEvent(null, null);
                Assert.Fail("expected nre");
            }
            catch (NullReferenceException nre)
            {
                // good
            }

            CriteriaId criteriaId = new CriteriaId(2);
            try
            {
                shard.AddCriteriaEvent(criteriaId, null);
                Assert.Fail("expected nre");
            }
            catch (NullReferenceException nre)
            {
                // good
            }

            ICriteriaEvent ce = Stub<ICriteriaEvent>();//new CriteriaEventDefaultMock()
            try
            {
                shard.AddCriteriaEvent(null, ce);
                Assert.Fail("expected nre");
            }
            catch (NullReferenceException nre)
            {
                // good
            }

            shard.AddCriteriaEvent(criteriaId, ce);
            //Assert.IsNotNull(shard.GetCriteriaEventMap());
            //Assert.Equals(1, shard.getCriteriaEventMap().size());
            //Assert.Equals(1, shard.getCriteriaEventMap().get(criteriaId).size());
            //Assert.AreSame(ce, shard.getCriteriaEventMap().get(criteriaId).get(0));

            // now add another event to the same criteria
            ICriteriaEvent anotherCe = Stub<ICriteriaEvent>();
            //shard.AddCriteriaEvent(criteriaId, anotherCe);
            //Assert.IsNotNull(shard.getCriteriaEventMap());
            //Assert.Equals(1, shard.getCriteriaEventMap().size());
            //Assert.Equals(2, shard.getCriteriaEventMap().get(criteriaId).size());
            //Assert.AreSame(ce, shard.getCriteriaEventMap().get(criteriaId).get(0));
            //Assert.AreSame(anotherCe, shard.getCriteriaEventMap().get(criteriaId).get(1));

            // now add an event to a different criteria
            CriteriaId anotherCriteriaId = new CriteriaId(3);
            ICriteriaEvent yetAnotherCe = Stub<ICriteriaEvent>();
            shard.AddCriteriaEvent(anotherCriteriaId, yetAnotherCe);
            //Assert.IsNotNull(shard.getCriteriaEventMap());
            //Assert.Equals(2, shard.getCriteriaEventMap().size());
            //Assert.Equals(2, shard.getCriteriaEventMap().get(criteriaId).size());
            //Assert.AreSame(ce, shard.getCriteriaEventMap().get(criteriaId).get(0));
            //Assert.AreSame(anotherCe, shard.getCriteriaEventMap().get(criteriaId).get(1));
            //Assert.Equals(1, shard.getCriteriaEventMap().get(anotherCriteriaId).size());
            //Assert.AreSame(yetAnotherCe, shard.getCriteriaEventMap().get(anotherCriteriaId).get(0));
        }