NHibernate: Error dehydrating property value

Topics: Core, Troubleshooting, Writing modules
Sep 6, 2013 at 8:06 AM
Hi,

I am trying to save into my custom table a large text into a field called Content (nvarchar(max)) and I am getting the below exception. Sometimes its working and sometimes is not. Also migration class can be found at the end.

Exception
2013-09-06 09:02:15,387 [91] Orchard.ContentManagement.DefaultContentManager - PropertyValueException thrown from IContentHandler by Orchard.Indexing.Handlers.CreateIndexingTaskHandler
NHibernate.PropertyValueException: Error dehydrating property value for Contrib.RssFeeder.Models.ArticlePartRecord.Content ---> NHibernate.HibernateException: The length of the string value exceeds the length configured in the mapping/parameter.
   at NHibernate.Type.AbstractStringType.Set(IDbCommand cmd, Object value, Int32 index)
   at NHibernate.Type.NullableType.NullSafeSet(IDbCommand cmd, Object value, Int32 index)
   at NHibernate.Persister.Entity.AbstractEntityPersister.Dehydrate(Object id, Object[] fields, Object rowId, Boolean[] includeProperty, Boolean[][] includeColumns, Int32 table, IDbCommand statement, ISessionImplementor session, Int32 index)
   --- End of inner exception stack trace ---
   at NHibernate.Persister.Entity.AbstractEntityPersister.Dehydrate(Object id, Object[] fields, Object rowId, Boolean[] includeProperty, Boolean[][] includeColumns, Int32 table, IDbCommand statement, ISessionImplementor session, Int32 index)
   at NHibernate.Persister.Entity.AbstractEntityPersister.Insert(Object id, Object[] fields, Boolean[] notNull, Int32 j, SqlCommandInfo sql, Object obj, ISessionImplementor session)
   at NHibernate.Persister.Entity.AbstractEntityPersister.Insert(Object id, Object[] fields, Object obj, ISessionImplementor session)
   at NHibernate.Action.EntityInsertAction.Execute()
   at NHibernate.Engine.ActionQueue.Execute(IExecutable executable)
   at NHibernate.Engine.ActionQueue.ExecuteActions(IList list)
   at NHibernate.Event.Default.AbstractSaveEventListener.PerformSaveOrReplicate(Object entity, EntityKey key, IEntityPersister persister, Boolean useIdentityColumn, Object anything, IEventSource source, Boolean requiresImmediateIdAccess)
   at NHibernate.Event.Default.AbstractSaveEventListener.SaveWithGeneratedId(Object entity, String entityName, Object anything, IEventSource source, Boolean requiresImmediateIdAccess)
   at NHibernate.Event.Default.DefaultSaveOrUpdateEventListener.SaveWithGeneratedOrRequestedId(SaveOrUpdateEvent event)
   at NHibernate.Event.Default.DefaultSaveOrUpdateEventListener.EntityIsTransient(SaveOrUpdateEvent event)
   at NHibernate.Event.Default.DefaultSaveOrUpdateEventListener.OnSaveOrUpdate(SaveOrUpdateEvent event)
   at NHibernate.Impl.SessionImpl.FireSave(SaveOrUpdateEvent event)
   at NHibernate.Impl.SessionImpl.Save(Object obj)
   at Orchard.Data.Repository`1.Create(T entity) in C:\inetpub\wwwroot\Website\src\Orchard\Data\Repository.cs:line 96
   at Orchard.Data.Repository`1.Orchard.Data.IRepository<T>.Create(T entity) in C:\inetpub\wwwroot\Website\src\Orchard\Data\Repository.cs:line 36
   at Orchard.Indexing.Services.IndexingTaskManager.CreateTask(ContentItem contentItem, Int32 action)
   at Orchard.Indexing.Services.IndexingTaskManager.CreateUpdateIndexTask(ContentItem contentItem)
   at Orchard.Indexing.Handlers.CreateIndexingTaskHandler.CreateIndexingTask(PublishContentContext context, ContentPart part)
   at Orchard.ContentManagement.Handlers.ContentHandler.InlineStorageFilter`1.Published(PublishContentContext context, TPart instance) in C:\inetpub\wwwroot\Website\src\Orchard\ContentManagement\Handlers\ContentHandler.cs:line 156
   at Orchard.ContentManagement.Handlers.StorageFilterBase`1.Orchard.ContentManagement.Handlers.IContentStorageFilter.Published(PublishContentContext context) in C:\inetpub\wwwroot\Website\src\Orchard\ContentManagement\Handlers\StorageFilterBase.cs:line 81
   at Orchard.ContentManagement.Handlers.ContentHandler.Orchard.ContentManagement.Handlers.IContentHandler.Published(PublishContentContext context) in C:\inetpub\wwwroot\Website\src\Orchard\ContentManagement\Handlers\ContentHandler.cs:line 274
   at Orchard.ContentManagement.DefaultContentManager.<>c__DisplayClass5c.<Create>b__59(IContentHandler handler) in C:\inetpub\wwwroot\Website\src\Orchard\ContentManagement\DefaultContentManager.cs:line 501
   at Orchard.InvokeExtensions.Invoke[TEvents](IEnumerable`1 events, Action`1 dispatch, ILogger logger) in C:\inetpub\wwwroot\Website\src\Orchard\InvokeExtensions.cs:line 17
2013-09-06 09:02:15,591 [91] Contrib.RssFeeder.Controllers.NewsController - RssService synchronization status. Total: (30), Synchronized: (13), Not Synchronized: (17), Failed: (0)
2013-09-06 09:02:15,594 [91] Contrib.RssFeeder.Controllers.NewsController - End of RssService synchronization process
2013-09-06 09:02:15,610 [91] NHibernate.AssertionFailure - An AssertionFailure occurred - this may indicate a bug in NHibernate or in your custom types.
NHibernate.AssertionFailure: null id in Orchard.Indexing.Models.IndexingTaskRecord entry (don't flush the Session after an exception occurs)
2013-09-06 09:02:15,619 [91] NHibernate.Transaction.ITransactionFactory - DTC transaction prepre phase failed
NHibernate.AssertionFailure: null id in Orchard.Indexing.Models.IndexingTaskRecord entry (don't flush the Session after an exception occurs)
   at NHibernate.Event.Default.DefaultFlushEntityEventListener.CheckId(Object obj, IEntityPersister persister, Object id, EntityMode entityMode)
   at NHibernate.Event.Default.DefaultFlushEntityEventListener.GetValues(Object entity, EntityEntry entry, EntityMode entityMode, Boolean mightBeDirty, ISessionImplementor session)
   at NHibernate.Event.Default.DefaultFlushEntityEventListener.OnFlushEntity(FlushEntityEvent event)
   at NHibernate.Event.Default.AbstractFlushingEventListener.FlushEntities(FlushEvent event)
   at NHibernate.Event.Default.AbstractFlushingEventListener.FlushEverythingToExecutions(FlushEvent event)
   at NHibernate.Event.Default.DefaultFlushEventListener.OnFlush(FlushEvent event)
   at NHibernate.Impl.SessionImpl.Flush()
   at NHibernate.Transaction.AdoNetWithDistributedTransactionFactory.DistributedTransactionContext.System.Transactions.IEnlistmentNotification.Prepare(PreparingEnlistment preparingEnlistment)
Migrations.cs
SchemaBuilder.CreateTable("ArticlePartRecord", builder => builder
                .ContentPartRecord()
                .Column<string>("ArticleId")           
                .Column("PubDate", DbType.DateTime)                
                .Column<string>("Provider")        
                .Column<string>("Headline")
                .Column<string>("Title")                
                .Column("Content", DbType.String, c => c.Unlimited())
                .Column("Summary", DbType.String, c => c.Unlimited())
            );
Sep 6, 2013 at 8:16 AM
I follow the solution in https://orchard.codeplex.com/discussions/402222 but I did not disable/enable my module as a result it did not take any effect. But when I disable/enable then it worked. I would like to understand why do I need to do disable/enable in order for my changes to take effect? Is that has to do anything with the app pool?