org.hibernate.type.TextType和Oracle [英] org.hibernate.type.TextType and Oracle

查看:236
本文介绍了org.hibernate.type.TextType和Oracle的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们将Hibernate用作JPA提供程序,并且我们有一个带有标有大对象字段的类

We use Hibernate as a JPA provider and we have a class with a large object field marked with

@Lob
@Type( type = "org.hibernate.type.TextType" )
private String someString;

该列的创建方式为

SOMESTRING            LONG()             

这与PostgreSQL和MySQL完美配合.在保留对象时使用Oracle

This works flawlessly with PostgreSQL and MySQL. With Oracle when persisting the object

entityManager.persist( object );

我们得到一个org.hibernate.exception.GenericJDBCException: Could not execute JDBC batch update异常.

删除@Type( type = "org.hibernate.type.TextType" )注释将解决Oracle问题,但引入PostgreSQL的编码问题,如

Removing the @Type( type = "org.hibernate.type.TextType" ) annotation will solve the problem with Oracle but introduces an encoding problem with PostgreSQL as described in Cannot store Euro-sign into LOB String property with Hibernate/PostgreSQL

我想知道如何定义一个大文本字段,以便out程序在PostgreSQL和Oracle上都可以运行.纯粹的JPA解决方案将是最佳选择,但特定于Hibernate的解决方案也可以.

I would like to know how to define a large text field so that out program works on both PostgreSQL and Oracle. A pure JPA solution would be optimal but an Hibernate specific one will also do.

真正的例外:

java.sql.BatchUpdateException: ORA-22295: cannot bind more than 4000 bytes data to LOB and LONG columns in 1 statement

现在,我遗漏的异常解释了这个问题,实际上我要保留的对象比大字符串(至少一个长DBID)要多.

Now, the exception I missed explains the problem and in fact the object I am persisting has more than then the large string (at least one long DBID).

推荐答案

我有一个

I had a similar problem and the only way was to extend/customize the Oracle dialect.

这篇关于org.hibernate.type.TextType和Oracle的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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