'Does Hibernate support PL/SQL record types?

I am using Hibernate as ORM tool in my application, and I am calling stored procedure for it, but I did not see any PL/SQL record type handling in Hibernate,

Is there any setting needed in Hibernate to support PL/SQL record type?

Note -

Hibernate internally uses JDBC, and JDBC does not support Record type, How hibernate resolve this by supporting Record type



Solution 1:[1]

Yes, you have to create hibernate entity for each stored procedure return type and register them into hibernate config.

hibernateSession.createSQLQuery("SELECT * FROM FOO").addEntity(Foo.class);

And add Foo config like:

<!-- Foo.hbm.xml -->
...
<hibernate-mapping>
    <class name="com.sample.Foo" table="FOO" ...>
        ...
    </class>
    ...

</hibernate-mapping>

Solution 2:[2]

You can convert the record into columns for eg:

SELECT (q.r).* FROM (SELECT r) q;

where r is your record(s)

Then you can treat it like any other query and map to an entity via SQLQuery.addEntity for eg.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2 pstanton