# HS6 Mass indexing issue with oracle DB

**URL:** https://discourse.hibernate.org/t/hs6-mass-indexing-issue-with-oracle-db/4664
**Category:** Hibernate ORM
**Created:** [October 14, 2020, 5:52am UTC](https://discourse.hibernate.org/t/hs6-mass-indexing-issue-with-oracle-db/4664 "2020-10-14T05:52:57Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Swarnkar](https://avatars.discourse-cdn.com/v4/letter/s/f4b2a3/32.png) [@Swarnkar](https://discourse.hibernate.org/u/Swarnkar)
#### Post date: [October 14, 2020, 5:52am UTC](https://discourse.hibernate.org/t/hs6-mass-indexing-issue-with-oracle-db/4664/1 "2020-10-14T05:52:57Z")

</div>

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

 ![image](https://canada1.discourse-cdn.com/flex035/uploads/hibernate/original/2X/a/a6956e95a516e1faaac0641930a141c4a89cb394.png)

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  
ADD (NOTES\_NEW LONG);  
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)

---

<div class="post-metadata">

### Author: ![yrodiere](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.hibernate.org/yrodiere/32/1760_2.png) [@yrodiere](https://discourse.hibernate.org/u/yrodiere)
#### Post date: [October 14, 2020, 6:55am UTC](https://discourse.hibernate.org/t/hs6-mass-indexing-issue-with-oracle-db/4664/2 "2020-10-14T06:55:03Z")

</div>

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/](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](https://docs.oracle.com/cd/B28359_01/server.111/b28318/datatype.htm#CNCPT1831), 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:

```auto
@Entity
public class Payment {    
    // ...

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

```

See [here](https://docs.jboss.org/hibernate/orm/5.4/userguide/html_single/Hibernate_User_Guide.html#basic-lob) for more ways of mapping LOBs using Hibernate ORM.

---

<div class="post-metadata">

### Author: ![Swarnkar](https://avatars.discourse-cdn.com/v4/letter/s/f4b2a3/32.png) [@Swarnkar](https://discourse.hibernate.org/u/Swarnkar)
#### Post date: [October 14, 2020, 7:11am UTC](https://discourse.hibernate.org/t/hs6-mass-indexing-issue-with-oracle-db/4664/3 "2020-10-14T07:11:05Z")

</div>

> [@yrodiere](#):
>
> But anyway, [Oracle itself discourages the use of the `LONG` type](https://docs.oracle.com/cd/B28359_01/server.111/b28318/datatype.htm#CNCPT1831), so I’d recommend you switch to some other type

got ur point as i have also got same hints from [long raw oracle](https://stackoverflow.com/questions/6573023/hibernate-mapping-for-oracle-long-raw) and [stackoverflow](https://stackoverflow.com/questions/10174951/hibernate-custom-type-to-avoid-caused-by-java-sql-sqlexception-stream-has-al) 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

---

<div class="post-metadata">

### Author: ![yrodiere](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.hibernate.org/yrodiere/32/1760_2.png) [@yrodiere](https://discourse.hibernate.org/u/yrodiere)
#### Post date: [October 14, 2020, 7:25am UTC](https://discourse.hibernate.org/t/hs6-mass-indexing-issue-with-oracle-db/4664/4 "2020-10-14T07:25:12Z")

</div>

> [@Swarnkar](#):
>
> however I don’t understand when we provide @Column(length = 10000) why hibernate create LONG data type.

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](https://docs.oracle.com/cd/B28359_01/server.111/b28318/datatype.htm#CNCPT1822).

> [@Swarnkar](#):
>
> this entity model is being used somewhere else with no issues but when I used it with HS then only I got this issue

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.
