Oracle LOB ordering not working with SequenceIdentityGenerator

Description

In the last few days i tried to upgrade an application with an pretty old hibernate3 version to the current hibernate4. It has quite a few entites with LOBs and updates/inserts don't work on such entites anymore. The problem of seems still to happen in our environment.

We use a SequenceIdentityGenerator for the ID columns and this seems to be the problem. I made a simpe test project to reproduce it.

The log looks like this for an insert (longText is the CLOB):

1 2 3 4 5 6 7 8 9 10 Hibernate: create table lob_test (id number(19,0) not null, displayName varchar2(120 char), internName varchar2(120 char), longText clob, repository_id number(19,0), version number(19,0), primary key (id)) ... Hibernate: insert into lob_test (id, displayName, internName, longText, repository_id, version) values (hibernate_sequence.nextval, ?, ?, ?, ?, ?) 02:45:13,279 TRACE BasicBinder:83 - binding parameter [1] as [VARCHAR] - display name 02:45:13,279 TRACE BasicBinder:83 - binding parameter [2] as [VARCHAR] - intern name 02:45:13,280 TRACE BasicBinder:83 - binding parameter [3] as [BIGINT] - 42 02:45:13,280 TRACE BasicBinder:71 - binding parameter [4] as [BIGINT] - <null> 02:45:13,281 TRACE BasicBinder:83 - binding parameter [5] as [CLOB] - long text 02:45:13,350 WARN SqlExceptionHelper:143 - SQL Error: 1722, SQLState: 42000 02:45:13,350 ERROR SqlExceptionHelper:144 - ORA-01722: Ungültige Zahl

The problem should be this id-column

1 2 3 @Id @GeneratedValue(strategy = GenerationType.AUTO) private Long id;

... and our own dialect based on Oracle10gDialect with this addition:

1 2 3 4 @Override public Class<?> getNativeIdentifierGeneratorClass() { return SequenceIdentityGenerator.class; }

Also thanks to Danilo Ghirardelli for his test project, which this is based on.

Environment

Testet with Hibernate 4.1.9 and 4.2.0.CR2
Oracle 11g with ojdbc6.jar

Status

Assignee

Lukasz Antoniak

Reporter

Torsten Schöne

Fix versions

Labels

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Components

Affects versions

4.2.0.CR2
4.1.9

Priority

Critical