Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8719431
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T06:47:48+00:00 2026-06-13T06:47:48+00:00

I am facing difficulty while fetching Complex Object Type from Oracle to Java. I

  • 0

I am facing difficulty while fetching Complex Object Type from Oracle to Java.

I am using Spring JDBCTemplate and Spring StoredProcedure.

At the Oracle end I have used a function which return an OBJECT(UNIT)which consists of TABLE(DIVISION_TAB) of an OBJECT(DIVISION) which itself consists of a TABLE(EMPLOYEE_TAB) of another OBJECT(EMPLOYEE).

These types are defined as below:

create or replace TYPE UNIT AS OBJECT 
( 
  UNIT_ID        NUMBER(38),
  UNIT_NAME      VARCHAR(50),
  DIVIVSION_LIST DIVIVSION_TAB
)

create or replace
TYPE DIVISION_TAB
AS TABLE OF DIVISION

create or replace
TYPE DIVISION AS OBJECT 
( 
  DIV_ID        NUMBER(38),
  DIV_NAME      VARCHAR(50),
  DIV_STATUS    NUMBER(38),
  EMPLOYEE_LIST EMPLOYEE_TAB
)

create or replace
TYPE EMPLOYEE_TAB
AS TABLE OF EMPLOYEE

create or replace
    TYPE EMPLOYEE AS OBJECT 
    ( 
      EMP_ID        NUMBER(38),
      EMP_NAME      VARCHAR(50),
      EMP_STATUS    NUMBER(38),
      EMP_SAL       NUMBER(20),
    )

Function at Database level return me an SQL Object of UNIT, which I am using in the following way while retrieving it in Java.

declareParameter(new SqlOutParameter("UNIT", OracleTypes.STRUCT, "UNIT",new SqlReturnType() {
         public Object getTypeValue(CallableStatement callableStatement, int colIndx, int sqlType, String typeName) 
            throws SQLException {
        Connection connection = callableStatement.getConnection();

        Map<String, Class<?>> typeMap = connection.getTypeMap();
        typeMap.put("UNIT", Unit.class);
        typeMap.put("DIVISION_TAB", java.sql.Array.class);
        typeMap.put("DIVISION", Division.class);
        typeMap.put("EMPLOYEE_TAB", java.sql.Array.class);
        typeMap.put("EMPLOYEE", Employee.class);

        STRUCT struct = (STRUCT)callableStatement.getObject(colIndx);
        Object[] attr = struct.getAttributes();
        return attr;
        }
    }));

PROBLEM::::

When I am debugging Object[] returned by SqlReturnType() method then I am able to fetch the details like UNIT_ID and UNIT_NAME but on the 3rd attribute i.e of type oracle.sql.ARRAY, when I am performing the following operation :

        ARRAY array = (ARRAY)attr[3];
    Object[] objects =  (Object[])((ARRAY)attr[3]).getArray();

it throws SQL Internat Exception.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T06:47:49+00:00Added an answer on June 13, 2026 at 6:47 am

    This problem was resolved. Just a simple mistake. The code is perfectly correct, I just missed giving grant to the TYPES I have defined.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am facing difficulty in writing a generic class in java whose generic members
I am facing difficulty to handle my own exception from Anonymous Inner class which
I am facing difficulty to write hibernate mapping with java annotation for problem as
I'm new to OpenGL. I'm using Java/JOGL. I'm having difficulty with polygon faces. I
I am facing extreme difficulty digesting the concepts of assembly language programming. I am
Facing some issue in Talend Admin Console, the jobs that are running from IDE
issue facing while loading the messages in to mq channel, recieving an error like
Guyz facing problems with creating a push notification service (for android) using Google C2DM
I am new to JUnit and facing difficulty in writing JUnit. I have an
I start learning the Java generic collection using Deitel Harvey book - but I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.