-->
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.  [ 2 posts ] 
Author Message
 Post subject: Oracle exception: ORA-24816: Expanded non LONG bind data
PostPosted: Thu Jan 18, 2007 5:25 pm 
Newbie

Joined: Wed Jan 17, 2007 7:18 am
Posts: 2
Hello

I have run into the following problem when saving long string values through a spring/hibernate framework to a varchar2(4000 char) column in an Oracle 10g database.

Caused by: java.sql.SQLException: ORA-24816: Expanded non LONG bind data supplied after actual LONG or LOB column

This only happens when the string is over 1000 characters but strangely I can save strings up to 4000 characters through test cases (using spring, hibernate and oracle) and directly with a jdbc client.

I am using the latest Oracle thin jdbc jar file.

Thanks in advance

Mandy


Top
 Profile  
 
 Post subject: Ugly Brutal Hack
PostPosted: Tue Apr 24, 2007 11:03 am 
Newbie

Joined: Tue Sep 20, 2005 3:51 pm
Posts: 18
Location: Boston, MA
Hello Mandy,
I had this problem as well. We hacked it via
Code:
@org.hibernate.annotations.SQLInsert(callable= true, sql="call newItem(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)")

To quote http://www.hibernate.org/hib_docs/annot ... ml_single/ :
Quote:
The parameters order is important and is defined by the order Hibernate handle properties. You can see the expected order by enabling debug logging for the org.hibernate.persister.entity level. With this level enabled Hibernate will print out the static SQL that is used to create, update, delete etc. entities. (To see the expected sequence, remember to not include your custom SQL through annotations as that will override the Hibernate generated static sql.)


It was an ugly workaround. First we enabled SQL debug and watched hibernate insert to figure out the order in which hibernate passed its parameters to the insert statement. Then we coded a stored procedure that took those parameters in the order specified in hibernate's debug as input and rearranged the insert statement to please Oracle.

Unfortunately, the decision to use Oracle is out of the hands of my development team. However, the decision to use Hibernate is. We're going to be refactoring our code to use JPA and will switch to TopLink if this isn't fixed soon.

The order of the parameters changes from connection pool to connection pool making this ugly hack extra-brittle. It works in our production application, but fails in our unit tests. The only way to get this strategy fully working is to write a stored procedure for each connection method used (Spring in Junit, Tomcat pools, etc) and switch them somehow.

I see multiple problems in this scenario:
    Why does oracle have this STUPID restriction if the first place?
    I don't think it's unreasonable to expect Hibernate to work with CLOBs on international databases on modern versions of Oracle, even if this means following stupid rules dictated by Oracle.
    I especially hate the SQLInsert annotation that doesn't let me specify the order of the fields. I can accept having to override hibernate's auto-magical behavior due to STUPID oracle rules. I don't appreciate such an unreasonable restriction on behalf of hibernate for something that I would see as a common use case.


I'd love to know if you (or anyone else) finds a better solution.

Thanks,
Steven


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.