Hibernate parse Ref Cursor output to Entity

Viewed 53

I'm having trouble mapping an Oracle DB function (which I cannot change) that outputs ref cursor into my @Entity annotated class.

Here is an example of the output of the DB function:

    {<TYPE=2,NAME=SIMON,ID=1>,}

Here is a snippet of my class that I would like to map the result to:

@Entity
@NamedNativeQuery(
   name="getUser",
   query="{ ? = call my_function_get_user(?) }", 
   callable=true)
public class User {

In my repository class I use the EntityManager.createNamedQuery function, which works - it returns a user but just as an Object[] with the values of the User, i.e. 2,SIMON,1.

Is there any elegant way to map this to my entity or will I have to write some code to get elements of the Object array and use the setters to populate the User object?

0 Answers
Related