I need to call an Oracle (10g) function that receives a CLOB as one of its arguments and returns a CLOB.
How do I call this function using Hibernate (3.5.6-Final) ?
Code:
String xml ="<Hello>World</Hello>";
Query q = session.createSQLQuery("SELECT mySchema.myPackage.myFunction(:client,:theClob) AS myResult FROM DUAL").addScalar("myResult");
q.setParameter("client", 3);
q.setParameter("theClob", xml);
Clob result = (Clob) q.uniqueResult();
The code above fails with " java.sql.SQLException: ORA-01460: unimplemented or unreasonable conversion requested "
So I modified to :
Code:
String xml ="<Hello>World</Hello>";
Clob xmlClob = Hibernate.createClob(xml, session);
Query q = session.createSQLQuery("SELECT mySchema.myPackage.myFunction(:client,:theClob) AS myResult FROM DUAL").addScalar("myResult");
q.setParameter("client", 3);
q.setParameter("theClob", xmlClob);
Clob result = (Clob) q.uniqueResult();
But now the code fails with " java.lang.ClassCastException: $Proxy91 cannot be cast to org.hibernate.engine.jdbc.LobCreationContext "
So i tried
Code:
String xml ="<Hello>World</Hello>";
Clob xmlClob = Hibernate.createClob(xml); // using a deprecated method here
Query q = session.createSQLQuery("SELECT mySchema.myPackage.myFunction(:client,:theClob) AS myResult FROM DUAL").addScalar("myResult");
q.setParameter("client", 3);
q.setParameter("theClob", xmlClob);
Clob result = (Clob) q.uniqueResult();
and now I get "java.sql.SQLException: ORA-06553: PLS-306: wrong number or types of arguments in call to 'PROCESSUNSAVEDCONTENTCLOB' "
Any suggestions?