diff --git a/src/NHibernate.Test/NHSpecificTest/NH3252/Fixture.cs b/src/NHibernate.Test/NHSpecificTest/NH3252/Fixture.cs new file mode 100644 index 00000000000..a1da18e66b2 --- /dev/null +++ b/src/NHibernate.Test/NHSpecificTest/NH3252/Fixture.cs @@ -0,0 +1,56 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using NUnit.Framework; +using NHibernate.Linq; + +namespace NHibernate.Test.NHSpecificTest.NH3252 +{ + [TestFixture] + public class Fixture : TestCase + { + protected override string MappingsAssembly + { + get { return "NHibernate.Test"; } + } + + protected override IList Mappings + { + get { return new string[] { "NHSpecificTest.NH3252.Mappings.hbm.xml" }; } + } + + [Test] + public void VerifyThatWeCanSaveAndLoad() + { + using (ISession session = OpenSession()) + using (ITransaction transaction = session.BeginTransaction()) + { + + session.Save(new Note { Text = new String('0', 9000) }); + transaction.Commit(); + } + + using (ISession session = OpenSession()) + using (ITransaction transaction = session.BeginTransaction()) + { + + var note = session.Query().First(); + Assert.AreEqual(9000, note.Text.Length); + } + } + + protected override void OnTearDown() + { + using (ISession session = OpenSession()) + using (ITransaction transaction = session.BeginTransaction()) + { + session.Delete("from System.Object"); + + session.Flush(); + transaction.Commit(); + } + } + } +} diff --git a/src/NHibernate.Test/NHSpecificTest/NH3252/Mappings.hbm.xml b/src/NHibernate.Test/NHSpecificTest/NH3252/Mappings.hbm.xml new file mode 100644 index 00000000000..e92b051985b --- /dev/null +++ b/src/NHibernate.Test/NHSpecificTest/NH3252/Mappings.hbm.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/src/NHibernate.Test/NHSpecificTest/NH3252/Note.cs b/src/NHibernate.Test/NHSpecificTest/NH3252/Note.cs new file mode 100644 index 00000000000..b63298cdb9b --- /dev/null +++ b/src/NHibernate.Test/NHSpecificTest/NH3252/Note.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace NHibernate.Test.NHSpecificTest.NH3252 +{ + class Note + { + public virtual int Id { get; protected set; } + + public virtual string Text { get; set; } + } +} diff --git a/src/NHibernate.Test/NHibernate.Test.csproj b/src/NHibernate.Test/NHibernate.Test.csproj index 7c1a410269d..5f856115358 100644 --- a/src/NHibernate.Test/NHibernate.Test.csproj +++ b/src/NHibernate.Test/NHibernate.Test.csproj @@ -668,6 +668,8 @@ + + @@ -2882,6 +2884,7 @@ + diff --git a/src/NHibernate/Driver/SqlClientDriver.cs b/src/NHibernate/Driver/SqlClientDriver.cs index c9f1aa15341..c36db1e4f4d 100644 --- a/src/NHibernate/Driver/SqlClientDriver.cs +++ b/src/NHibernate/Driver/SqlClientDriver.cs @@ -133,8 +133,8 @@ protected static void SetDefaultParameterSize(IDbDataParameter dbParam, SqlType switch (dbParam.DbType) { case DbType.AnsiString: - case DbType.AnsiStringFixedLength: - dbParam.Size = MaxSizeForLengthLimitedAnsiString; + case DbType.AnsiStringFixedLength: + dbParam.Size = IsAnsiText(dbParam, sqlType) ? MaxSizeForAnsiClob : MaxSizeForLengthLimitedAnsiString; break; case DbType.Binary: dbParam.Size = IsBlob(dbParam, sqlType) ? MaxSizeForBlob : MaxSizeForLengthLimitedBinary; @@ -154,7 +154,18 @@ protected static void SetDefaultParameterSize(IDbDataParameter dbParam, SqlType dbParam.Size = MaxDateTimeOffset; break; } - } + } + + /// + /// Interprets if a parameter is a Clob (for the purposes of setting its default size) + /// + /// The parameter + /// The of the parameter + /// True, if the parameter should be interpreted as a Clob, otherwise False + protected static bool IsAnsiText(IDbDataParameter dbParam, SqlType sqlType) + { + return ((DbType.AnsiString == dbParam.DbType || DbType.AnsiStringFixedLength == dbParam.DbType) && sqlType.LengthDefined && (sqlType.Length > MaxSizeForLengthLimitedAnsiString)); + } /// /// Interprets if a parameter is a Clob (for the purposes of setting its default size)