2012-09-18 60 views
1

我正在迁移到休眠4.1并且还添加了对oracle 11g的支持。迁移到4.1似乎与mysql安装程序一致,我正在调试oracle特定的问题。我有一个问题,在oracle抱怨休眠不正确格式化oracle sql

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的这个查询,它失败了。问题似乎与'。'相关。在表名上。如果我删除这个或在查询之前把db用户/模式设置好。

有没有关闭此设置的设置? 我没有提供需要的财产吗?

<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> 
+0

我有一个预感与hibernate.default_schema属性有关,但我还没有完全探索这个 –

+1

您的数据库名为'公共'?因为default_schema是oracle的数据库名称。 –

+0

我的模式与用户相同,我已经更正了这一点,它似乎允许部署artefact。 –

回答

0

这个问题是与

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

此值必须与您所创建的模式。

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