How to convert Oracle user defined Type into java object in spring jdbc stored procedure
<p>I am working on springjdbcTemplate, and all db call will be done through stored procedures. In Oracle 11g I have created one user defined type containing with other type as field inside it as below.</p>

<pre><code>create or replace type WORKER AS Object (NAME VARCHAR2(30),
                                         age NUMBER);

create or replace type WORKER_LIST IS TABLE OF WORKER;

create or replace type MANAGER AS Object(
NAME VARCHAR2(30),
workers WORKER_LIST
);
</code></pre>

<p>And at Java side I have created the classes as follows.</p>

<pre><code>public class Worker implements SQLData {
    private String name;
    private int age;
    @Override
    public String getSQLTypeName() throws SQLException {
        return "WORKER";
    }
    @Override
    public void readSQL(SQLInput stream, String typeName) throws SQLException {
        setName(stream.readString());
        setAge(stream.readInt());

    }
    @Override
    public void writeSQL(SQLOutput stream) throws SQLException {
        stream.writeString(getName());
        stream.writeInt(getAge());
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public int getAge() {
        return age;
    }
    public void setAge(int age) {
        this.age = age;
    }
}

public class Manager implements SQLData  {

    private String name;
    private List&lt;Worker&gt; workers;

    @Override
    public String getSQLTypeName() throws SQLException {
        return "Manager";
    }

    @Override
    public void readSQL(SQLInput stream, String typeName) throws SQLException {
        setName(stream.readString());
        setWorkers((List&lt;Worker&gt;) stream.readObject());
    }

    @Override
    public void writeSQL(SQLOutput stream) throws SQLException {
        stream.writeString(getName());
        stream.writeObject((SQLData) getWorkers());
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public List&lt;Worker&gt; getWorkers() {
        return workers;
    }

    public void setWorkers(List&lt;Worker&gt; workers) {
            this.workers = workers;
        }
    }
</code></pre>

<p>I have mentioned in typeMap about the mappings.</p>

<p>But I am not getting expected results.</p>

<p>Worker type is returned as <code>Struct</code> and <code>List&lt;Worker&gt;</code> is returned as array.</p>

<p>Please let me know what should I have do and what is the standard protocol to get the expected object as I mentioned above. I'm new to JDBCTemplate. Please suggest.</p>

<p>Thanks
Ram</p>