HSQL & Hibernate: unsupported internal operation: Session

橙三吉。 提交于 2019-12-11 08:58:11

问题


I have a project with the following dependencies:

hibernate-entitymanager-4.1.8
hsql-2.2.8

I have a Persistence Unit including:

<properties>
    <property name="javax.persistence.jdbc.driver" value="org.hsqldb.jdbcDriver"/>
    <property name="hibernate.cache.provider_class" value="org.hibernate.cache.NoCacheProvider"/>
    <property name="hibernate.hbm2ddl.auto" value="create-drop"/>
    <property name="hibernate.dialect" value="org.hibernate.dialect.HSQLDialect"/>
</properties>

And an Entity with a field thus:

@Lob
@Column(name = "DOCUMENT")
private String document;

When I come to persist through the EntityManager my entity I'm seeing the following end of stack trace:

Caused by: java.lang.RuntimeException: unsupported internal operation: Session
at org.hsqldb.error.Error.runtimeError(Unknown Source)
at org.hsqldb.Session.performLOBOperation(Unknown Source)
at org.hsqldb.Session.execute(Unknown Source)
at org.hsqldb.types.ClobDataID.nonSpaceLength(Unknown Source)
at org.hsqldb.types.CharacterType.castOrConvertToType(Unknown Source)
at org.hsqldb.types.CharacterType.convertToType(Unknown Source)
at org.hsqldb.StatementDML.getInsertData(Unknown Source)
at org.hsqldb.StatementInsert.getResult(Unknown Source)

Am do doing something obviously wrong here? This was working albeit with quite a few changes and on a different machine. Possibly a result of a dependency upgrade or a switch to JPA/Hiberate from a straight Spring/Hibernate abstraction layer.

Several others reporting much the same thing found via Google but no particular solution :(


回答1:


A fix in Hibernate 4.1.8 created a regression. For HSQLDB, Schema export will create a blog/clob limited to 255 char.

When using HSQLDB, inserting any CLOB value larger than 16Mb always fails with an exception

Pull request




回答2:


This issue has been fixed in the latest version of HSQLDB. Version 2.3.0 is available from hsqldb.org.




回答3:


I even tried with newer version HSQLDB 2.4.1 and Hibernate-core 5.3.6, the problem still persists. Because Hibernate generates schema with only 255 char column length, in my case, try to alter column type works (clob instead of clob(255))

alter table public.user alter column myClobColumn clob



来源:https://stackoverflow.com/questions/14583147/hsql-hibernate-unsupported-internal-operation-session

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!