ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Folashade Adeyosoye" <sharda...@gmail.com>
Subject RE: Countng Rows - UPDATE
Date Sun, 10 Jul 2005 19:02:08 GMT
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: Nathan.Maves@Sun.COM [mailto:Nathan.Maves@Sun.COM] 
Sent: Saturday, July 09, 2005 11:15 PM
To: user-java@ibatis.apache.org
Subject: Re: Countng Rows - UPDATE

 

My question is why did this work?

 

On Jul 5, 2005, at 9:32 AM, Folashade Adeyosoye wrote:





In the JAVA part I switched

 

 

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

 

FOR

 

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

 

 

Thanks all..

 

  _____  

From: Clinton Begin [mailto:clinton.begin@gmail.com] 
Sent: Monday, July 04, 2005 12:37 AM
To:  <mailto:user-java@ibatis.apache.org> user-java@ibatis.apache.org
Subject: Re: Countng Rows

 


Interesting.  It looks like the CCE is coming from a bad transaction
implementation.  Here's the line it's popping on...

SqlMapDaoTransaction trans = (SqlMapDaoTransaction)
daoManager.getTransaction(this);

So the transaction implementation is not an instance of
SqlMapDaoTransaction.  

What transaction manager are you using (i.e can you post your DAO config)?

Cheers,
Clinton




On 7/3/05, Folashade Adeyosoye < <mailto:shardayyy@gmail.com>
shardayyy@gmail.com> 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 = 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