【问题标题】:Hibernate incorrectly formatting oracle sqlHibernate 错误地格式化 oracle sql
【发布时间】:2012-09-18 08:23:24
【问题描述】:

我正在迁移到 hibernate 4.1 并添加对 oracle 11g 的支持。 mysql 设置迁移到 4.1 似乎没有问题,我正在调试 oracle 特定问题。我有一个 Oracle 抱怨的问题

java.sql.SQLException: ORA-00903: invalid table name

我应该提到这个设置也使用 c3p0 和 ehcache。

导致此异常的查询是:

DEBUG org.hibernate.SQL  - 

select
    dp.id as id168_,
    dp.Description as Descript2_168_,
    dp.name as name168_,
    case 
        when dp1_.id is not null then 1 
        when dp2_.id is not null then 2 
        when dp.id is not null then 0 
    end as clazz_ 
from
    .tableA dp 
left outer join
    .tableB dp1_ 
        on dp.id=dp1_.id 
left outer join
    .tableC dp2_ 
        on dp.id=dp2_.id

我在 SQL Developer 中尝试过这个查询,但失败了。问题似乎与“。”有关。在表名上。如果我删除它或在查询良好之前放置数据库用户/模式。

是否有关闭此符号的设置? 我没有提供需要的属性吗?

<properties>
        <property name="hibernate.dialect" value="org.hibernate.dialect.Oracle10gDialect"/>
        <property name="hibernate.connection.driver_class" value="oracle.jdbc.OracleDriver"/>
        <property name="hibernate.connection.username" value="myUser"/>
        <property name="hibernate.connection.password" value="myPassword"/>
        <property name="hibernate.connection.url" value="jdbc:oracle:thin://@192.168.X.X:1521:oracledb"/>
        <property name="hibernate.archive.autodetection" value=""/>

        <property name="hibernate.format_sql" value="true"/>
        <property name="hibernate.show_sql" value="true"/>
        <property name="hibernate.default_schema" value="public"/>

        <property name="hibernate.ejb.cfgfile" value="META-INF/hibernate.cfg.xml"/>

        <!-- cache configuration -->
        <property name="hibernate.cache.region.factory_class" value="org.hibernate.cache.ehcache.SingletonEhCacheRegionFactory" />
        <property name="hibernate.cache.use_second_level_cache" value="true"/>
        <property name="hibernate.cache.use_query_cache" value="true"/>

        <!-- pool configuration -->
        <property name="hibernate.connection.provider_class" value="org.hibernate.service.jdbc.connections.internal.C3P0ConnectionProvider" />
        <property name="hibernate.c3p0.max_size" value="50" />
        <property name="hibernate.c3p0.min_size" value="5" />
        <property name="hibernate.c3p0.acquire_increment" value="1" />
        <property name="hibernate.c3p0.idle_test_period" value="17" />
        <property name="hibernate.c3p0.max_statements" value="0" />
        <property name="hibernate.c3p0.timeout" value="3600" />
        <property name="hibernate.c3p0.preferredTestQuery" value="SELECT 1 FROM DUAL"/>

    </properties>

【问题讨论】:

  • 我预感它与 hibernate.default_schema 属性有关,但我还没有完全探索过这个
  • 您的数据库是否命名为“public”?因为 default_schema 是 oracle 的数据库名称..
  • 我的架构与用户相同,我已更正此问题,似乎允许部署人工制品。
  • 你能给我们看看映射文件和HQL语句吗?

标签: oracle hibernate


【解决方案1】:

这个问题与

<property name="hibernate.default_schema" value="public"/>

此值需要与您创建的架构相匹配。

ctapobep 的评论帮助确定了这个问题。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-11-21
    • 1970-01-01
    • 2019-10-01
    • 1970-01-01
    • 1970-01-01
    • 2020-10-04
    • 1970-01-01
    • 2013-03-24
    相关资源
    最近更新 更多