-->
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: Passing Null parameter for date in stored procedure
PostPosted: Fri Dec 22, 2006 10:04 am 
Newbie

Joined: Wed Jul 13, 2005 11:00 am
Posts: 5
Hi,

I am using hibernate 3.2 with Spring and am facing a problem with passing Date parameters as null to an Oracle Stored procedure. The call to the stored procedure works fine if the date parameters are passed. But if it is not passed, it gives an exception PLS-00306: wrong number or types of arguments in call to PROC_GET_USERS

But the same procedure accepts nulls and returns values if I execute the procedure from command line from Sql Plus.

Any help on the same is appreciated.

-Rajesh


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 22, 2006 1:03 pm 
Senior
Senior

Joined: Mon Oct 23, 2006 5:12 am
Posts: 141
Location: Galicia, Spain
Use

<property name="show_sql">true</property>

and see what SQL Hibernate is sending to Oracle

_________________
andresgr (--don't forget to rate)


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 11, 2007 9:12 am 
Newbie

Joined: Wed Jul 13, 2005 11:00 am
Posts: 5
On further debugging I found that there is a difference between the null binding that hibernate does and the result when we use a direct callable statement and bind null values along with proper parameter types. It seems that since hibernate does not know the parameter type before hand, if the value being bound is null, then it treats the value as SerializableType which is a subclass of NullableType. In this case the nullSafeSet method handles null parameters as follows:
Code:
st.setNull( index, sqlType() );
Here the sqlType() function returns -3 which corresponds to Types.BINARY in java.sql.Types. I debugged the CallableStatement there and found that the binding it creates within is of type rawNullBinder. And this causes an SQL exception like java.sql.SQLException: ORA-06550: line 1, column 7:

PLS-00306: wrong number or types of arguments in call to PROC_NAME. I think if the null binding was done with Types.NULL instead of Types.BINARY, this exception could be avoided. But the strange thing is that it happens only for Dates and Numeric parameters, there is no problem if the null parameter is of type string.

Are there any other solutions for this issue, or am I dwelving too much in to hibernate code?

Note: I am using the Spring hibernate template method:
Code:
findByNamedQueryAndNamedParam(String queryName, String[] paramNames, Object[] values)


Any suggestions are welcome.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jan 13, 2007 6:37 am 
Newbie

Joined: Wed Jul 13, 2005 11:00 am
Posts: 5
Well I found the solution myself. Use the Query interface directly and in the setParameter pass the hibernate type of the prameter also. It works perfectly.


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.