karabara karabara - 1 year ago 98
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()

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

Answer Source

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

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download