Question

I'm getting following exception, while updating table in Hibernate

ORA-24816: Expanded non LONG bind data supplied after actual LONG or LOB column

I have extracted sql query as well, it looks like

Update table_name set columnName (LOB)=value, colmun2 (String with 4000)=value where id=?;

Entity class

class Test{

    @Lob
    private String errorText;

    @Column(length = 4000)
    private String text;
}

Please help me, what is wrong in this

Thanks Ravi Kumar

Was it helpful?

Solution 3

I found issue. 1. When hibernate updating data in DB and entity has 4000 chars column and lob type column then hibernate throwing this exception

I have solved this issue by writing two update queires 1. First i have saved entity by using Update() 2. Written another update query for lob column update

Thanks ravi

OTHER TIPS

Running oerr ora 24816 to get the details on the error yields:

$ oerr ora 24816
24816, ... "Expanded non LONG bind data supplied after actual LONG or LOB column"
// *Cause:  A Bind value of length potentially > 4000 bytes follows binding for
//          LOB or LONG.
// *Action: Re-order the binds so that the LONG bind or LOB binds are all
//          at the end of the bind list.

So another solution that uses only 1 query would be to move your LOB/LONG binds after all your non-LOB/LONG binds. This may or may not be possible with Hibernate. Perhaps something more like:

update T set column2 (String with 4000)=:1, columnName (LOB)=:3 where id=:2;

This DML limitation appears to have been around since at least Oracle 8i.

References:

I do realise that this thread is quite old, but I thought I'd share my own experience with the same error message here for future reference.

I have had the exact same symptoms (i.e. ORA-24816) for a couple of days. I was a bit side-tracked by various threads I came across suggesting that this was related to order of parameter binding. In my case this was not a problem. Also, I struggled to reproduce this error, it only occurred after deploying to an application server, I could not reproduce this through integration tests.

However, I took a look at the code where I was binding the parameter and found:

preparedStatement.setString(index, someStringValue);

I replaced this with:

preparedStatement.setClob(index, new StringReader(someStringValue));

This did the trick for me.

This thread from back in 2009 was quite useful.

I have also encountered same error in oracle db and foudn that Hibernate Guys fixed here

In my case we were already using hiberante 4.3.7 but didnt mention that field is Lob in Entity

Reproducing Steps

  1. Have fields with varchar2 datatype and clob data type.Make sure your column name are in this alphabetic order clob_field,varchar_two_field1,varchar_two_field2.
  2. Now update clob_field with < 2000 bytes and varchar_two_field1 with 4000 bytes size.
  3. This should end up with error ORA-24816: Expanded non LONG bind data supplied after actual LONG or LOB column

Solution

  1. Make sure you have hiberante 4.1.8, < 4.3.0.Beta1
  2. Annotate your clob/blob field in respective Entity as

    import javax.persistence.Lob;  
    ...
        @Lob
        @Column(name = "description")
        private String description;  
    ....
    

If you want to see the difference , by after making above changes enable debug for sql statements by setting "true" for "hibernate.show_sql" in persistence.xml.

I came across this issue today while trying to Insert the data into a table. To avoid this error, Just keep all the fields having "LOB" data type at the end of the insert statement.

For Example

Table1 has 8 Fields (Field1,Field2,.... Field8 etc..),

of which

Field1 and Field2 are of CLOB data types

and the rest are Varchar2 Data types

. Then while inserting the data make sure you keep Field1 and Field2 values at the end like below.

 INSERT INTO TABLE1 ( Field3,Field4,Field5,Field6,Field7,Field8,Field1,Field2)  
    Values ('a','b','c','d','e','f','htgybyvvbshbhabjh','cbsdbvsb')

Place your LOB binding at the last. See if that solves the issue..

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top