Print Page | Close Window

Error : Null Entity cannot be modified

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce Classic
Forum Discription: For .NET 2.0
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=673
Printed Date: 11-Jun-2026 at 9:18am


Topic: Error : Null Entity cannot be modified
Posted By: JulianBenjamin
Subject: Error : Null Entity cannot be modified
Date Posted: 05-Feb-2008 at 6:35am
I'm getting the following error when setting a value of a related entity.
 
I have a ItemData entity, and it's related ProductDescription record (joined via ItemNumber in the Entity Relations tab).
 
When I retrieve the ItemData record, I can use ItemData.ProductDescription.ItemText and get the value, as the record exists in the ProductDescription table.  However, when saving the data, I'm assigning a value to the ItemText field in the ItemData.ProductDescription object using ItemData.ProductDescription.ItemText = x and I get a Null Entity Cannot be modified error.
 
Any ideas?  I've pasted the exception below.
 
IdeaBlade.Util.IdeaBladeException was unhandled by user code
  Message="Null entity cannot be modified"
  Source="IdeaBlade.Persistence"
  StackTrace:
       at IdeaBlade.Persistence.EntityTable.OnColumnChanging(DataColumnChangeEventArgs pArgs)
       at System.Data.DataRow.set_Item(DataColumn column, Object value)
       at IdeaBlade.Persistence.Entity.SetColumnValue(DataColumn pSetColumn, Object pValue)
       at ComNET.Data.ProductDescriptionDataRow.SetItemTextImpl(String value) in D:\code\CatalogManager\CatalogManager.Data\ComNET.Data\ProductDescriptionDataRow.cs:line 488
       at ComNET.Data.ProductDescriptionDataRow.set_ItemText(String value) in D:\code\CatalogManager\CatalogManager.Data\ComNET.Data\ProductDescriptionDataRow.cs:line 480
       at CatalogManager.ItemDetail.btnSave_Click(Object sender, EventArgs e) in D:\code\CatalogManager\CatalogManager\ItemDetail.aspx.cs:line 211
       at DevExpress.Web.ASPxEditors.ASPxButton.OnClick(EventArgs e)
       at DevExpress.Web.ASPxEditors.ASPxButton.RaisePostBackEvent(String eventArgument)
       at DevExpress.Web.ASPxClasses.ASPxWebControl.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)
       at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
       at System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
       at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
  InnerException:



Replies:
Posted By: davidklitzke
Date Posted: 05-Feb-2008 at 9:43am
You need to use UpdateNullEntity().
 
The DevForce Developer's Guide says this:

The null entity cannot be changed, deleted, or saved. But the savvy developer can redefine a null entity‟s default property responses by overriding the UpdateNullEntity() method in the entity‟s Developer class. She could change the Address.City property, for example, so that it returns the string "<unknown>".

See this tutorial if you want an example:



Posted By: JulianBenjamin
Date Posted: 05-Feb-2008 at 11:46am
But it's not a NullEntity, because that record actually exists in the database.


Posted By: JulianBenjamin
Date Posted: 05-Feb-2008 at 4:32pm
Figured out what the problem was.  I was using two different PersistenceManagers, one to retrieve the data, and the other to save the data.



Print Page | Close Window