`
lysming
  • 浏览: 24556 次
  • 来自: ...
社区版块
存档分类
最新评论

hibernate3.2 解决原生态sql支持oracle11g的binary_double和binary_float的办法

阅读更多
环境:hibernate3.2.6GA,oracle11g(使用的ojdbc6.jar)
在进行原生态sql查询时,查询binary_double和binary_float类型字段时报错,报错信息参见最后。
解决方式:自定义Dialect,类如下
import java.sql.Types;
import org.hibernate.dialect.Oracle10gDialect;

/**
 * @author lysming
 *
 */
public class Oracle11gDialect extends Oracle10gDialect {
	public Oracle11gDialect() {
		super();
		registerHibernateType(100, "string");//binary_float
		registerHibernateType(101, "string");//binary_double
	}
}

我使用了String来处理binary_float和binary_double,具体情况看大家的实际需要。
在hibernate.cfg.xml中指定使用自定义的Dialect:
……
<property name="dialect">
     com.glodon.common.web.dao.Oracle11gDialect
</property>
……

详细错误信息如下:
Stacktraces
org.hibernate.MappingException: No Dialect mapping for JDBC type: 101     org.hibernate.dialect.TypeNames.get(TypeNames.java:56)
    org.hibernate.dialect.TypeNames.get(TypeNames.java:81)
    org.hibernate.dialect.Dialect.getHibernateTypeName(Dialect.java:370)
    org.hibernate.loader.custom.CustomLoader$Metadata.getHibernateType(CustomLoader.java:559)
    org.hibernate.loader.custom.CustomLoader$ScalarResultColumnProcessor.performDiscovery(CustomLoader.java:485)
    org.hibernate.loader.custom.CustomLoader.autoDiscoverTypes(CustomLoader.java:501)
    org.hibernate.loader.Loader.getResultSet(Loader.java:1796)
    org.hibernate.loader.Loader.doQuery(Loader.java:674)
    org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:236)
    org.hibernate.loader.Loader.doList(Loader.java:2213)
    org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2104)
    org.hibernate.loader.Loader.list(Loader.java:2099)
    org.hibernate.loader.custom.CustomLoader.list(CustomLoader.java:289)
    org.hibernate.impl.SessionImpl.listCustomQuery(SessionImpl.java:1695)
    org.hibernate.impl.AbstractSessionImpl.list(AbstractSessionImpl.java:142)
    org.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:152)
    com.glodon.common.web.dao.CommonDAOImpl.getPage(CommonDAOImpl.java:203)
    com.glodon.common.web.business.BaseService.getAsPage(BaseService.java:42)
    sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    java.lang.reflect.Method.invoke(Method.java:597)
    org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:310)
    org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)
    org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
    org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106)
    org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
    org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:89)
    org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
    org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
    $Proxy82.getAsPage(Unknown Source)
    com.glodon.common.web.action.BaseAction.list(BaseAction.java:107)
    com.glodon.common.web.action.BaseAction.execute(BaseAction.java:92)
    sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    java.lang.reflect.Method.invoke(Method.java:597)
    com.opensymphony.xwork2.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:441)
    com.opensymphony.xwork2.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.java:280)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:243)
    com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:165)
    com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
    com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:252)
    org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:68)
    com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
    com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:122)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
    com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:195)
    com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
    com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:195)
    com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
    com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.java:179)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
    org.apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:235)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
    com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept(ModelDrivenInterceptor.java:89)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
    com.opensymphony.xwork2.interceptor.ChainingInterceptor.intercept(ChainingInterceptor.java:126)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
    com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterceptor.java:138)
    com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
    org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:164)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
    com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:195)
    com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
    org.apache.struts2.interceptor.MultiselectInterceptor.intercept(MultiselectInterceptor.java:75)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
    org.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:94)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
    com.opensymphony.xwork2.interceptor.I18nInterceptor.intercept(I18nInterceptor.java:165)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
    com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept(AliasInterceptor.java:179)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
    com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:176)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
    com.opensymphony.xwork2.DefaultActionProxy.execute(DefaultActionProxy.java:130)
    org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:488)
    org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:395)
    org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
    org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    com.opensymphony.sitemesh.webapp.SiteMeshFilter.obtainContent(SiteMeshFilter.java:129)
    com.opensymphony.sitemesh.webapp.SiteMeshFilter.doFilter(SiteMeshFilter.java:77)
    org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
    org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    org.apache.struts2.dispatcher.ActionContextCleanUp.doFilter(ActionContextCleanUp.java:102)
    org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
    org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    com.glodon.common.web.filter.UserFilter.doFilter(UserFilter.java:92)
    org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
    org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:96)
    org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
    org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
    org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
    org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
    org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
    org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
    org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)
    org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
    org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
    org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
    org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)
    org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
    org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
    org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)
    java.lang.Thread.run(Thread.java:619)
分享到:
评论

相关推荐

    cef_binary_3.2623.1395.g3034273_windows32

    标题中的"cef_binary_3.2623.1395.g3034273_windows32"指的是Chromium Embedded Framework (CEF) 的一个特定版本,这是一个开源项目,它允许开发者将Google Chromium浏览器引擎嵌入到他们的应用程序中。这个版本号3....

    cef_binary_3.2623.1395.g3034273_macosx64.part1

    cef_binary_3.2623.1395.g3034273_macosx64

    cef_binary_3.2623.1395.g3034273_windows32.part2

    cef_binary_3.2623.1395.g3034273_windows32

    pls_interger 和binary_integer的区别与多种数据类型说明

    Oracle 中的数据类型详解 Oracle 中的数据类型可以分为四种:标量(SCALAR)、复合(COMPOSITE)、引用(REFERENCE)和 LOB。下面将详细介绍标量类型的特性。 数字类型 数字类型可以分为三种基本类型:NUMBER、...

    cef_binary_3.2623.1401.gb90a3be_windows32.7z

    cef_binary_3.2623.1401.gb90a3be_windows32.7z cef_binary_3.2623.1401.gb90a3be_windows32.7z cef_binary_3.2623.1401.gb90a3be_windows32.7z

    cef_binary_3.2623.1401 重编译支持Mp3、Mp4

    在提供的压缩包中,`cef_binary_3.2623.1401.gb90a3be_windows32` 和 `cef_binary_3.2623.1401.gb90a3be_windows64` 分别是为32位和64位Windows系统编译的二进制文件。开发者可以根据他们的应用程序是为哪种系统架构...

    cef_binary_3.3071.1649.g98725e6

    这个"cef_binary_3.3071.1649.g98725e6"是CEF的一个特定版本,用于集成到软件开发中,以提供强大的Web渲染和网络功能。 首先,版本号"3.3071.1649.g98725e6"包含了CEF的三个主要组成部分:主版本号、次版本号和Git...

    num2bin.rar_Float to binary_Help!_binary_to_float

    help for convert float number to binary num

    cef_binary_87.1.14+ga29e9a3+chromium-87.0.4280.141_windows32.7z

    2.在工程属性页包含目录:cef_binary_87.1.14+ga29e9a3+chromium-87.0.4280.141_windows32和cef_binary_87.1.14+ga29e9a3+chromium-87.0.4280.141_windows32\libcef_dll\base 3.预处理器定义增加:NOMINMAX

    cef_binary_92.0.27+g274abcf+chromium-92.0.4515.159_windows64.zip

    标题中的"cef_binary_92.0.27+g274abcf+chromium-92.0.4515.159_windows64.zip"指的是CEF(Chromium Embedded Framework)的一个特定版本的二进制文件,这个版本是92.0.27,基于g274abcf的修订版,并且与Chromium ...

    cef_binary_3.3239.1723.g071d1c1_windows64.zip

    在提供的压缩包文件“cef_binary_3.3239.1723.g071d1c1_windows64.zip”中,我们可以看到CEF的一个特定版本,即3.3239.1723,它已经针对x86架构进行了编译,并且支持MP3、AAC和MP4等多媒体格式。这意味着你可以使用...

    cef_binary_3.2623.1395.g3034273_macosx64.part2

    cef_binary_3.2623.1395.g3034273_macosx64

    oracle(9i)pl_sql+oracle(11g)pl_sql参考手册

    此压缩包包含了两个重要的官方参考手册,分别是针对Oracle 9i和11g版本的PL/SQL部分,都是了解和精通Oracle数据库编程的宝贵资源。 `oracle(9i)pl_sql.pdf`文档可能涵盖以下关键知识点: 1. **PL/SQL基础**:包括...

    cef_binary_3.1547.1412_windows32.7z

    总的来说,"cef_binary_3.1547.1412_windows32.7z"文件为Windows 32位平台的开发者提供了一种强大且灵活的方式来集成和控制基于WebKit的Web界面,极大地拓展了桌面应用的可能性。无论是创建一个简单的Web视图,还是...

    cef_binary2

    集成chrome 内核收集到的 cef_binary , 包含cef 1x,2x,41,43 版本...cef_binary_3.2704.1414.g185cd6c_windows32_client.tar cef_binary_3.2924.1571.gcdcdfa9_windows64_client.tar cef-binary-cef_binary_3.1547.1412

    binary_image.rar_binary opencv_image binary_opencv binary_thresh

    二值图像,正如标题“binary_image.rar_binary opencv_image binary_opencv binary_thresh”所暗示的,是只包含两种像素值(通常为0和255)的图像,分别代表背景和前景。这种图像简化了图像处理任务,如目标检测、...

    binary_bitmap.zip_binary_binary image_bitmap_image binary_made

    标题中的“binary_bitmap.zip_binary_binary image_bitmap_image binary_made”暗示了这个压缩包与二进制图像处理有关,特别是涉及到位图(bitmap)的二值化处理。位图是一种像素阵列表示的图像格式,而二值化是将...

    cef_binary_3.1650.1503_windows32.7z

    标题“cef_binary_3.1650.1503_windows32.7z”表明这是一款针对Windows 32位操作系统的CEF(Chromium Embedded Framework)二进制文件的压缩包。CEF是一个开源框架,它允许开发人员在他们的应用程序中嵌入Chromium...

    cef_binary_79.1.38+gecefb59+chromium-79.0.3945.130_windows32_release_symbols

    最新(2020年2月发布)编译后支持音视频格式(mp3/mp4)的 cef_binary_79.1.38 发布包 x32(x86) 包,对应的 cefsharp 版本是 CefSharp -Version 79.1.360,下载后若不清楚如何使用,加q2826977662咨询,工作日时间都...

Global site tag (gtag.js) - Google Analytics