Hibernate自定义类型以避免'由于:java.sql.SQLException:流已经被关闭' [英] Hibernate custom type to avoid 'Caused by: java.sql.SQLException: Stream has already been closed'

查看:268
本文介绍了Hibernate自定义类型以避免'由于:java.sql.SQLException:流已经被关闭'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何编写自定义的Long类来处理Oracle中的长整型值,以避免出现以下错误?

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


.sql.SQLException:Stream已被关闭。

Caused by: java.sql.SQLException: Stream has already been closed.

谢谢

Thanks

推荐答案

Oracle 建议不使用 Long Long Raw 列(自Oracle 8i以来)。仅出于传统原因,它们仅包含在Oracle中。如果您确实需要使用它们,则应该在尝试触摸 ResultSet 中的任何其他列之前先处理这些列:

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:

文档: p>

Docs:


当查询选择一个或多个LONG或LONG RAW列时,JDBC驱动程序将这些列以流模式传输到客户端。在调用executeQuery或next之后,LONG列的数据正在等待读取。

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.

不要使用LONG列创建表。改为使用大对象(LOB)列,CLOB,NCLOB和BLOB。 LONG列仅支持向后兼容。 Oracle建议您将现有的LONG列转换为LOB列。

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.

至于hibernate - 请参阅问题

As for hibernate - see this question.

这篇关于Hibernate自定义类型以避免'由于:java.sql.SQLException:流已经被关闭'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆