mysql text字段Hibernian映射 调用session.createSQLQuery(queryString).list()执行sql语句时出错的问题 高手进
近期做了一个空间
数据查询分页展示的控件
基于Hibernian的
Java code
/**
* 该方法用sql来获取分页显示的数据
* @param HibernateSessionFactory.getSession();
* @param sqlstr 查询语句
* @param pageNo 页码
* @param page_size 每页显示条目
* @return List 返回第pageNo页的数据
* 参考http://tech.it168.com/j/d/2007-02-01/200702011251562.shtml
*/
@SuppressWarnings("unchecked")
public List findCutPageForSQL(Session session,final String sqlstr,final int pageNo,final int page_size){
String queryString = sqlstr;
queryString+=" limit "+(pageNo-1)*page_size+","+page_size;
System.out.println("$"+queryString);
return session.createSQLQuery(queryString).list();
}
其中定义了如上方法用来调用sql语句
能够打印出如下sql语句
$ select id,syslogdate,hostIp,facilities,levels,message from Historysyslogdailup
但抛出如下错误:
org.hibernate.MappingException: No Dialect mapping for JDBC type: -1
at org.hibernate.dialect.TypeNames.get(TypeNames.java:56)
at org.hibernate.dialect.TypeNames.get(TypeNames.java:81)
at org.hibernate.dialect.Dialect.getHibernateTypeName(Dialect.java:192)
at org.hibernate.loader.custom.CustomLoader.getHibernateType(CustomLoader.java:161)
at org.hibernate.loader.custom.CustomLoader.autoDiscoverTypes(CustomLoader.java:131)
at org.hibernate.loader.Loader.getResultSet(Loader.java:1678)
at org.hibernate.loader.Loader.doQuery(Loader.java:662)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:224)
at org.hibernate.loader.Loader.doList(Loader.java:2145)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2029)
at org.hibernate.loader.Loader.list(Loader.java:2024)
at org.hibernate.loader.custom.CustomLoader.list(CustomLoader.java:111)
at org.hibernate.impl.SessionImpl.listCustomQuery(SessionImpl.java:1655)
at org.hibernate.impl.AbstractSessionImpl.list(AbstractSessionImpl.java:142)
at org.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:164)
at com.by.demo.data.CutPage.findCutPageForSQL(CutPage.java:56)
at com.by.demo.data.GetDataList.GetDataListForSQL(GetDataList.java:137)
at com.by.demo.data.DBSource.findDataForSQL(DBSource.java:52)
at com.by.demo.data.Data.GetDataList(Data.java:53)
at
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.directwebremoting.impl.ExecuteAjaxFilter.doFilter(ExecuteAjaxFilter.java:34)
at org.directwebremoting.impl.DefaultRemoter$1.doFilter(DefaultRemoter.java:428)
at org.directwebremoting.impl.DefaultRemoter.execute(DefaultRemoter.java:431)
at org.directwebremoting.impl.DefaultRemoter.execute(DefaultRemoter.java:283)
at org.directwebremoting.servlet.PlainCallHandler.handle(PlainCallHandler.java:52)
at org.directwebremoting.servlet.UrlProcessor.handle(UrlProcessor.java:101)
at org.directwebremoting.servlet.DwrServlet.doPost(DwrServlet.java:146)
at
javax.servlet.http.HttpServlet.service(HttpServlet.java:710) at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilter