How to map Java class to Oracle custom type to use as IN parameter in stored procedure?
NickName:DarioJ Ask DateTime:2019-08-07T01:16:23

How to map Java class to Oracle custom type to use as IN parameter in stored procedure?

I'm trying to use a custom object in oracledb as IN parameter for a procedure, but I'm having issues sending it from my java application

I tried mapping the DTO class directly in query.registerStoredProcedureParameter(1, CustomClass.class, ParameterMode.IN);

Also I didn't find this particular question in stackoverflow

Java code:

    private String executeSP(CustomClass dto) {
    StoredProcedureQuery query = em.createStoredProcedureQuery("PACKAGE.SOMEPROCEDURE");
    query.registerStoredProcedureParameter(1, CustomClass.class, ParameterMode.IN);
    query.registerStoredProcedureParameter(2, String.class, ParameterMode.OUT);

    // Pass the parameter values
    query.setParameter(1, dto);

    // Execute query
    query.execute();

    // Get output parameters
    String response = (String) query.getOutputParameterValue(2);

    System.out.println(response);
    return response;
}

PL SQL Procedure:

PROCEDURE SOMEPROCEDURE (
  P_DTO                  IN     DTOTYPE (previously created)
  P_RESULT                  OUT     VARCHAR2);

Expected result: Hibernate maps the dto to the oracle custom object Actual result: org.hibernate.MappingException: Unknown entity

Copyright Notice:Content Author:「DarioJ」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/57381082/how-to-map-java-class-to-oracle-custom-type-to-use-as-in-parameter-in-stored-pro

More about “How to map Java class to Oracle custom type to use as IN parameter in stored procedure?” related questions

How to map Java class to Oracle custom type to use as IN parameter in stored procedure?

I'm trying to use a custom object in oracledb as IN parameter for a procedure, but I'm having issues sending it from my java application I tried mapping the DTO class directly in query.

Show Detail

Mapping an Oracle stored procedure result to a custom Java type (class)

I have to call a stored procedure in Oracle (11g) that uses a single IN OUT parameter. This parameter is an Oracle custom type defined as CREATE OR REPLACE TYPE "SEPADD"."T_NAPRAVI_NALOG_TEST" IS

Show Detail

Oracle Stored Procedure and custom data type

I have an Oracle stored procedure which takes two parameters: a custom data type and a string. Calling the stored procedure in Oracle, I would do the following: EXECUTE MY_STORED_PROCEDURE(MYTYPE...

Show Detail

Call Oracle procedure with list of Java object as in parameter from spring boot

So we have a requirement where we need to call Oracle stored procedure by passing a custom list of Java object as in parameter using spring boot, I did some research and couldn't get a proper

Show Detail

Mule: Invoking an Oracle stored procedure which returns a table of custom type

I am using Mule CE 3.6.1. I have the following Database connector configuration calling an Oracle stored procedure. <db:stored-procedure config-ref="Oracle_Configuration" doc:name="Database"&gt...

Show Detail

How to Pass Java List of Objects to Oracle Stored Procedure Using MyBatis?

I have been googling this for a while and cannot seem to find any real answers. I have an Oracle stored procedure that has a number of in parameters that have a type that is table of the table row...

Show Detail

Pass oracle object type to java stored procedure

Is is possible to pass oracle object type to java stored procedure. Here's what i have so far. Java stored procedure: create or replace and compile java source named Example as import java.sql.SQLD...

Show Detail

How to call Oracle stored procedure with custom object as input parameter

In Oracle database I have defined type: create or replace TYPE person_type AS OBJECT (id NUMBER(10), name VARCHAR2(50), age NUMBER); and a stored procedure create or replace PROCEDURE add_pe...

Show Detail

Java ,Spring Framework Calling Oracle Stored Procedure with CURSOR as input Parameter

Normally, we register cursor as an out parameter to retreive the values from oracle stored procedure. Below code is for Spring: RowMapper<?> rowMapper = new DataRowMapper(tableName);

Show Detail

Calling a stored procedure from java that accepts parameter of type Record

I want to write a simple insert statement in an Oracle stored procedure. The target table has 40 columns. So rather than passing all parameters to the procedure one by one, I am planning to accept an

Show Detail