无法将 clob 数据类型从数据库获取到 JPA 实体中
我能够将 (spring-hibernate saveorupdate()
) 字段保存
@Lob
@Column(name = "FILENAME")
private String filename;
到 oracle 数据库中,数据类型是 clob
,但是当我尝试检索它时,出现错误
错误 - JDBCExceptionReporter.logExceptions(72) | ORA-00932: 数据类型不一致: 预期 - 得到 CLOB
下面是我从数据库检索的方式
DetachedCriteria crit = DetachedCriteria.forClass(Storagefile.class);
crit.addOrder(bSortOrder ? Order.asc(sortColumnId) : Order.desc(sortColumnId));
List<Storagefile> result = (List<Storagefile>) getHibernateTemplate().findByCriteria(crit, nFirst, nPageSize);
I able to save (spring-hibernate saveorupdate()
) field
@Lob
@Column(name = "FILENAME")
private String filename;
into oracle database datatype is clob
but when i try retrieve it, i get error
ERROR -
JDBCExceptionReporter.logExceptions(72)
| ORA-00932: inconsistent datatypes:
expected - got CLOB
below is how i retrive from database
DetachedCriteria crit = DetachedCriteria.forClass(Storagefile.class);
crit.addOrder(bSortOrder ? Order.asc(sortColumnId) : Order.desc(sortColumnId));
List<Storagefile> result = (List<Storagefile>) getHibernateTemplate().findByCriteria(crit, nFirst, nPageSize);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
从您的示例代码中尚不清楚,但我的猜测是您正在尝试按 CLOB 列排序,而 Oracle 不允许这样做。该错误代码是 Oracle 告诉您这一点的迷人方式。
您确定需要使用 CLOB 来存储文件名吗? Oracle 可以在
VARCHAR2
列中存储最多 4000 个字符,这对于文件名来说肯定足够了吗?如果您想按文件名
排序,那么您就需要这样做。It's not clear from your sample code, but my guess is that you're trying to sort by the CLOB column, and Oracle does not permit that. That error code is Oracle's charming way of telling you this.
Are you sure you need to use a CLOB to store a filnename? Oracle can store up to 4000 characters in a
VARCHAR2
column, surely that's enough for a filename? If you want to sort by thefilename
, then that's what you'll need to do.您是否已经浏览过此内容:
https://www.hibernate.org/56.html
似乎是 Oracle 9i 驱动程序和 LOB 的问题(不确定您的设置是什么)。
Have you waded through this:
https://www.hibernate.org/56.html
There seems to be an issue with the Oracle 9i driver and LOBs (not sure what your setup is).