-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Count(*) seems to be incorrect!
PostPosted: Fri Nov 18, 2005 7:53 am 
count(*) always returns 1 less than the actual value.

This looks like a bug to me unless we doing something wrong!


test:

Code:
[TestMethod]
        public void CheckRowCount()
        {
            Repository repository = new Repository();
            int rowCount = repository.GetRowCount<RecordOfAdvice>();
            RecordOfAdvice r5 = new RecordOfAdvice(1);
            RecordOfAdvice r4 = new RecordOfAdvice(1);
            RecordOfAdvice r3 = new RecordOfAdvice(1);
            RecordOfAdvice r2 = new RecordOfAdvice(1);
            RecordOfAdvice r1 = new RecordOfAdvice(1);
            r1.Save();
            r2.Save();
            r3.Save();
            r4.Save();
            r5.Save();
            Assert.AreEqual(rowCount +5, repository.GetRowCount<RecordOfAdvice>());

        }



the count code
Code:
public int GetRowCount<T>() where T: IEntity
    {
        string typeName = typeof(T).Name;
        IList listCount = Session.Find(String.Format("select count(*) from {0}", typeName));
        int count = Convert.ToInt32(listCount[0].ToString());
        return count;
    }


Top
  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.