可能是你sql错了, 修改一下catch部分:catch (Exception ex) {
throw new DAOException("Query the FirstLevelProjectIte occur errors:", ex);
}==>catch (Exception ex) {
ex.printStackTrace();
}
throw new DAOException("Query the FirstLevelProjectIte occur errors:", ex);
}==>catch (Exception ex) {
ex.printStackTrace();
}
解决方案 »
- 工作中用不到的Java基础用经常复习吗???
- Eclipse怎么集成Maven要现在最新的集成方法
- 谁能给我介绍一个免费的mib文件编辑工具
- 在测试jsp程序的时候,长时间运行程序的时候,tomcat返回如下的日子,请问是什么原因?另外如何解决呢?
- 问一个struts中的页面跳转问题
- LINUX下ECLIPSE怎么启动?设置?谢谢!在线等.急!狂谢~
- tomcat&struts相关问题
- java mail 报错了,大家看一下
- eclipse 3.0中的tomcat插件在哪里?
- 在jsp页面取ModelAndView里面设置的一个HashSet
- java和EXE
- DES解密问题,请兄弟朋友救命!(高分)
简单翻译一下:
‘java.lang.UnsupportedOperationException: Sql查询目前不支持iteration’
public Iterator FirstLevelProjectIte() throws DAOException {
Iterator firstLevelProjectIte = null;
try {
firstLevelProjectIte = session.createSQLQuery(
" select {p.*},{t.*}" +
" from project {p},task {t} " +
" where {p}.id={t}.project_id ", new String[] {"p", "t"},
new Class[] {Project.class, Task.class}).list().iterator();
return firstLevelProjectIte;
} catch (Exception ex) {
throw new DAOException("Query the FirstLevelProjectIte occur errors:", ex);
}
}
public static void main(String[] args) throws DAOException,
HibernateException {
ProjectDAO dao = new HibernateProjectDAOImpl();
Iterator ite = dao.FirstLevelProjectIte(); if (ite.hasNext()) {
Object[] o = (Object[]) ite.next();
for (int i = 0; i < o.length; i++) {
Project project = null;
try {
project = dao.findByPK(2);
if (o[i].equals(project)) {
System.out.println("obj:" + project.getDescription());
}
} catch (DAOException ex) {
ex.printStackTrace();
} catch (DataNotFoundException ex) {
ex.printStackTrace();
}
}
}
}