如题 ,我在编写j2ee的过程中碰到了这个问题,查了一些资料,有些人说是在hibernate中没定义过text类型(我的数据库表确实有这个类型的字段)可是我按照它的写法做了。。还是会出问题
以下是错误
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)
        ......................
我的三个表分别是subarea,reside,userinfo
subarea:id,subareaname
reside: id,sid, rname,content,edituserid-------其中content就是text类型的字段 
userinfo:id,userinfo--------等字段 
其中reside中的sid关联subarea表的id,edituserid关联userinfo的id
在做j2ee的过程中。它会自动生成pojo(所有的pojo以及配置文件都是自动生成的,在更新完数据库后,我把所有的映射,配置都删掉重新弄了,也是用工具自动生成的
其中reside.java类的内容为
private Integer id;
private Userinfo userinfo
private Subarea subarea;
private String rname;
private String content;
(**************省略get.set方法*****************)
它的查询方法是
public List indexlist(){
session=HibernateSessionFactory.getSession();
try{
sqlquery=session.createSQLQuery("select reside.id,reside.sid,reside.rname,reside.content,reside.edituserid,userinfo.username from reside,userinfo where reside.edituserid=userinfo.id");
List indexlist=sqlquery.list();
return indexlist;
}catch(Exception ex){
ex.printStackTrace();
System.out.println("分区读取出错");
return null;
}finally{
if(session.isOpen()){
session.close();
}
}
}出现这种错误是为什么啊,在之前我没更新数据库之前(即未加放content字段时就不会出现这种错误)

解决方案 »

  1.   

    我也是
    严重: Servlet.service() for servlet default threw exception
    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:231)
    at org.hibernate.loader.custom.CustomLoader$Metadata.getHibernateType(CustomLoader.java:559)
    at org.hibernate.loader.custom.CustomLoader$ScalarResultColumnProcessor.performDiscovery(CustomLoader.java:485)
    at org.hibernate.loader.custom.CustomLoader.autoDiscoverTypes(CustomLoader.java:501)
    at org.hibernate.loader.Loader.getResultSet(Loader.java:1677)
    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:2144)
    at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2028)
    at org.hibernate.loader.Loader.list(Loader.java:2023)
    at org.hibernate.loader.custom.CustomLoader.list(CustomLoader.java:289)
    at org.hibernate.impl.SessionImpl.listCustomQuery(SessionImpl.java:1695)
    at org.hibernate.impl.AbstractSessionImpl.list(AbstractSessionImpl.java:142)
    at org.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:150)
    at com.union.dao.HibernateGenericDao.pagedQueryBySql(HibernateGenericDao.java:394)
    at com.union.service.product.Impl.UnionSiteProductServiceImpl.getUnionSiteProductInfo(UnionSiteProductServiceImpl.java:21)
    at com.union.service.product.Impl.UnionSiteProductServiceImpl$$FastClassByCGLIB$$d3a34512.invoke(<generated>)
    at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:149)
    at org.springframework.aop.framework.Cglib2AopProxy$CglibMethodInvocation.invokeJoinpoint(Cglib2AopProxy.java:700)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
    at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
    at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:89)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
    at org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:635)
      

  2.   

    我也遇到类似问题,问题已解决,在下面的地址找到解决方法。http://blog.csdn.net/lizhihai_99/article/details/6079960