oracle 11g 休眠问题

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1193275/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-18 18:40:13  来源:igfitidea点击:

oracle 11g hibernate problem

oraclehibernateoracle11g

提问by amar4kintu

I am changing my database from PostgreSQL to Oracle 11g. I am using hibernate 3.0 with Java and Struts.

我正在将我的数据库从 PostgreSQL 更改为 Oracle 11g。我在 Java 和 Struts 中使用 hibernate 3.0。

Everything is working fine with PostgreSQL.

使用 PostgreSQL 一切正常。

I have changed following in hibernate.cfg.xml file.

我在 hibernate.cfg.xml 文件中更改了以下内容。

<property name="hibernate.connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
    <property name="hibernate.connection.password">mypassword</property>
    <property name="hibernate.connection.url">jdbc:Oracle:thin:@192.168.1.1:1521/mydb</property>
    <property name="hibernate.connection.username">my_user</property>
    <property name="hibernate.dialect">org.hibernate.dialect.Oracle10gDialect</property>

Everything else is same as that was in Postgresql.

其他一切都与 Postgresql 中的相同。

I am using ojdbc5.jar

我正在使用 ojdbc5.jar

Now when I run my page it gives me following error.

现在,当我运行我的页面时,它给了我以下错误。

ORA-00903: invalid table name

ORA-00903: 无效的表名

Can any one help me regarding the matter?

任何人都可以帮助我解决这个问题吗?

Thanks.

谢谢。

回答by Justin

dpbradley is probably correct, however, I just ran into the following problem with 11g and hibernate: - oracle 11g will let you define a table with a name larger than 30 characters - however, you can't actually refer to that table in a SQL statement because its name is too long.

dpbradley 可能是正确的,但是,我刚刚在 11g 和 hibernate 中遇到了以下问题: - oracle 11g 将允许您定义名称大于 30 个字符的表 - 但是,您实际上无法在 SQL 中引用该表声明,因为它的名字太长。

  • Hibernate auto generated DDL does not seem care or warn when it generates the DDL
  • Hibernate 自动生成的 DDL 在生成 DDL 时似乎并不关心或警告

回答by dpbradley

It's most likely one of two cases:

这很可能是以下两种情况之一:

  1. You are connecting as a user other than the owner of the table and can't resolve the name.
  2. There is a problem with case sensitivity in either the reference to the table name in the code or its actual name.
  1. 您正在以表所有者以外的用户身份进行连接,并且无法解析名称。
  2. 在代码中对表名的引用或其实际名称中存在区分大小写的问题。

If you are not the owner of the table (but have grants to access it!), you'll need to either have an Oracle synonym that translates a reference to MYTABLE into THE_ACTUAL_OWNER.MYTABLE, or reference the schema qualifier directly in your code.

如果您不是该表的所有者(但有权访问它!),您将需要有一个 Oracle 同义词将 MYTABLE 的引用转换为 THE_ACTUAL_OWNER.MYTABLE,或者直接在您的代码中引用模式限定符。

The second case is less likely, but sometimes table creation scripts will create objects in oracle with double quotes around the object name, which will allow creation of mixed-case identifier - CREATE TABLE "myTable" will create the mixed case identifier which then must be referenced by the mixed-case string.

第二种情况不太可能,但有时表创建脚本会在 oracle 中创建对象,对象名称周围带有双引号,这将允许创建混合大小写标识符 - CREATE TABLE "myTable" 将创建混合大小写标识符,然后必须由大小写混合字符串引用。

To provide us with further info, connect with some sort of ad-hoc SQL tool as the same user as your application and post the results of:

为了向我们提供更多信息,请以与您的应用程序相同的用户身份连接某种特定的 SQL 工具,并发布以下结果:

select owner, table_name from all_tables where table_name = 'theNameOfTheTableOfinterest';

select owner, table_name from all_tables where table_name = 'theNameOfTheTableOfinterest';