# ORA-01461: can bind a LONG value only for insert into a LONG column

**URL:** <https://discourse.hibernate.org/t/ora-01461-can-bind-a-long-value-only-for-insert-into-a-long-column/12407>\
**Category:** Hibernate ORM\
**Created:** [September 1, 2026, 4:15am UTC](https://discourse.hibernate.org/t/ora-01461-can-bind-a-long-value-only-for-insert-into-a-long-column/12407 "2026-09-01T04:15:22Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![zpneun](https://avatars.discourse-cdn.com/v4/letter/z/b2d939/32.png) [@zpneun](https://discourse.hibernate.org/u/zpneun)\
**Post date:** [September 1, 2026, 4:15am UTC](https://discourse.hibernate.org/t/ora-01461-can-bind-a-long-value-only-for-insert-into-a-long-column/12407/1 "2026-09-01T04:15:22Z")

</div>

Hi all,

I’ve got problems putting long Strings (\>32768 chars) into a CLOB field in an Oracle DB. I’ve investigated a little bit and found out that this comes from JDBC and the way how Hibernate uses it.

If your SQL is “INSERT INTO … VALUES (?)”, there is no problem using `setString` on the PreparedStatement, even if the String is very long.

But if your SQL is “INSERT INTO … SELECT ? FROM DUAL” AND your String is long AND you use `setString`, you will earn a ORA-01461. This also holds true if you try a cast like in “INSERT INTO … SELECT to\_clob(?) FROM DUAL”.

Regarding JDBC, you can fix it if you use `setCharacterStream` on the PreparedStatement instead of `setString`.

But how is this related to Hibernate?

Well, if you use the `upsert` method of a StatelessSession, Hibernate will compose a MERGE statement using exactly this SELECT ? FROM DUAL idiom.

Therefore currently it is simply impossible to use `upsert` with an Entity which has a field which maps to a Oracle CLOB column having Strings longer than 32768.

Currently I worked around this by creating a JdbcType and annotating it in the affected Entity, but of course it would be nice if Hibernate would support this out of the box.

Would it be worth the effort creating a bug report for this? Or is it a feature request? The only change would be to use `setCharacterStream` instead of `setString` in the situation of long Strings with CLOBs.

Marcus.

---

<div class="post-metadata">

**Author:** ![beikov](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.hibernate.org/beikov/32/258_2.png) [@beikov](https://discourse.hibernate.org/u/beikov)\
**Post date:** [September 2, 2026, 9:09am UTC](https://discourse.hibernate.org/t/ora-01461-can-bind-a-long-value-only-for-insert-into-a-long-column/12407/2 "2026-09-02T09:09:09Z")

</div>

Yes, this looks like a bug and we’ve been trying to reproduce this in the past without success.  
Please try to create a reproducer with our [test case template](https://github.com/hibernate/hibernate-test-case-templates/blob/master/orm/hibernate-orm-7/src/test/java/org/hibernate/bugs/JPAUnitTestCase.java) and if you are able to reproduce the issue, create a bug ticket in our [issue tracker](https://hibernate.atlassian.net) and attach that reproducer.

---

<div class="post-metadata">

**Author:** ![zpneun](https://avatars.discourse-cdn.com/v4/letter/z/b2d939/32.png) [@zpneun](https://discourse.hibernate.org/u/zpneun)\
**Post date:** [September 3, 2026, 5:14am UTC](https://discourse.hibernate.org/t/ora-01461-can-bind-a-long-value-only-for-insert-into-a-long-column/12407/3 "2026-09-03T05:14:12Z")

</div>

I had been able to create a reproducer, and I’ll fit it to the template.

Since the issue is Oracle specific, I used docker to setup an Oracle Instance for my local test. Do you have any guidelines to create a vendor specific test?

---

<div class="post-metadata">

**Author:** ![zpneun](https://avatars.discourse-cdn.com/v4/letter/z/b2d939/32.png) [@zpneun](https://discourse.hibernate.org/u/zpneun)\
**Post date:** [September 3, 2026, 8:43am UTC](https://discourse.hibernate.org/t/ora-01461-can-bind-a-long-value-only-for-insert-into-a-long-column/12407/4 "2026-09-03T08:43:34Z")

</div>

Done: [Jira](https://hibernate.atlassian.net/browse/HHH-20835)
