一个struts+hibernate的项目,其中有一个地方每次执行就java.lang.ClassCastException: java.lang.Long然后根据提示错误的地方去找:
public static int findTCount() {
Transaction tx = null;
int intCount= 0;
try {
session = hib.openSession();
tx = session.beginTransaction();
intCount=((Integer)session.createQuery(
"select count(*)from Tongxun").uniqueResult()).intValue();
tx.commit();
hib.closeSession(session);
} catch (Exception e) {
e.printStackTrace();
tx.rollback();
}
return intCount;
}其中intCount=((Integer)session.createQuery("select count(*)from Tongxun").uniqueResult()).intValue();是这句话出的问题,请路过的高人指教,小弟不胜感激。
public static int findTCount() {
Transaction tx = null;
int intCount= 0;
try {
session = hib.openSession();
tx = session.beginTransaction();
intCount=((Integer)session.createQuery(
"select count(*)from Tongxun").uniqueResult()).intValue();
tx.commit();
hib.closeSession(session);
} catch (Exception e) {
e.printStackTrace();
tx.rollback();
}
return intCount;
}其中intCount=((Integer)session.createQuery("select count(*)from Tongxun").uniqueResult()).intValue();是这句话出的问题,请路过的高人指教,小弟不胜感激。
解决方案 »
- 怎么测试action的内存消耗
- 求教java动态添加数据库表,不是添加表格!!!(最好有代码)
- (附建议)hibernate中的session问题,项目中绝对会碰上
- proxool 的问题
- struts,国际化问题:Missing message for key "item.username"为什么总是这个exception
- tomcat如何新增一个web应用
- 请求帮助,一个this.getClass().getClassLoader().getResource("abc.def").getFile()的错误
- 有谁能说一下数据库的事务和JTA事务的区别?
- Glassfish4.1怎么启用SSI
- 系统中的日志是用AOP实现的,还是显性的用log.info打印呢
- 有关js的一个很简单的问题。。。
- 空指向异常!
intCount=Integer.parseInt(session.createQuery("select count(*)from Tongxun").uniqueResult());
试试看.
Long a = 10L;
int b = Integer.parseInt(a);