Hibernate 和 Oracle VARRAYS/NESTED TABLE
Oracle 支持使用 VARRAYS 和 NESTED TABLE 数据类型,允许多值属性。 (http://www.orafaq.com/wiki/NESTED_TABLE)
我目前正在使用 Hibernate 3作为我的 ORM 框架,但我不知道如何将 Hibernate 映射到数据库中的 NESTED TABLE/VARRAY 数据类型。
我考虑过在 Hibernate 中定义自定义类型,但没有成功。 (Hibernate 甚至可以处理取消嵌套子表所需的“COLUMN_VALUE”Oracle 关键字吗?)
有谁知道如何在 Hibernate 中实现这些数据类型?
谢谢大家的帮助。
——TBW。
Oracle supports the use of VARRAYS and NESTED TABLE data types, allowing multivalued attributes. (http://www.orafaq.com/wiki/NESTED_TABLE)
I am currently using Hibernate 3 as my ORM framework, but I can't see how I can map Hibernate to a NESTED TABLE/VARRAY data type in my database.
I looked at defining custom types in Hibernate, with no success. (Can Hibernate even handle the "COLUMN_VALUE" Oracle keyword necessary to unnest the subtable?)
Does anyone know how to implement these data types in Hibernate?
Thank you all for your help.
-- TBW.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Oracle 数字表的 Hibernate 用户类型。
OracleNativeExtractor 在这里找到: https://community.jboss.org/wiki/MappingOracleXmlTypeToDocument 。字符串 YOUR_CUSTOM_ARRAY_TYPE 替换为您的姓名。
Hibernate's UserType for Oracle's TABLE OF NUMBERS.
OracleNativeExtractor found here : https://community.jboss.org/wiki/MappingOracleXmlTypeToDocument . String YOUR_CUSTOM_ARRAY_TYPE replace with your name.
我希望我是错的,并且您在研究中找到更好的答案,但 Hibernate 不支持此功能。 Hibernate 依赖标准 JDBC 与数据库通信,这些功能不是标准的一部分。它们是 Oracle 扩展。
也就是说,我可以想到一些解决方法:
1)实现您自己的 UserType。根据您的特定用户类型,您将有机会操纵数据库提供的值(或即将发送到数据库的值)。但这仅在 Oracle 将此值作为以下 java.sql.Types 之一提供时才有效: http://download.oracle.com/javase/1.5.0/docs/api/java/sql/Types.html
2) 另一种选择是直接使用 JDBC ,通过使用 Hibernate 工作线程。请参阅以下 Worker 示例:https://github.com/hibernate/hibernate-core/blob/master/hibernate-core/src/test/java/org/hibernate/test/jdbc/GeneralWorkTest.java
也就是说,我认为您必须权衡解决方案并重新评估是否确实需要嵌套表。
I hope I'm wrong and that you find a better answer in your research, but this feature is not supported in Hibernate. Hibernate relies on standard JDBC to talk to a database and these features are not part of the standard. They are Oracle extensions.
That said, I can think of a few workarounds:
1) Implement your own UserType. With your specific user type, you'll have a chance to manipulate the values provided by the database (or about to be sent to the database). But that will only work if Oracle provides this value as one of these java.sql.Types: http://download.oracle.com/javase/1.5.0/docs/api/java/sql/Types.html
2) The other option is to use JDBC directly, through the use of a Hibernate worker. See this example of a Worker: https://github.com/hibernate/hibernate-core/blob/master/hibernate-core/src/test/java/org/hibernate/test/jdbc/GeneralWorkTest.java
That said, I think that you have to weight the solutions and re-evaluate if you really need a nested table.