karabara karabara - 18 days ago 8
SQL Question

How to get Clob data from native query?

I have tried this:

List resultList = session.createSQLQuery("select pack.FuncName ClobData from dual").list()


whereis
FuncName
it is the name of function that returns clob data. But in
resultList
I see some proxy object (for example
$Proxy189
). I believe... It is something simple and I don't want ising reflection to get my data.

Answer

Yes, launching SQL querys directly is not a good idea (by default) using an ORM.

Probably one of the solutions that could fit better in your case will be mapping the CLOB data returned by your FuncName to a new non-managed entity (if it's the case). You can create a new entity that fit your requirements and get the data. You can read about it here for example.

Of course other solution can be, launch the function that prepares/buils the clob data, save it (for example in a temporary table structure) and then loading it using the @Lob annotation. Check the reference about Property mapping with annotations