HS6 Mass indexing issue with oracle DB

Hibernate Search - Mass indexing HHH000327: Error performing load command : org.hibernate.exception.GenericJDBCException: Could not read entity state from ResultSet

Background: So we have a field in Hibernate entity whose type is String (DB side VARCHAR 256)
And we wanted it to support length 10k.
We have ddl auto set to update and in prod environment we have Data in tables so we only have option to update the type of that field manually.
so same thing we tested in dev environment and found hibernate create type as LONG (Oracle 12c)
so we manually update it via following sql command .

alter table PAYMENT
update SALE.PAYMENT SET NOTES_NEW = to_char(NOTES) where 1=1;
alter table PAYMENT drop column NOTES cascade constraints;
alter table PAYMENT rename column NOTES_NEW to NOTES;

now we have issue as described earlier .
please provide me what’s going wrong here why hibernate not able to be in sync of manual changes.
PS : in hibernate we already did like this
@Column(length = 10000)

Moving to the Hibernate ORM category as this is plainly an ORM issue.

I believe you’re affected by this: https://blog.jooq.org/2015/12/30/oracle-long-and-long-raw-causing-stream-has-already-been-closed-exception/

Apparently the Oracle JDBC driver has a limitation that forces you to retrieve LONG values from the ResultSet first, before all other columns.

Due to how Hibernate ORM is designed, I don’t think it’s likely that Hibernate ORM will ever be able to apply this workaround.

But anyway, Oracle itself discourages the use of the LONG type, so I’d recommend you switch to some other type. They recommand the use of LOB objects. A quick way to implement that in your application would be to map your property like this:

public class Payment {    
    // ...

    @org.hibernate.annotations.Type( type = "materialized_clob" )
    private String notes;
    // ...

See here for more ways of mapping LOBs using Hibernate ORM.

got ur point as i have also got same hints from long raw oracle and stackoverflow for the same .
however I don’t understand when we provide @Column(length = 10000) why hibernate create LONG data type.
this entity model is being used somewhere else with no issues but when I used it with HS then only I got this issue

I suppose that’s the only non-clob type that allows that many characters in Oracle, so Hibernate ORM picks that one because it has no choice.

EDIT: Yes, VARCHAR is limited to 4000 bytes in Oracle.

It’s possible that, for this other query, the LONG column appears first in the resultset, so it works correctly, but only by chance. You can enable SQL logging if you want to check.

Really, Hibernate Search doesn’t do anything too advanced when loading entities: it just delegates to ORM. So if you have a problem when Hibernate Search loads entities, chances are this problem is in ORM (or, in this case, the JDBC driver) and you can encounter it without Hibernate Search.