Hibernate custom type to avoid 'Caused by: java.sql.SQLException: Stream has already been closed'

前端 未结 4 1292
小蘑菇
小蘑菇 2021-02-14 02:40

How do I write a custom Long class to handle long values in Oracle, to avoid the following error?

Caused by: java.sql.SQLException: Stream has already bee

4条回答
  •  南方客
    南方客 (楼主)
    2021-02-14 02:54

    Oracle recommends not using Long and Long Raw columns (since Oracle 8i). They are included in Oracle only for legacy reasons. If you really need to use them, the you should first handle these columns before attempting to touch any other columns in the ResultSet:

    Docs:

    When a query selects one or more LONG or LONG RAW columns, the JDBC driver transfers these columns to the client in streaming mode. After a call to executeQuery or next, the data of the LONG column is waiting to be read.

    Do not create tables with LONG columns. Use large object (LOB) columns, CLOB, NCLOB, and BLOB, instead. LONG columns are supported only for backward compatibility. Oracle recommends that you convert existing LONG columns to LOB columns. LOB columns are subject to far fewer restrictions than LONG columns.

    As for hibernate - see this question.

提交回复
热议问题