-->
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.  [ 4 posts ] 
Author Message
 Post subject: executing functions from database oracle
PostPosted: Mon Jun 09, 2008 9:53 am 
Beginner
Beginner

Joined: Wed Apr 23, 2008 2:00 pm
Posts: 20
Hello!
I'm trying executing a function whichs returns me a boolean from my Oracle DB and i'm having some problems.
My mapping definition is like this :

<sql-query name="setTransactions" callable="true">
{? = call MyPackage.myFunction (?,?) }
</sql-query>

and in my java code i'm doing like this :
Session session = HibernateUtil.getSession();
List list = session.getNamedQuery("setTransactions")
.setInteger(0, idTr)
.setString(1, nroContenedor)
.list();
session.close();

When i execute i'm having

ADVERTENCIA: SQL Error: 6550, SQLState: 65000
09/06/2008 10:49:22 org.hibernate.util.JDBCExceptionReporter logExceptions
GRAVE: ORA-06550: line 1, column 13:
PLS-00382: expression is of wrong type
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored
...

Does somebody can help me ?
Thanks !


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 09, 2008 10:33 am 
Expert
Expert

Joined: Tue May 13, 2008 3:42 pm
Posts: 919
Location: Toronto & Ajax Ontario www.hibernatemadeeasy.com
Code:
.setInteger(0, idTr)
.setString(1, nroContenedor)


I think you might want to look at the datatypes of idTr and nroContenedor. I don't think they're Integer and String objects.

_________________
Cameron McKenzie - Author of "Hibernate Made Easy" and "What is WebSphere?"
http://www.TheBookOnHibernate.com Check out my 'easy to follow' Hibernate & JPA Tutorials


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 09, 2008 1:15 pm 
Beginner
Beginner

Joined: Wed Apr 23, 2008 2:00 pm
Posts: 20
actually i found the error. The function was returning a boolean, but in the documentation says that for oracle the functions/procedures must return a ResultSet.
So with this now is working !
Thanks !


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 09, 2008 1:26 pm 
Beginner
Beginner

Joined: Wed Apr 23, 2008 2:00 pm
Posts: 20
i'm having another problem...
when i get the ResultSet from the DB, i'm getting null values whilke i should get a string values...
How i have to configurate my mapping to do this ?
This is how i'm doing now :

<sql-query name="setTransactions" callable="true">
<return class="java.lang.String" />
{ ? = call myPackage.MyFunction(?,?) }
</sql-query>

This gives me an error for the <return class="java.lang.String" />
If i delete it, there is no error but i'm getting null values as a result of my query.


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

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.