简体   繁体   English

使用EclipseLink在Oracle中调用具有复杂对象类型参数的存储过程

[英]Calling stored procedure in Oracle with complex object type parameters using EclipseLink

Due to the deprecation of JPublisher since Oracle 12c we're currently considering other ways how we can call stored procedures with complex object types as parameters instead of generated classes and JDBC. 由于自Oracle 12c以来不再使用JPublisher,因此我们目前正在考虑其他方法来调用具有复杂对象类型作为参数的存储过程,而不是调用生成的类和JDBC。

It seems that EclipseLink JPA Extensions is the only tool that can help with it. 似乎EclipseLink JPA Extensions是唯一可以提供帮助的工具。 Following the examples I found I'd be able to call procedures with simple types as arguments. 根据这些示例,我发现我可以使用简单类型作为参数调用过程。 But I wasn't able to annotate my entity classes so that they would map correctly to the PL/SQL Object types in the database when the objects are a bit more complex. 但是我无法对我的实体类进行注释,以便在对象更复杂时将它们正确映射到数据库中的PL / SQL对象类型。

For example we have a stored procedure that has one input and one output parameter of the same Object type A. The type structure is following: 例如,我们有一个存储过程,它有一个输入和一个相同的对象类型A的输出参数。类型结构如下:

Object type A contains <- Table type B which is table of <- Object type C which contains <- Table type D which is table of <- Object type E. 对象类型A包含< - 表类型B,它是< - 对象类型C的表,其中包含< - 表类型D,它是< - 对象类型E的表。

I figured I shall use the @OracleObject for the Object types and @PLSQLTable for the Table types but I haven't found a way how to correctly combine them together. 我想应该将@OracleObject用于对象类型并将@PLSQLTable用于表类型,但是我还没有找到一种将它们正确组合在一起的方法。

I've tried the following: 我尝试过以下方法:

// All annotations with the required elements

@Embeddable
@Struct
@OracleObject
public class A {
    @Column(name = "B")
    private B b;

    // Getter and setter
}

@Embeddable
@Struct
@PLSQLTable (.., nestedType = "C")
public class B { }

@Embeddable
@Struct
@OracleObject
public class C {}

I've tried to add the @PLSQLTable with the proper annotation elements to class A and/or to class C but the Java and DB objects do not map to each other correctly and I'm getting the java.sql.SQLException: Invalid column type during the call. 我试图将带有正确注释元素的@PLSQLTable添加到类A和/或类C但是Java和DB对象没有正确映射到彼此并且我得到java.sql.SQLException: Invalid column type在通话过程中。

I'd greatly appreciate if someone could explain to me how to use the annotations to tell the EclipseLink that Object A contains Table B of Object C. 如果有人能够向我解释如何使用注释告诉EclipseLink对象A包含对象C的表B,我将不胜感激。

Thank you very much. 非常感谢你。

Same issue here. 同样的问题在这里 I have been going down the path of Spring Data Oracle Extension project. 我一直走在Spring Data Oracle Extension项目的道路上。 However the example given is a simple pojo, not a complex object. 然而,给出的示例是一个简单的pojo,而不是一个复杂的对象。
Despite a lack of examples anywhere I can find, I was able to pull a very complex object back via SqlReturnSqlData(), but can't seem to find a way to insert a complex object into an oracle stored procedure. 尽管在任何地方都找不到示例,但是我仍然可以通过SqlReturnSqlData()将非常复杂的对象拉回去,但似乎找不到找到将复杂对象插入到oracle存储过程中的方法。 I have yet to find any full example of how anyone is inserting custom complex Oracle Types. 我还没有找到任何人如何插入自定义复杂Oracle类型的完整示例。 Via Spring or any other way. 通过Spring或任何其他方式。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM