日期:2014-05-17  浏览次数:20752 次

sql向mysql数据库迁移,分页出现问题,报的应该是 关键字错误,但是死活发现不了
错误: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '15 dpt0_.Id as Id5_, dpt0_.text as text5_, dpt0_.url as url5_, dpt0_.parentId as' at line 1

数据库 mysql

hibernate 方法

public List findPageByQuery(final String queryString,final Object[] parameters, final PageInfo pageInfo) {
return getHibernateTemplate().executeFind(new HibernateCallback(){
public Object doInHibernate(Session session)throws HibernateExceptionSQLException{
Query query = session.createQuery("from Dpt");
query.setMaxResults(15);
query.setFirstResult(0);
return query.list();
}
});
}
------最佳解决方案--------------------
hibernate配置文件里
<prop key="hibernate.dialect">
org.hibernate.dialect.MySQLDialect
</prop>这句有没有
------其他解决方案--------------------
LZ,你发表的另外一个帖子有回复,你去看看,是否对你有帮助,也是这个问题的!
------其他解决方案--------------------
支持一下楼主!
------其他解决方案--------------------
LZ,建议你看看自己的配置文件,对象Dpt和你的hibernate配置文件的列,属性是否一致!
------其他解决方案--------------------
<hibernate-mapping>
    <class name="org.heb.lib.sms.model.Dpt" table="dpt">
        <id name="id" type="java.lang.Integer">
            <column name="Id" />
            <generator class="native" />
        </id>
        <property name="text" type="java.lang.String">
            <column name="text" length="500" />
        </property>
        <property name="url" type="java.lang.String">
            <column name="url" length="500" />
        </property>
        <property name="parentId" type="java.lang.Integer">
            <column name="parentId" />
        </property>
        <property name="cls" type="java.lang.String">
            <column name="cls" length="50" />
        </property>
        <property name="leaf" type="java.lang.Integer">
            <column name="leaf" />
        </property>
&n