No, i don't use sample-data.xml to populate it. I populated my database using sql file that i created from mysqldump. What do you mean "if you're only doing a get, it should work fine"?..

Thanks a lot Matt.


Matt Raible wrote:
The tests rollback any transactions that modified data when you're in
the database. However, if you're only doing a get, it should work
fine. Does your sample-data.xml populate the database with 142,882
countries?

Matt

On Mon, Oct 19, 2009 at 2:07 AM, Nelson Biasura
<nelson.bias...@aurisoftsys.com> wrote:
Hello, I'm trying to check the size of the return list in one of my method
in DAO. But it always return 0;
When executing "mvn test -Dtest=NameDaoTest" does it create and populate new
data in my database? I noticed that all my data in database is gone.
I guest it automatically call the "mvn hibernate3:hbm2ddl
dbunit:operation".. how can i bypass it so that i can retrieve data in my
database. I am expecting the size of the list to be 142882 and i want to put
assert in my test. Here is my code

DaoTest:

public void testGetProduct() {
      for(int i = 1; i <= 5; i++) {
          List countries = groupProductDao.findByServiceIdAndSubList("6561",
"U");
          assertEquals(countries.size(),142882);
            }
  }

DaoHibernate:

  public List<GroupProduct> findByServiceIdAndSubList(String serviceId,
String subList) {
      Long serviceIdLong = Long.valueOf(serviceId);
      List<GroupProduct> gpDTOList = new ArrayList<GroupProduct>();

      if (subList.equals("")) {
          List<String> descList = new ArrayList<String>();
descList = getHibernateTemplate().find("select description from GroupProduct
where version=0 and serviceID=? order by description asc", serviceIdLong);
          if (descList.size() != 0) {
              subList = descList.get(0).substring(0,1);
          }
      }
      gpDTOList = getHibernateTemplate().find("from GroupProduct where
version=0 and serviceID=? and description like '"+subList+"%' order by
description asc", serviceIdLong);

       return gpDTOList;
  }



Please help..






---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@appfuse.dev.java.net
For additional commands, e-mail: users-h...@appfuse.dev.java.net



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@appfuse.dev.java.net
For additional commands, e-mail: users-h...@appfuse.dev.java.net



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@appfuse.dev.java.net
For additional commands, e-mail: users-h...@appfuse.dev.java.net

Reply via email to