Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>For future reference: <a href="http://thebasilet.blogspot.be/2009/07/nhibernate-oracle-clobs.html" rel="nofollow">this post</a> perfectly describes what causes this error and how you can solve it.</p> <blockquote> <p>ORA-01461: can bind a LONG value only for insert into a LONG column</p> <p>This error is not very helpful and goggling it will most likely result in topics regarding oracle patches and the like. In reality this is a bug with the microsoft oracle client driver. The driver mistakenly infers the column type of the string being saved, and tries forcing the server to update a LONG value into a CLOB/NCLOB column type. The reason for the incorrect behavior is even more obscure and only happens when all the following conditions are met.</p> <ol> <li>when we set the IDbDataParameter.Value = (string whose length is : 4000 > length > 2000 )</li> <li>when we set the IDbDataParameter.DbType = DbType.String</li> <li>when DB Column is of type NCLOB/CLOB</li> </ol> <p>Unfortunately NHibernate 2.0's default behavior is to do exactly the above, making it quite more likely to run into this ugly bug when using nhibernate and oracle.</p> </blockquote> <p>Solution offered in the blog post: a custom NHibernate Oracle Driver:</p> <pre><code>/// &lt;summary&gt; /// Initializes the parameter. /// &lt;/summary&gt; /// &lt;param name="dbParam"&gt;The db param. /// &lt;param name="name"&gt;The name. /// &lt;param name="sqlType"&gt;Type of the SQL. protected override void InitializeParameter(System.Data.IDbDataParameter dbParam, string name, global::NHibernate.SqlTypes.SqlType sqlType) { base.InitializeParameter(dbParam, name, sqlType); //System.Data.OracleClient.dll driver generates an exception //we set the IDbDataParameter.Value = (string whose length: 4000 &gt; length &gt; 2000 ) //when we set the IDbDataParameter.DbType = DbType.String //when DB Column is of type NCLOB/CLOB //The Above is the default behavior for NHibernate.OracleClientDriver //So we use the built-in StringClobSqlType to tell the driver to use the NClob Oracle type //This will work for both NCLOB/CLOBs without issues. //Mapping file will need to be update to use StringClob as the property type if ((sqlType is StringClobSqlType)) { ((OracleParameter)dbParam).OracleType = OracleType.NClob; } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload