New Posts New Posts RSS Feed: Error : Null Entity cannot be modified
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

Error : Null Entity cannot be modified

 Post Reply Post Reply
Author
JulianBenjamin View Drop Down
Newbie
Newbie
Avatar

Joined: 03-Aug-2007
Location: United States
Posts: 10
Post Options Post Options   Quote JulianBenjamin Quote  Post ReplyReply Direct Link To This Post Topic: Error : Null Entity cannot be modified
    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:
Back to Top
davidklitzke View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 14-Jun-2007
Posts: 715
Post Options Post Options   Quote davidklitzke Quote  Post ReplyReply Direct Link To This Post 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:



Edited by davidklitzke - 05-Feb-2008 at 9:44am
Back to Top
JulianBenjamin View Drop Down
Newbie
Newbie
Avatar

Joined: 03-Aug-2007
Location: United States
Posts: 10
Post Options Post Options   Quote JulianBenjamin Quote  Post ReplyReply Direct Link To This Post Posted: 05-Feb-2008 at 11:46am
But it's not a NullEntity, because that record actually exists in the database.
Back to Top
JulianBenjamin View Drop Down
Newbie
Newbie
Avatar

Joined: 03-Aug-2007
Location: United States
Posts: 10
Post Options Post Options   Quote JulianBenjamin Quote  Post ReplyReply Direct Link To This Post 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.
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down