org.hibernate.MappingException: No Dialect 地图ping for JDBC type: -1

org.hibernate.MappingException: No Dialect mapping for JDBC type: -1

我采用的是mysql数据库,sql语句如下:

 select sc.id,sce.title,sc.publishTime,channel.channelPath,sce.author,sce.origin,sce.originUrl,sce.description,sct.txt  from sitenav_content sc,sitenav_channel channel,sitenav_content_ext sce,sitenav_content_txt sct  where sc.channelId=channel.id and sc.id=sce.contentId and sc.id=sct.contentId and sc.id=10038

这句sql直接在mysql的客户端执行是没任何问题的,但是在程序执行就会抛出如下错误:

 

反复分析其原因,可能是查询的某个数据类型,普通的sql语句不支持。sct.txt这个字段是longtext类型的,应该是mysql数据库特有的字段类型,用普通的sql去查询就会报以上错误。

于是我就删除该字段,查询就可以成功执行。

所以,建议某些特殊字段类型的字段,指定数据库的方言后,就用hibernate的HQL去查询,这样就可以避免这类错误。