My favorites | Sign in
Project Logo
             
New issue | Search
for
| Advanced search | Search tips
Issue 55: Issue with Entity Tracking, Entity Factory, and 1-to-1 relationship
5 people starred this issue and may be notified of changes. Back to list
Status:  Accepted
Owner:  michshat
Type-Defect
Priority-Medium
Platform-SQL


Sign in to add a comment
 
Reported by rhett.c, Jun 19, 2008
What steps will reproduce the problem?
1. Turn on entity tracking and entity factory
2. Find two entity types that have a one-to-one relationship.
3. Fill a T-List with an entity from the parent (primary table) side of the
relationship
4. Also get the related child that belongs to the entity 
5. Make another service call that will get the same parent record

What is the expected output? What do you see instead?
I expect the entity factory and tracker to recognize that the entity
already exists and handle the object references properly.  In other words
no matter how many service calls I make to get entity data from the
database I don't expect there to be problems.  The issue is that an
exception is thrown in the child entities copy method as it tries to add a
copy of its self to the existing copies hashtable but a copy already exists.  

What version of .netTiers and CodeSmith are you using?
.netTiers 2.3.0 Beta 1
CodeSmith 4.14


Please provide any additional information below.
I have included the stack trace below, replacing actual entity names with
parent and child consistent with the description above.  It appears that a
circular reference (using the term loosely) exists between the entities so
the parent keeps trying to copy the child and that causes the child to try
to copy the parent.  

   at System.Collections.Hashtable.Insert(Object key, Object nvalue,
Boolean add)
   at System.Collections.Hashtable.Add(Object key, Object value)
   at CCMS.Entities.ChildBase.Copy(IDictionary existingCopies)
   at CCMS.Entities.ChildBase.Clone(IDictionary existingCopies)
   at CCMS.Entities.ParentBase.MakeCopyOf(Object x, IDictionary existingCopies)
   at CCMS.Entities.ParentBase.Copy(IDictionary existingCopies)
   at CCMS.Entities.ParentBase.Clone(IDictionary existingCopies)
   at CCMS.Entities.ChildBase.MakeCopyOf(Object x, IDictionary existingCopies)
   at CCMS.Entities.ChildBase.Copy(IDictionary existingCopies)
   at CCMS.Entities.ChildBase.Clone()
   at CCMS.Entities.ParentBase.MakeCopyOf(Object x)
   at CCMS.Entities.ParentBase.ParentEntityData.Clone()
   at CCMS.Entities.ParentBase.AcceptChanges()
   at CCMS.Data.Bases.ParentProviderBaseCore.Fill(IDataReader reader,
TList`1 rows, Int32 start, Int32 pageLength)
   at
CCMS.Data.SqlClient.SqlParentProviderBase.GetByParentAssignmentId(TransactionManager
transactionManager, Int32 _partyAssignmentId, Int32 start, Int32
pageLength, Int32& count)
   at CCMS.Services.ParentServiceBase.GetByParentAssignmentId(Int32
_parentAssignmentId, Int32 start, Int32 pageLength, Int32& totalCount)
   at CCMS.Services.ParentServiceBase.GetByParentAssignmentId(Int32
_parentAssignmentId)

 
Comment 1 by rhett.c, Jun 20, 2008
To follow up:  Entity Tracking and Entity Factory settings do not appear to be 
related to this issue.  
Comment 2 by rhett.c, Jun 20, 2008
It seems the issue is occuring when trying to save a new parent and child at the 
same time.  If I load an existing parent and child then modify them I can DeepSave 
without an issue.
Comment 3 by freddyriost, Jul 02, 2008
This happened to me too, and the issue does begin on: 
CCMS.Entities.ParentBase.AcceptChanges().

To put it simple, AcceptChanges is broken when the related object is loaded on the 
entity. To do a simple save (not deep), I had to null the property, save and then 
set the property again. Also note that entity tracking does affect this, as a simple 
get can come with the related object's property filled, and from then on you can't 
do a simple get (not deep).
Comment 4 by bniemyjski, Dec 07, 2008
More information can be found at the following forum thread
(http://community.codesmithtools.com/forums/p/8276/30939.aspx#30939)

What version of .netTiers and CodeSmith are you using?
2.2

duplicate issue (http://code.google.com/p/nettiers/issues/detail?id=17)
Status: Accepted
Owner: michshat
Comment 5 by bniemyjski, May 25, 2009
(No comment was entered for this change.)
Labels: Platform-SQL
Comment 6 by stafford.williams, Jul 20, 2009
problem seems to still exist in .netTiers 2.3
Comment 7 by teppic.xxviii, Sep 17, 2009
Hi - stumbled across this issue today and my obvious thought was: Well if the entity
already exists in the IDictionary, don't bother adding it again as it's already been
processed.

I put this after the if(existingCopies == null) statement at the beginning of
Copy(IDictionary existingCopies) in EntityInstanceBase.generated.cst:

else if (existingCopies.Contains(this))
{
   return (<%=className%>)existingCopies[this];
}


Works fine for me although maybe I'm potentially creating another bug? I don't know,
but like I say it works ok for me for now, will update if I get any problems.
Sign in to add a comment

Hosted by Google Code