basquang™ on clouds

December 23, 2009

“ORA-01461: can bind a LONG value only for insert into a LONG column” error in NHibernate

Filed under: NHibernate — basquang @ 8:08 AM

“ORA-01461: can bind a LONG value only for insert into a LONG column” happen when try to insert large text (> 4000 Unicode characters) using NHibernate and Oracle.

Following are steps work around to fix the problem:

1. Using Clob or NClob data type

Normally we use VARCHAR2 or NVARCHAR2 for text. But the max length of these data type is 4000. So If we want to store large text which greater than 4000 characters, we must change the data type to CLOB or NCLOB (for Unicode)

2. Using correct connection.driver_class: NHibernate.Driver.OracleDataClientDriver

We were using the NHibernate.Driver.OracleClientDriver which default to Microsoft’s Oracle provider (System.Data.OracleClient). We must change the driver_class property to NHibernate.Driver.OracleDataClientDriver

//c.SetProperty(NHibernate.Cfg.Environment.ConnectionDriver, "NHibernate.Driver.OracleClientDriver");
c.SetProperty(NHibernate.Cfg.Environment.ConnectionDriver, "NHibernate.Driver.OracleDataClientDriver");             
Or in config file
<property name="connection.driver_class">
3. Using correct Mapping attributes: type=”AnsiString”

Normally we can use type=”String” default for CLOB/NCLOB. Try to use type=”AnsiString” if two steps above not work.

<property name="SoNhaDuongPho" column="SO_NHA_DUONG_PHO" type="AnsiString"/>

With three steps above, I solved the problem. Hope this help!

Here are some helpful links



  1. Thanks a lot!

    It really helped me.

    Comment by Marcin Rybacki — May 20, 2011 @ 4:16 PM | Reply

  2. Thanks.. It helped me. I’ve been trying to fix this for last 2 days.

    Comment by Prathyusha — September 26, 2013 @ 12:03 AM | Reply

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

Blog at

%d bloggers like this: