InvalidDataAccessResourceUsageException:could not execute query,求助,谢谢。

cfm511240 2009-09-24 05:54:08
ssh2做的项目
PubUser的映射文件为:
<hibernate-mapping>
<class name="com.simple.systemset.vo.PubUser" table="PUB_USER"
schema="SIMPLE">
<id name="userId" type="java.lang.Long">
<column name="USER_ID" precision="4" scale="0" />
<generator class="native"/>
</id>
<property name="name" type="java.lang.String">
<column name="NAME" length="50" not-null="true" />
</property>
<property name="opcode" type="java.lang.String">
<column name="OPCODE" length="50" not-null="true" />
</property>
<property name="pswd" type="java.lang.String">
<column name="PSWD" length="50" not-null="true" />
</property>

<many-to-one name="pubDep" column="dep_id" unique="true" class="com.simple.systemset.vo.PubDep"/>

<many-to-one name="pubUserGroup" column="group_id" unique="true" class="com.simple.systemset.vo.PubUserGroup"/>

<property name="createTime" type="java.util.Date">
<column name="CREATE_TIME" length="7" not-null="true" />
</property>
<property name="createUser" type="java.lang.Long">
<column name="CREATE_USER" precision="4" scale="0"
not-null="true" />
</property>
</class>
</hibernate-mapping>
现在一执行这个方法就报错:
public List findPageByQuery(int intCurPage, int intPageRows) {
try {
final int a = (intCurPage - 1) * intPageRows;
final int b = intPageRows;
List list = getHibernateTemplate().executeFind(
new HibernateCallback() {
public Object doInHibernate(Session session)
throws HibernateException, SQLException {
Query query = session.createQuery("from PubUser");
query.setFirstResult(a);
query.setMaxResults(b);
List list = query.list();
return list;
}
});
return list;

} catch (RuntimeException re) {
throw re;
}
错误信息为org.springframework.dao.InvalidDataAccessResourceUsageException: could not execute query; nested exception is org.hibernate.exception.SQLGrammarException: could not execute query
在网上查了应该是和关联有关,去了关联好用。不知道怎样解决,谁遇到过这种问题帮帮忙,谢谢了。

...全文
2552 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
zhuhx08 2012-05-22
  • 打赏
  • 举报
回复
我也遇到了 你把那个 a 换成表达式 (intCurPage - 1) * intPageRows 直接 填这个
hepeng_8 2011-06-30
  • 打赏
  • 举报
回复
hibernate 分页
零下九度 2010-04-19
  • 打赏
  • 举报
回复
我也遇到了这个问题
cfm511240 2009-09-25
  • 打赏
  • 举报
回复
我把query.setFirstResult(a);
query.setMaxResults(b); 这两个去了就好用,但不能分页了,我的数据库是oracle,我用
show_sql输出的语句是select top 。。。。。,oracle不支持top,为什么hibernate会把hql解析成sqlserver的语句呀?
cfm511240 2009-09-25
  • 打赏
  • 举报
回复
没人遇到过这类问题么?谢谢
yaku2688 2009-09-24
  • 打赏
  • 举报
回复
看这有点眼熟………………

67,513

社区成员

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

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