代码
public List findRec(final String hql, final int firstResult,
final int maxResults) {
return getHibernateTemplate().executeFind(new HibernateCallback() {
public Object doInHibernate(Session s) throws HibernateException,
SQLException { Query query = s.createQuery(hql);
query.setFirstResult(firstResult);
query.setMaxResults(maxResults);
List list = query.list();
return list;
}
});
}public List getRolesCategorys(final int start, final int limit) {
return findRec("from HtSysRolesCategory", start, limit);
}输出的hql:
Hibernate: select htsysroles0_.ROLE_CATE_ID as ROLE1_1_, htsysroles0_.ROLE_CATE_NAME as ROLE2_1_ from HT_SYS.HT_SYS_ROLES_CATEGORY htsysroles0_ limit ?
(怎么多出了limit? ,我用的是oracle)错误:Struts Problem ReportStruts has detected an unhandled exception:
Messages: 1. ORA-00933: SQL ???????
2. could not execute query
3. could not execute query; SQL [select htsysroles0_.ROLE_CATE_ID as ROLE1_1_, htsysroles0_.ROLE_CATE_NAME as ROLE2_1_ from HT_SYS.HT_SYS_ROLES_CATEGORY htsysroles0_]; nested exception is org.hibernate.exception.SQLGrammarException: could not execute queryFile: oracle bc/driver/DatabaseError.java
Line number: 112请高手帮忙啊。
public List findRec(final String hql, final int firstResult,
final int maxResults) {
return getHibernateTemplate().executeFind(new HibernateCallback() {
public Object doInHibernate(Session s) throws HibernateException,
SQLException { Query query = s.createQuery(hql);
query.setFirstResult(firstResult);
query.setMaxResults(maxResults);
List list = query.list();
return list;
}
});
}public List getRolesCategorys(final int start, final int limit) {
return findRec("from HtSysRolesCategory", start, limit);
}输出的hql:
Hibernate: select htsysroles0_.ROLE_CATE_ID as ROLE1_1_, htsysroles0_.ROLE_CATE_NAME as ROLE2_1_ from HT_SYS.HT_SYS_ROLES_CATEGORY htsysroles0_ limit ?
(怎么多出了limit? ,我用的是oracle)错误:Struts Problem ReportStruts has detected an unhandled exception:
Messages: 1. ORA-00933: SQL ???????
2. could not execute query
3. could not execute query; SQL [select htsysroles0_.ROLE_CATE_ID as ROLE1_1_, htsysroles0_.ROLE_CATE_NAME as ROLE2_1_ from HT_SYS.HT_SYS_ROLES_CATEGORY htsysroles0_]; nested exception is org.hibernate.exception.SQLGrammarException: could not execute queryFile: oracle bc/driver/DatabaseError.java
Line number: 112请高手帮忙啊。
解决方案 »
- Hibernate和触发器Trigger协同工作中怎样在保存后自动更新pojo数据为数据库处理后的数据
- 什么错 求解 谢谢
- 网站中的jsp页面接入到支付宝网关接口、易宝支付网关接口?
- 一个webservice问题。
- 请教struts中的容错处理问题
- 进来!大胆讨论作为一名程序员你如何看待恋爱和工作上的关系?
- 用Eclispe+lomboz+JBoss以后还要用EasyStruts么?
- ****** 数据源改动后,重新部署EJB时的问题 ******
- 谁有《j2ee1.4标准教材》的示例代码吗?请给我一份
- 请教,我该如何在weblogic 上 部署EJB ?
- preparedStatement打印不带问号的sql
- spring事物传播
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop.xsd">
<!-- apache.dbcp连接池的配置 -->
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
destroy-method="close">
<property name="driverClassName" value="oracle.jdbc.driver.OracleDriver">
</property>
<property name="url" value="jdbc:oracle:thin:@192.168.1.150:1521:rpms">
</property>
<property name="username" value="ht_sys"></property>
<property name="password" value="ht_sys"></property>
<!-- 最大活动连接数 -->
<property name="maxActive" value="100"></property>
<!-- 最大可空闲连接数 -->
<property name="maxIdle" value="30"></property>
<!-- 最大可等待连接数 -->
<property name="maxWait" value="500"></property>
<!-- 默认的提交方式(如果不需要事务可以设置成true,在实际应用中一般设置为false,默认为false) -->
<property name="defaultAutoCommit" value="true"></property>
</bean>
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="dataSource">
<ref bean="dataSource" />
</property>
<!-- hibernate方言等相关配置 -->
<property name="hibernateProperties">
<props>
<prop key="connection.useUnicode">true</prop>
<prop key="connection.characterEncoding">utf-8</prop>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
<prop key="hibernate.show_sql">true</prop>
</props>
</property>
<!-- hbm.xml的映射文件 -->
<property name="mappingResources">
<list>
<value>com/htinfo/htsys/model/HtSysUsers.hbm.xml</value>
<value>com/htinfo/htsys/model/HtSysRolesCategory.hbm.xml</value>
</list>
</property>
</bean>
不应该啊,我将query.setMaxResults(maxResults);行代码去掉就没有错误了啊。