我有一个奇怪的问题,我正在尝试解决超过 2 天的问题。
我有一个包含 236 列的表,使用流利的 nHibernate 进行映射。
FluentConfiguration configuration = Fluently. Configure (). Database (pConfigurer).Mappings(m =>
{
m.HbmMappings.AddFromAssemblyOf<T>();
m.FluentMappings.AddFromAssemblyOf<T>();
})
有几列是 text 或 varchar(max) 或 varchar(800) ,它们是使用长度映射的
Map(x => x.ScDirectorFeeDesc).Column("sc_director_fee_desc").Length(2147483647)
只要我从数据库中读取值,即使长度超过 1000 或更多,一切都很好。
当我尝试修改超过 1000 的字符串并尝试保存时,或者当我尝试在那里保存新值时,我遇到了一个问题,它让我感到异常......
Could not synchronize database state with session
NHibernate.Exceptions.GenericADOException: could not execute batch command.[SQL: SQL not available] ---> System.Data.SqlClient.SqlException: String or binary data would be truncated.
The statement has been terminated.
at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)
at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)
at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task& task, Boolean asyncWrite, SqlDataReader ds)
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, TaskCompletionSource`1 completion, Int32 timeout, Task& task, Boolean asyncWrite)
at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(TaskCompletionSource`1 completion, String methodName, Boolean sendToPipe, Int32 timeout, Boolean asyncWrite)
at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
at System.Data.SqlClient.SqlCommandSet.ExecuteNonQuery()
at NHibernate.AdoNet.SqlClientSqlCommandSet.ExecuteNonQuery()
at NHibernate.AdoNet.SqlClientBatchingBatcher.DoExecuteBatch(IDbCommand ps)
--- End of inner exception stack trace ---
at NHibernate.AdoNet.SqlClientBatchingBatcher.DoExecuteBatch(IDbCommand ps)
at NHibernate.AdoNet.AbstractBatcher.ExecuteBatchWithTiming(IDbCommand ps)
at NHibernate.AdoNet.AbstractBatcher.ExecuteBatch()
at NHibernate.Engine.ActionQueue.ExecuteActions(IList list)
at NHibernate.Engine.ActionQueue.ExecuteActions()
at NHibernate.Event.Default.AbstractFlushingEventListener.PerformExecutions(IEventSource session
我正在使用 Fluent 1.3.0.733 和 NHibernate 3.3.1.4000
如果有人知道这里的问题,请告诉我这将非常有帮助。
我尝试在映射中提及 StringClob 和 Text SQLTypes,我什至尝试将列类型更改为 4000,但它不仅保存它,而且引发异常。
谢谢, 苏库玛