|
Not sure but this is what they look like
now… JAVA public int searchCountAvatar(String
role) throws DaoException{ IMember mem = new MemberImpl(); Object parameterObject = null; Integer count; try {
mem.setMemberAvatar(FGCConstants.BLANK); mem.setMemberRole(role); mem.setMemberStatus(FGCConstants.ACCOUNT_ACTIVE); parameterObject = mem; count = (Integer)
getObject("searchCountAvatar", parameterObject); } catch (DaoException sqlEx) { logger.fatal("DaoException
Error. " + sqlEx.getMessage()); throw new
DaoException(sqlEx.getMessage()); } return ((Integer)count).intValue(); } XML <statement
id="searchCountAvatar" resultClass="java.lang.Integer"
parameterClass="memberObject"> SELECT COUNT(*) FROM FGC_MEMBERS
where MemberAvatar != #memberAvatar# <isNotEqual
prepend="and" property="memberRole"
compareValue="ADMIN"> MemberStatus = #memberStatus# </isNotEqual> </statement> From:
[EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] My question is why did this work? On Jul 5, 2005, at 9:32 AM, Folashade Adeyosoye wrote:
count = (Integer) queryForObject("searchCountAvatar",
parameterObject); FOR
count = (Integer) getObject("searchCountAvatar",
parameterObject); Thanks all.. From: Clinton Begin [mailto:[EMAIL PROTECTED]]
On 7/3/05, Folashade Adeyosoye <[EMAIL PROTECTED]> wrote: 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 =
[EMAIL PROTECTED] DEBUG[2005-Jul-03
21:37:00] - sqlmapdao.BaseSqlMapDao(BaseSqlMapDao.java:35) - sqlMap =
[EMAIL PROTECTED] 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(SqlMapDaoTemplate.java:60)
at
com.ibatis.dao.client.template.SqlMapDaoTemplate.queryForObject(SqlMapDaoTemplate.java:162)
at
net.naijatek.fgconline.persistence.sqlmapdao.IbatisMemberDAO.searchCountAvatar(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(FGCServiceImpl.java:1269)
at
net.naijatek.fgconline.framework.FgcDriver.testSearchCountAvatar(FgcDriver.java: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)
|
