-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Function call with CLOB parameter and result
PostPosted: Wed Oct 13, 2010 1:15 pm 
Newbie

Joined: Thu Apr 08, 2010 11:34 am
Posts: 7
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?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.