原生sql org.hibernate.exception.DataException: could not execute query

thinkpadshi 2013-06-14 12:52:55
如下是异常,但是sql语句直接复制到oracle中可以正常运行,不知道为什么嵌入原生的sql就没法运行了,断点设置发现还有一个异常,在could not execute query之前,那就是
Could not open Hibernate Session for transaction


org.springframework.dao.DataIntegrityViolationException: could not execute query; SQL [select to_char(apply_time,'yyyy-mm') as time,sum(approve_quota) as total from APPLY_INFO group by to_char(apply_time,'yyyy-mm') order by to_char(apply_time,'yyyy-mm');]; nested exception is org.hibernate.exception.DataException: could not execute query


在SSH中用原生的sql语句如下
public List nonPerforming() {
return getHibernateTemplate().execute(
new HibernateCallback<List>() {
@Override
public List doInHibernate(Session session)
throws HibernateException, SQLException {
SQLQuery query = session
.createSQLQuery("select to_char(apply_time,'yyyy-mm') as time," +
"sum(approve_quota) as total from APPLY_INFO " +
"group by to_char(apply_time,'yyyy-mm') " +
"order by to_char(apply_time,'yyyy-mm');");
List results = query.list();
return results;
}
});
}
...全文
1035 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
thinkpadshi 2013-06-15
  • 打赏
  • 举报
回复
卧槽,居然是多了一个分号,奶奶的
thinkpadshi 2013-06-14
  • 打赏
  • 举报
回复
额,Could not open Hibernate Session for transaction这个错误消失了,现在只有那一个错误了,不知为什么myeclipse和浏览器都不直接显示错误,非要让我设置断点去看

67,512

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧