From: Richard B. <rb...@us...> - 2005-04-11 23:27:46
|
Update of /cvsroot/jcframework/dotnet In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10939 Modified Files: CInjectedObject.vb CJoin.vb CPersistenceBroker.vb CPersistentObject.vb Log Message: Only copy one-to-many collections if the association is retrieveAutomatic. More changes related to naming Index: CPersistenceBroker.vb =================================================================== RCS file: /cvsroot/jcframework/dotnet/CPersistenceBroker.vb,v retrieving revision 1.108 retrieving revision 1.109 diff -u -d -r1.108 -r1.109 --- CPersistenceBroker.vb 11 Apr 2005 00:31:43 -0000 1.108 +++ CPersistenceBroker.vb 11 Apr 2005 23:27:06 -0000 1.109 @@ -2710,28 +2710,30 @@ End If 'Now go through and find out which objects have been removed from the collection 'and attempt to modify and/or delete them. - For Each value In obj.GetRemovedCollectionItems(udamap.FromClassTarget) - If udamap.DeleteAutomatic = True Then - 'Delete the object - qd = New QueuedDelete - qd.ObjectToDelete = value - q.Enqueue(qd) - Else - For Each e As AssociationMapEntry In udamap.Entries - 'Try to set to nothing first. If it fails set the value to NULL alias value - 'Need to do a get first so we know what type to alias - Try - value.SetAttributeValue(e.ToAttrMap.Name, Nothing) - Catch - tmpObj = value.GetValueByAttribute(e.ToAttrMap.Name) - ModAliasNull.NullToAlias(DBNull.Value, tmpObj) - value.SetAttributeValue(e.ToAttrMap.Name, tmpObj) - End Try - Next - 'Now add object to list to be saved - q.Enqueue(value) - End If - Next + If udamap.RetrieveAutomatic = True And udamap.LazyLoad = False Then + For Each value In obj.GetRemovedCollectionItems(udamap.FromClassTarget) + If udamap.DeleteAutomatic = True Then + 'Delete the object + qd = New QueuedDelete + qd.ObjectToDelete = value + q.Enqueue(qd) + Else + For Each e As AssociationMapEntry In udamap.Entries + 'Try to set to nothing first. If it fails set the value to NULL alias value + 'Need to do a get first so we know what type to alias + Try + value.SetAttributeValue(e.ToAttrMap.Name, Nothing) + Catch + tmpObj = value.GetValueByAttribute(e.ToAttrMap.Name) + ModAliasNull.NullToAlias(DBNull.Value, tmpObj) + value.SetAttributeValue(e.ToAttrMap.Name, tmpObj) + End Try + Next + 'Now add object to list to be saved + q.Enqueue(value) + End If + Next + End If ElseIf udamap.CardinalityType = AssociationMap.Cardinality.ManyToMany Then If obj.GetClassMap.Name = udamap.FromClass.Name Then col = obj.GetCollectionByAttribute(udamap.FromClassTarget) @@ -3433,12 +3435,17 @@ Dim p As PropertyInfo Dim tmpObj As Object + p = fromObject.GetObjectType.GetProperty(propertyName, BindingFlags.Instance Or BindingFlags.NonPublic Or BindingFlags.Public) + If p Is Nothing Then + 'Property propertyName couldn't be found + Return Nothing + End If + fromColl = fromObject.GetCollectionByAttribute(propertyName) If fromColl Is Nothing Then Return Nothing End If - p = fromObject.GetObjectType.GetProperty(propertyName, BindingFlags.Instance Or BindingFlags.NonPublic Or BindingFlags.Public) iListType = p.PropertyType.GetInterface("IList", True) iDicType = p.PropertyType.GetInterface("IDictionary", True) If Not iListType Is Nothing OrElse Not iDicType Is Nothing Then Index: CInjectedObject.vb =================================================================== RCS file: /cvsroot/jcframework/dotnet/CInjectedObject.vb,v retrieving revision 1.26 retrieving revision 1.27 diff -u -d -r1.26 -r1.27 --- CInjectedObject.vb 11 Apr 2005 00:31:43 -0000 1.26 +++ CInjectedObject.vb 11 Apr 2005 23:27:06 -0000 1.27 @@ -667,7 +667,7 @@ While Not cm Is Nothing For Each de As DictionaryEntry In cm.AssociationMaps aMap = de.Value - If aMap.CardinalityType = aMap.Cardinality.OneToMany Then + If aMap.CardinalityType = aMap.Cardinality.OneToMany And aMap.LazyLoad = False And aMap.RetrieveAutomatic = True And aMap.SaveAutomatic = True Then coll = PersistenceBroker.CopyCollection(Me, aMap.FromClassTarget) m_oneToManyCollections.Add(coll, aMap.FromClassTarget) End If Index: CPersistentObject.vb =================================================================== RCS file: /cvsroot/jcframework/dotnet/CPersistentObject.vb,v retrieving revision 1.66 retrieving revision 1.67 diff -u -d -r1.66 -r1.67 --- CPersistentObject.vb 11 Apr 2005 00:31:44 -0000 1.66 +++ CPersistentObject.vb 11 Apr 2005 23:27:07 -0000 1.67 @@ -1750,7 +1750,8 @@ While Not cm Is Nothing For Each de As DictionaryEntry In cm.AssociationMaps aMap = de.Value - If aMap.CardinalityType = aMap.Cardinality.OneToMany Then + 'Only copy associations with retrieveAutomatic="true". Exclude lazy loaded associations. + If aMap.CardinalityType = aMap.Cardinality.OneToMany And aMap.RetrieveAutomatic = True And aMap.LazyLoad = False And aMap.SaveAutomatic = True Then coll = PersistenceBroker.CopyCollection(Me, aMap.FromClassTarget) m_oneToManyCollections.Add(coll, aMap.FromClassTarget) End If Index: CJoin.vb =================================================================== RCS file: /cvsroot/jcframework/dotnet/CJoin.vb,v retrieving revision 1.12 retrieving revision 1.13 diff -u -d -r1.12 -r1.13 --- CJoin.vb 11 Apr 2005 00:31:43 -0000 1.12 +++ CJoin.vb 11 Apr 2005 23:27:06 -0000 1.13 @@ -182,8 +182,7 @@ LeftSide = leftJoin RightSide = rightClassMap TableAlias = aliasName - association = association - IsSuperClass = False + m_association = association End Sub '''----------------------------------------------------------------------------- @@ -269,7 +268,7 @@ Dim s As String Dim tm As TableMap Dim cm As ClassMap - Dim i As Short ' j As Short + Dim i As Short ' j As Short Dim udaEntry As AssociationMapEntry Dim db As IRelationalDatabase Dim leftBracket As String = "(" |