ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Folashade Adeyosoye" <sharda...@gmail.com>
Subject Countng Rows
Date Mon, 04 Jul 2005 03:48:03 GMT
I have quick question please. I am trying to run a select count(*) and seem
to be getting a ClassCast Exception. here is the code.

 

I think it might be related to the Integer been returned.

 

Any help would be appreciated.

 

Thanks

 

 

 

 

(XML)

// ADMIN ROLE:  count all members that have an avatar 

// MEMBER ROLE : count all members that have an avatar if member status is
ACTIVE

 

  <statement id="searchCountAvatar" resultClass="java.lang.Integer"
parameterClass="memberObject">

 

      SELECT COUNT(*) FROM FGC_MEMBERS where MemberAvatar != #memberAvatar#

      <dynamic prepend="where">

        <isEqual prepend="and" property="memberRole" compareValue="MEMBER">

          MemberStatus = #memberID#

        </isEqual>

      </dynamic>

  </statement>

 

 

 

 

(JAVA)

 

  public int searchCountAvatar(String role) throws DaoException{

 

    IMember mem = new MemberImpl();

    Object parameterObject = null;

    //int count = 0;

    Integer count;

 

    try {

      mem.setMemberAvatar(FGCConstants.BLANK);

      mem.setMemberRole(role);     // role  == MEMBER or ADMIN

      mem.setMemberStatus(FGCConstants.ACCOUNT_ACTIVE);

      parameterObject = mem;

      count = (Integer) queryForObject("searchCountAvatar",
parameterObject);

 

    }

    catch (DaoException sqlEx) {

      logger.fatal("DaoException Error. " + sqlEx.getMessage());

      throw new DaoException(sqlEx.getMessage());

    }

    return ((Integer)count).intValue();

    //return count;

  }

 

 

 

EXCEPTION

=========== Starting testSearchCountAvatar ==============

INFO [2005-Jul-03 21:36:59] - sqlmapdao.BaseSqlMapDao(BaseSqlMapDao.java:30)
- BaseSqlMapDao static block starting... 

DEBUG[2005-Jul-03 21:36:59] - sqlmapdao.BaseSqlMapDao(BaseSqlMapDao.java:33)
- reader = java.io.InputStreamReader@1b15692

DEBUG[2005-Jul-03 21:37:00] - sqlmapdao.BaseSqlMapDao(BaseSqlMapDao.java:35)
- sqlMap = com.ibatis.sqlmap.engine.impl.SqlMapClientImpl@e66f56

INFO [2005-Jul-03 21:37:00] - sqlmapdao.BaseSqlMapDao(BaseSqlMapDao.java:37)
- BaseSqlMapDao static block finished... 

DEBUG[2005-Jul-03 21:37:07] -
jdbc.SimpleDataSource(SimpleDataSource.java:579) - Created connection
6400263.

DEBUG[2005-Jul-03 21:37:07] - sql.Connection(ConnectionLogProxy.java:42) -
{conn-100000} Connection

DEBUG[2005-Jul-03 21:37:13] -
jdbc.SimpleDataSource(SimpleDataSource.java:527) - Returned connection
6400263 to pool.

java.lang.ClassCastException

            at
com.ibatis.dao.client.template.SqlMapDaoTemplate.getSqlMapExecutor(SqlMapDao
Template.java:60)

            at
com.ibatis.dao.client.template.SqlMapDaoTemplate.queryForObject(SqlMapDaoTem
plate.java:162) 

            at
net.naijatek.fgconline.persistence.sqlmapdao.IbatisMemberDAO.searchCountAvat
ar(IbatisMemberDAO.java:3358)

            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

            at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39
)

            at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl
.java:25)

            at java.lang.reflect.Method.invoke(Method.java:324)

            at com.ibatis.dao.engine.impl.DaoProxy.invoke(DaoProxy.java:72)

            at $Proxy0.searchCountAvatar(Unknown Source)

            at
net.naijatek.fgconline.service.FGCServiceImpl.searchCountAvatar(FGCServiceIm
pl.java:1269)

            at
net.naijatek.fgconline.framework.FgcDriver.testSearchCountAvatar(FgcDriver.j
ava:98)

            at
net.naijatek.fgconline.framework.FgcDriver.main(FgcDriver.java:66)

Hit uncaught exception com.ibatis.dao.client.DaoException

com.ibatis.dao.client.DaoException

            at
net.naijatek.fgconline.framework.FgcDriver.main(FgcDriver.java:78)

 


Mime
View raw message