错误: 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数据库 mysqlhibernate 方法public List findPageByQuery(final String queryString,final Object[] parameters, final PageInfo pageInfo) {
return getHibernateTemplate().executeFind(new HibernateCallback(){
public Object doInHibernate(Session session)throws HibernateException, SQLException{
Query query = session.createQuery("from Dpt");
query.setMaxResults(15);
query.setFirstResult(0);
return query.list();
}
});
}
return getHibernateTemplate().executeFind(new HibernateCallback(){
public Object doInHibernate(Session session)throws HibernateException, SQLException{
Query query = session.createQuery("from Dpt");
query.setMaxResults(15);
query.setFirstResult(0);
return query.list();
}
});
}
<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>
<property name="code" type="java.lang.String">
<column name="code" length="50" />
</property>
</class>
</hibernate-mapping>
import java.util.Set;/**
* Dpt entity. @author MyEclipse Persistence Tools
*/public class Dpt implements java.io.Serializable { // Fields private Integer id;
private String text;
private String url;
private Integer parentId;
private String cls;
private Integer leaf;
private String code; // Constructors /** default constructor */
public Dpt() {
} /** full constructor */
public Dpt(String text, String url, Integer parentId, String cls,
Integer leaf, String code) {
this.text = text;
this.url = url;
this.parentId = parentId;
this.cls = cls;
this.leaf = leaf;
this.code = code;
} // Property accessors public Integer getId() {
return this.id;
} public void setId(Integer id) {
this.id = id;
} public String getText() {
return this.text;
} public void setText(String text) {
this.text = text;
} public String getUrl() {
return this.url;
} public void setUrl(String url) {
this.url = url;
} public Integer getParentId() {
return this.parentId;
} public void setParentId(Integer parentId) {
this.parentId = parentId;
} public String getCls() {
return this.cls;
} public void setCls(String cls) {
this.cls = cls;
} public Integer getLeaf() {
return this.leaf;
} public void setLeaf(Integer leaf) {
this.leaf = leaf;
} public String getCode() {
return this.code;
} public void setCode(String code) {
this.code = code;
}}
而且在sql 底下就没事,为什么
getHibernateTemplate().execute(new HibernateCallback() {
public Object doInHibernate(Session session)
throws HibernateException, SQLException {
Query q = session.createQuery(hql);
q.setFirstResult(Integer.parseInt(start));
q.setMaxResults(Integer.parseInt(limit));
list = q.list();
return list;
}
});
return list;
}
LZ,我是这么使用的,以前!是用 execute,不是你的executeFind!!!你修改试试!
正常来说你的dao传入的参数都是要用的,LZ,你传入的几个参数,没看到使用,
如果不行,给后面对象设置个别名!
from Dpt p !!!
<prop key="hibernate.dialect">
org.hibernate.dialect.MySQLDialect
</prop>这句有没有
<prop key="hibernate.dialect">
org.hibernate.dialect.MySQLDialect
</prop>这句有没有LZ,看来估计就只剩这个原因了,你看看你修改了没!!或者
<prop key="hibernate.dialect">org.hibernate.dialect.MySQLInnoDBDialect</prop>我估计你的还是<prop key="hibernate.dialect">
org.hibernate.dialect.SQLServerDialect
</prop>