From: Dan M. <dan...@us...> - 2005-07-10 11:35:52
|
Update of /cvsroot/jcframework/dotnet In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6561/dotnet Modified Files: AtomsFramework.xml CClassMap.vb CInjectedObject.vb CInjectedObjects.vb CJoin.vb CMultiRetrieveCriteria.vb CMultiSummaryCriteria.vb CPersistenceBroker.vb CPersistentCriteria.vb CSelectInCriteria.vb Log Message: Add support for standard classes super classes. Add new NUnit test to test standard classes super classes. Index: CMultiSummaryCriteria.vb =================================================================== RCS file: /cvsroot/jcframework/dotnet/CMultiSummaryCriteria.vb,v retrieving revision 1.20 retrieving revision 1.21 diff -u -d -r1.20 -r1.21 --- CMultiSummaryCriteria.vb 24 May 2005 07:43:42 -0000 1.20 +++ CMultiSummaryCriteria.vb 10 Jul 2005 11:35:39 -0000 1.21 @@ -35,7 +35,7 @@ Private m_fieldsForSum As Collection Private m_methodsForSum As Collection Private m_aliasForSum As Collection - Private m_joins As Join + 'Private m_joins As Join '''----------------------------------------------------------------------------- ''' Project : AtomsFramework Index: CPersistenceBroker.vb =================================================================== RCS file: /cvsroot/jcframework/dotnet/CPersistenceBroker.vb,v retrieving revision 1.112 retrieving revision 1.113 diff -u -d -r1.112 -r1.113 --- CPersistenceBroker.vb 25 May 2005 01:26:11 -0000 1.112 +++ CPersistenceBroker.vb 10 Jul 2005 11:35:39 -0000 1.113 @@ -299,7 +299,7 @@ 'each entry will store the class map and the sql alias for the map 'Dim rMaps As New HybridDictionary Dim mapName As String - Dim cm2 As ClassMap, cm3 As ClassMap + Dim cm2 As ClassMap, cm3 As ClassMap, cm4 As ClassMap Dim classMapCount As Integer = 0 Dim udamap As AssociationMap Dim joins As Join @@ -445,66 +445,28 @@ 'Now process associations For i = 0 To rs.ResultSet.Tables(0).Rows.Count - 1 classMapCount = j - For Each de In cm.AssociationMaps - udamap = de.Value - If udamap.RetrieveAutomatic Then - mapName = "t" & classMapCount.ToString - classMapCount += 1 - cm2 = udamap.ToClass - 'Only process one-to-one relationships on the first record retrieved - If udamap.CardinalityType = AssociationMap.Cardinality.OneToOne And i = 0 Then - gotValue = False - classMapCount += Me.GetChildCountForMultipleInheritance(udamap.ToClass) - 1 - targetobj = obj.GetObjectByAttribute(udamap.FromClassTarget) - If Not targetobj Is Nothing Then - 'if the class as child classes then check if the targetobj is of type child - If cm2.ChildrenMaps.Count > 0 Then - cm3 = targetobj.GetClassMap() - cm2.PopulateObject(cm3, targetobj, rs, joins.GetClassMapTableAlias(cm3)) - Else - cm2.PopulateObject(cm2, targetobj, rs, mapName) - End If - If targetobj.Persistent Then - If Not targetobj.IsIPersistentObject Then - targetobj = LocateOrCacheInjObject(targetobj, True, True) - Else - tmpObj = m_cache.Item(targetobj) - End If - If Not (tmpObj Is Nothing) Then - targetobj = tmpObj - Try - PCCacheHits.Increment() - Catch - End Try - Else - ' All objects are loaded to the cache regardless of applications cache usage - m_cache.Add(targetobj) - Try - PCCacheSize.RawValue = m_cache.Count - Catch - End Try - End If - obj.SetAttributeValue(udamap.FromClassTarget, targetobj.GetSourceObject) - If Not targetobj.AssociationsLoaded Then - If udamap.LazyLoad Then - targetobj.IsDirty = False - targetobj.IsProxy = True - targetobj.AssociationsLoaded = True - Else - RetrievePrivateObject(targetobj, conn, False, False) - End If + cm4 = cm + Do + For Each de In cm4.AssociationMaps + udamap = de.Value + If udamap.RetrieveAutomatic Then + mapName = "t" & classMapCount.ToString + classMapCount += 1 + cm2 = udamap.ToClass + 'Only process one-to-one relationships on the first record retrieved + If udamap.CardinalityType = AssociationMap.Cardinality.OneToOne And i = 0 Then + gotValue = False + classMapCount += Me.GetChildCountForMultipleInheritance(udamap.ToClass) - 1 + targetobj = obj.GetObjectByAttribute(udamap.FromClassTarget) + If Not targetobj Is Nothing Then + 'if the class as child classes then check if the targetobj is of type child + If cm2.ChildrenMaps.Count > 0 Then + cm3 = targetobj.GetClassMap() + cm2.PopulateObject(cm3, targetobj, rs, joins.GetClassMapTableAlias(cm3)) Else - targetobj.IsDirty = False - targetobj.OriginalCacheKey = New CacheKey(targetobj) + cm2.PopulateObject(cm2, targetobj, rs, mapName) End If - gotValue = True - End If - End If - If Not gotValue Then - 'Check whether the object is of child type - If udamap.ToClass.ChildrenMaps.Count > 0 Then - targetobj = Me.CreateTargetObjectForMultipleInheritance(udamap.ToClass, obj.GetObjectType, obj.GetObjectType.Namespace, rs.ResultSet.Tables(0).Rows(i), joins, conn) - If Not targetobj Is Nothing AndAlso targetobj.Persistent Then + If targetobj.Persistent Then If Not targetobj.IsIPersistentObject Then targetobj = LocateOrCacheInjObject(targetobj, True, True) Else @@ -524,6 +486,7 @@ Catch End Try End If + obj.SetAttributeValue(udamap.FromClassTarget, targetobj.GetSourceObject) If Not targetobj.AssociationsLoaded Then If udamap.LazyLoad Then targetobj.IsDirty = False @@ -536,15 +499,14 @@ targetobj.IsDirty = False targetobj.OriginalCacheKey = New CacheKey(targetobj) End If - obj.SetAttributeValue(udamap.FromClassTarget, targetobj.GetSourceObject) + gotValue = True End If - Else - 'Object doesn't exist - let's create it - 'See if the assembly path is specified - targetobj = udamap.ToClass.CreateObjectInstance - If Not targetobj Is Nothing Then - cm2.PopulateObject(cm2, targetobj, rs, mapName) - If targetobj.Persistent Then + End If + If Not gotValue Then + 'Check whether the object is of child type + If udamap.ToClass.ChildrenMaps.Count > 0 Then + targetobj = Me.CreateTargetObjectForMultipleInheritance(udamap.ToClass, obj.GetObjectType, obj.GetObjectType.Namespace, rs.ResultSet.Tables(0).Rows(i), joins, conn) + If Not targetobj Is Nothing AndAlso targetobj.Persistent Then If Not targetobj.IsIPersistentObject Then targetobj = LocateOrCacheInjObject(targetobj, True, True) Else @@ -578,163 +540,206 @@ End If obj.SetAttributeValue(udamap.FromClassTarget, targetobj.GetSourceObject) End If + Else + 'Object doesn't exist - let's create it + 'See if the assembly path is specified + targetobj = udamap.ToClass.CreateObjectInstance + If Not targetobj Is Nothing Then + cm2.PopulateObject(cm2, targetobj, rs, mapName) + If targetobj.Persistent Then + If Not targetobj.IsIPersistentObject Then + targetobj = LocateOrCacheInjObject(targetobj, True, True) + Else + tmpObj = m_cache.Item(targetobj) + End If + If Not (tmpObj Is Nothing) Then + targetobj = tmpObj + Try + PCCacheHits.Increment() + Catch + End Try + Else + ' All objects are loaded to the cache regardless of applications cache usage + m_cache.Add(targetobj) + Try + PCCacheSize.RawValue = m_cache.Count + Catch + End Try + End If + If Not targetobj.AssociationsLoaded Then + If udamap.LazyLoad Then + targetobj.IsDirty = False + targetobj.IsProxy = True + targetobj.AssociationsLoaded = True + Else + RetrievePrivateObject(targetobj, conn, False, False) + End If + Else + targetobj.IsDirty = False + targetobj.OriginalCacheKey = New CacheKey(targetobj) + End If + obj.SetAttributeValue(udamap.FromClassTarget, targetobj.GetSourceObject) + End If + End If End If End If - End If - ElseIf udamap.CardinalityType = AssociationMap.Cardinality.OneToMany Or udamap.CardinalityType = AssociationMap.Cardinality.ManyToMany Then - If udamap.CardinalityType = AssociationMap.Cardinality.OneToMany Then - col = obj.GetCollectionByAttribute(udamap.FromClassTarget) - 'fromClass = udamap.FromClass - toClass = udamap.ToClass - Else - If obj.GetClassMap.Name = udamap.FromClass.Name Then + ElseIf udamap.CardinalityType = AssociationMap.Cardinality.OneToMany Or udamap.CardinalityType = AssociationMap.Cardinality.ManyToMany Then + If udamap.CardinalityType = AssociationMap.Cardinality.OneToMany Then col = obj.GetCollectionByAttribute(udamap.FromClassTarget) 'fromClass = udamap.FromClass toClass = udamap.ToClass Else - col = obj.GetCollectionByAttribute(udamap.ToClassTarget) - toClass = udamap.FromClass - 'fromClass = udamap.ToClass - End If - End If - 'When retrieving we need to make sure the collection is cleared before - 'we go an load objects. - ' Under normal circumstances this will be the case, however when the - 'collection is in a many-to-many associations it is possible for - 'one side to be cleared, but for the other object to still - 'have the reference in place. (see the unit tests for an example) - If i = 0 Then - 'Obviously we don't want to clear it each time through ;-) - col.Clear() - End If - - 'Check whether the object is of child type - If toClass.ChildrenMaps.Count > 0 Then - targetobj = Me.CreateTargetObjectForMultipleInheritance(toClass, obj.GetObjectType, obj.GetObjectType.Namespace, rs.ResultSet.Tables(0).Rows(i), joins, conn) - 'update classMapCount with the child count number - classMapCount += Me.GetChildCountForMultipleInheritance(toClass) - classMapCount -= 1 'This is because we added one in the beginning of the for loop - If Not targetobj Is Nothing AndAlso targetobj.Persistent Then - If Not targetobj.IsIPersistentObject Then - targetobj = LocateOrCacheInjObject(targetobj, True, True) - Else - tmpObj = m_cache.Item(targetobj) - End If - If Not (tmpObj Is Nothing) Then - targetobj = tmpObj - Try - PCCacheHits.Increment() - Catch - End Try + If obj.GetClassMap.Name = udamap.FromClass.Name Then + col = obj.GetCollectionByAttribute(udamap.FromClassTarget) + 'fromClass = udamap.FromClass + toClass = udamap.ToClass Else - ' All objects are loaded to the cache regardless of applications cache usage - m_cache.Add(targetobj) - Try - PCCacheSize.RawValue = m_cache.Count - Catch - End Try + col = obj.GetCollectionByAttribute(udamap.ToClassTarget) + toClass = udamap.FromClass + 'fromClass = udamap.ToClass End If + End If + 'When retrieving we need to make sure the collection is cleared before + 'we go an load objects. + ' Under normal circumstances this will be the case, however when the + 'collection is in a many-to-many associations it is possible for + 'one side to be cleared, but for the other object to still + 'have the reference in place. (see the unit tests for an example) + If i = 0 Then + 'Obviously we don't want to clear it each time through ;-) + col.Clear() + End If - 'Need to determine if new object is already in the collection - '(prevents duplicates when multiple one-to-many associations exist) - gotValue = False - For Each tmpColObj As Object In col - If tmpColObj.GetType.IsSubclassOf(GetType(PersistentObject)) Then - tmpObj = tmpColObj + 'Check whether the object is of child type + If toClass.ChildrenMaps.Count > 0 Then + targetobj = Me.CreateTargetObjectForMultipleInheritance(toClass, obj.GetObjectType, obj.GetObjectType.Namespace, rs.ResultSet.Tables(0).Rows(i), joins, conn) + 'update classMapCount with the child count number + classMapCount += Me.GetChildCountForMultipleInheritance(toClass) + classMapCount -= 1 'This is because we added one in the beginning of the for loop + If Not targetobj Is Nothing AndAlso targetobj.Persistent Then + If Not targetobj.IsIPersistentObject Then + targetobj = LocateOrCacheInjObject(targetobj, True, True) + tmpObj = Nothing Else - tmpObj = GetInjectedObject(tmpColObj) + tmpObj = m_cache.Item(targetobj) End If - If tmpObj.Equals(targetobj) Then - gotValue = True + If Not (tmpObj Is Nothing) Then + targetobj = tmpObj + Try + PCCacheHits.Increment() + Catch + End Try + Else + ' All objects are loaded to the cache regardless of applications cache usage + m_cache.Add(targetobj) + Try + PCCacheSize.RawValue = m_cache.Count + Catch + End Try End If - Next - If Not gotValue Then - If Not targetobj.AssociationsLoaded Then - If udamap.LazyLoad Then - targetobj.IsDirty = False - targetobj.IsProxy = True - targetobj.AssociationsLoaded = True + 'Need to determine if new object is already in the collection + '(prevents duplicates when multiple one-to-many associations exist) + gotValue = False + For Each tmpColObj As Object In col + If tmpColObj.GetType.IsSubclassOf(GetType(PersistentObject)) Then + tmpObj = tmpColObj Else - RetrievePrivateObject(targetobj, conn, False, False) + tmpObj = GetInjectedObject(tmpColObj) + End If + If tmpObj.Equals(targetobj) Then + gotValue = True + End If + Next + + If Not gotValue Then + If Not targetobj.AssociationsLoaded Then + If udamap.LazyLoad Then + targetobj.IsDirty = False + targetobj.IsProxy = True + targetobj.AssociationsLoaded = True + Else + RetrievePrivateObject(targetobj, conn, False, False) + End If + Else + targetobj.IsDirty = False + targetobj.OriginalCacheKey = New CacheKey(targetobj) + End If + If targetobj.AssociationsLoaded Then + col.Add(targetobj.GetSourceObject) End If - Else - targetobj.IsDirty = False - targetobj.OriginalCacheKey = New CacheKey(targetobj) - End If - If targetobj.AssociationsLoaded Then - col.Add(targetobj.GetSourceObject) End If End If - End If - Else - targetobj = toClass.CreateObjectInstance - row = rs.ResultSet.Tables(0).Rows(i) - toClass.PopulateObject(toClass, targetobj, row, mapName) - If targetobj.Persistent Then - If Not targetobj.IsIPersistentObject Then - 'For injected objects we want to work with just one version - 'By not checking the persistent cache we can ensure this, and - 'we will also be keeping the persistent cache updated - targetobj = LocateOrCacheInjObject(targetobj, True, True) - tmpObj = Nothing - Else - tmpObj = m_cache.Item(targetobj) - End If - If Not (tmpObj Is Nothing) Then - targetobj = tmpObj - Try - PCCacheHits.Increment() - Catch - End Try - Else - ' All objects are loaded to the cache regardless of applications cache usage - m_cache.Add(targetobj) - Try - PCCacheSize.RawValue = m_cache.Count - Catch - End Try - End If - 'Need to determine if new object is already in the collection - '(prevents duplicates when multiple one-to-many associations exist) - gotValue = False - For Each tmpColObj As Object In col - If tmpColObj.GetType.IsSubclassOf(GetType(PersistentObject)) Then - tmpObj = tmpColObj + Else + targetobj = toClass.CreateObjectInstance + row = rs.ResultSet.Tables(0).Rows(i) + toClass.PopulateObject(toClass, targetobj, row, mapName) + If targetobj.Persistent Then + If Not targetobj.IsIPersistentObject Then + 'For injected objects we want to work with just one version + 'By not checking the persistent cache we can ensure this, and + 'we will also be keeping the persistent cache updated + targetobj = LocateOrCacheInjObject(targetobj, True, True) + tmpObj = Nothing Else - tmpObj = GetInjectedObject(tmpColObj) + tmpObj = m_cache.Item(targetobj) End If - If tmpObj.Equals(targetobj) Then - gotValue = True + If Not (tmpObj Is Nothing) Then + targetobj = tmpObj + Try + PCCacheHits.Increment() + Catch + End Try + Else + ' All objects are loaded to the cache regardless of applications cache usage + m_cache.Add(targetobj) + Try + PCCacheSize.RawValue = m_cache.Count + Catch + End Try End If - Next - If Not gotValue Then - If Not targetobj.AssociationsLoaded Then - If udamap.LazyLoad Then - targetobj.IsDirty = False - targetobj.IsProxy = True - targetobj.AssociationsLoaded = True + 'Need to determine if new object is already in the collection + '(prevents duplicates when multiple one-to-many associations exist) + gotValue = False + For Each tmpColObj As Object In col + If tmpColObj.GetType.IsSubclassOf(GetType(PersistentObject)) Then + tmpObj = tmpColObj Else - RetrievePrivateObject(targetobj, conn, False, False) + tmpObj = GetInjectedObject(tmpColObj) + End If + If tmpObj.Equals(targetobj) Then + gotValue = True + End If + Next + If Not gotValue Then + If Not targetobj.AssociationsLoaded Then + If udamap.LazyLoad Then + targetobj.IsDirty = False + targetobj.IsProxy = True + targetobj.AssociationsLoaded = True + Else + RetrievePrivateObject(targetobj, conn, False, False) + End If + Else + targetobj.IsDirty = False + targetobj.OriginalCacheKey = New CacheKey(targetobj) + End If + If targetobj.AssociationsLoaded Then + col.Add(targetobj.GetSourceObject) End If - Else - targetobj.IsDirty = False - targetobj.OriginalCacheKey = New CacheKey(targetobj) - End If - If targetobj.AssociationsLoaded Then - col.Add(targetobj.GetSourceObject) End If End If End If End If End If - End If - Next + Next + cm4 = cm4.SuperClass + Loop While Not cm4 Is Nothing Next - If Not cm.SuperClass Is Nothing Then - 'need to process associations for the parent as well - RetrieveAssociations(obj, conn, cm.SuperClass, useCache) - End If + 'If Not cm.SuperClass Is Nothing Then + ' 'need to process associations for the parent as well + ' RetrieveAssociations(obj, conn, cm.SuperClass, useCache) + 'End If obj.IsProxy = False If obj.Persistent Then obj.IsDirty = False 'Clear the dirty flag only if the object is persistent @@ -825,7 +830,8 @@ Next j If valuesSet Then If Not Value.IsIPersistentObject Then - anObjPers = LocateOrCacheInjObject(Value, True, True) + 'anObjPers = LocateOrCacheInjObject(Value, False, False) + anObjPers = m_injectedObjects.Find(Value) Else anObjPers = m_cache.Item(Value) End If @@ -3159,6 +3165,60 @@ ''' ----------------------------------------------------------------------------- ''' <summary> + ''' Returns all objects in the database of the same type. + ''' </summary> + ''' <param name="type">Object type to return</param> + ''' <returns>Arraylist. All objects of the same type</returns> + ''' <remarks> + ''' </remarks> + ''' <history> + ''' [danmayer] 10/7/2005 Created + ''' </history> + ''' ----------------------------------------------------------------------------- + Public Function GetAll(ByVal type As Type) As ArrayList + Return GetAll(type, False) + End Function + + ''' ----------------------------------------------------------------------------- + ''' <summary> + ''' Returns all objects of the same type and their associated objects from the database. + ''' </summary> + ''' <param name="type">Object type to return</param> + ''' <param name="getAssociations">True - get all associated object.</param> + ''' <returns>Arraylist. All objects of the same type</returns> + ''' <remarks> + ''' </remarks> + ''' <history> + ''' [danmayer] 10/7/2005 Created + ''' </history> + ''' ----------------------------------------------------------------------------- + Public Function GetAll(ByVal type As Type, ByVal getAssociations As Boolean) As ArrayList + Dim injObj As InjectedObject + Dim col As ArrayList + Dim r As RetrieveCriteria + Dim c As ResultCursor + + r = New RetrieveCriteria + r.ReturnFullObjects = True + r.ClassMap = Me.GetClassMap(type) + c = r.Perform + col = New ArrayList + While c.HasElements And Not c.EOF + injObj = New InjectedObject(Activator.CreateInstance(type)) + c.LoadObject(injObj.ReferencedObject) + If getAssociations And Not injObj.AssociationsLoaded Then + 'Load the full object + injObj = Me.GetInjectedObject(injObj.ReferencedObject) + Me.RetrieveObject(injObj, False, False) + End If + col.Add(injObj) + c.NextCursor() + End While + Return col + End Function + + ''' ----------------------------------------------------------------------------- + ''' <summary> ''' Finds an object in the database using the Find attributes. ''' </summary> ''' <param name="obj">The object to be found.</param> @@ -3264,16 +3324,14 @@ If addToCache Then m_injectedObjects.Add(injObj) End If - Else - If replaceCachedValues And Not injObj.IsLoading Then - If TypeOf obj Is IPersistableObject Then - 'If the object is loading we will already be setting associations and values - redoing it can wipe out collections, etc - injObj.ReplaceValues(CType(obj, IPersistableObject).GetSourceObject, injObj.ReferencedObject, False) - injObj.AssociationsLoaded = False - Else - injObj.ReplaceValues(obj, injObj.ReferencedObject, False) - injObj.AssociationsLoaded = False - End If + ElseIf replaceCachedValues AndAlso Not injObj.IsLoading Then + If TypeOf obj Is IPersistableObject Then + 'If the object is loading we will already be setting associations and values - redoing it can wipe out collections, etc + injObj.ReplaceValues(CType(obj, IPersistableObject).GetSourceObject, injObj.ReferencedObject, False) + injObj.AssociationsLoaded = False + Else + injObj.ReplaceValues(obj, injObj.ReferencedObject, False) + injObj.AssociationsLoaded = False End If End If Return injObj Index: CMultiRetrieveCriteria.vb =================================================================== RCS file: /cvsroot/jcframework/dotnet/CMultiRetrieveCriteria.vb,v retrieving revision 1.23 retrieving revision 1.24 diff -u -d -r1.23 -r1.24 --- CMultiRetrieveCriteria.vb 24 May 2005 07:43:42 -0000 1.23 +++ CMultiRetrieveCriteria.vb 10 Jul 2005 11:35:39 -0000 1.24 @@ -36,7 +36,7 @@ Private m_rows As Short Private m_Having As CriteriaCondition Private m_fullObjects As Boolean 'default is false, ie proxy objects only - Private m_joins As Join + 'Private m_joins As Join '''----------------------------------------------------------------------------- ''' <summary> @@ -143,7 +143,7 @@ Me.New() Me.AddObjectToJoin(obj, Nothing, "") Me.ClassMap = obj.GetClassMap(obj) - m_joins = New Join(obj.GetClassMap(obj), "t1") + 'm_joins = New Join(obj.GetClassMap(obj), "t1") End Sub ''' ----------------------------------------------------------------------------- @@ -165,7 +165,7 @@ injObj = broker.GetInjectedObject(obj) Me.AddObjectToJoin(injObj, Nothing, "") Me.ClassMap = broker.GetClassMap(obj.GetType) - m_joins = New Join(Me.ClassMap, "t1") + 'm_joins = New Join(Me.ClassMap, "t1") End Sub '''----------------------------------------------------------------------------- @@ -212,20 +212,29 @@ End While Exit Sub End If + + If m_fromCMaps.Count = 0 Then + Throw New RetrieveException("The From Object has not been added to the criteria yet") + End If + cm = fromObj.GetClassMap i = 0 'Used to track the index of the from object For Each cm2 In m_fromCMaps i += 1 If cm2.Name = cm.Name Then - bfound = True - Exit For + am = cm2.GetAssociationMapByName(assocName) + If Not am Is Nothing Then + 'bfound = True + Exit For + End If End If Next - If Not bfound Then - Throw New RetrieveException("The From Object has not been added to the criteria yet") - End If - am = cm2.GetAssociationMapByName(assocName) + 'If Not bfound Then + ' Throw New RetrieveException("The From Object has not been added to the criteria yet") + 'End If + + ' am = cm2.GetAssociationMapByName(assocName) If am Is Nothing Then Throw New NoAssociationException("Invalid association " & assocName & " selected - no such association exists") End If @@ -371,7 +380,7 @@ For Each cm In m_fromCMaps j += 1 mapName = "t" & j.ToString - ht.Add(cm.Name, mapName) + ht.Add(cm.ClassNamespace & "." & cm.Name, mapName) 'Load each individual column, and process in order of objects to join For i = 1 To cm.GetSize 'process attributes for either the whole object or proxy attributes only @@ -417,7 +426,7 @@ Else statement.AddSqlClause(" ") End If - statement.AddSqlClause(entry.AttributeMap.ColumnMap.GetAliasQualifiedName(ht(entry.ClassMap.Name))) + statement.AddSqlClause(entry.AttributeMap.ColumnMap.GetAliasQualifiedName(ht(entry.ClassMap.ClassNamespace & "." & entry.ClassMap.Name))) 'statement.addSqlClause(entry.AttributeMap.ColumnMap.getAliasQualifiedName("t1")) If entry.Ascend Then statement.AddSqlClause(" " & Me.ClassMap.RelationalDatabase.GetClauseStringAscend) @@ -521,11 +530,21 @@ Public Function GetObjectAlias(ByVal obj As IPersistableObject, ByVal offset As Integer) As String Dim i As Integer = 0 For Each o As DictionaryEntry In m_objectsToJoin - If o.Value.GetType Is obj.GetSourceObject.GetType Then - If i = offset Then - Return o.Key - Else - i += 1 + If TypeOf (o.Value) Is InjectedObject Then + If CType(o.Value, InjectedObject).ReferencedObject.GetType Is obj.GetSourceObject.GetType Then + If i = offset Then + Return o.Key + Else + i += 1 + End If + End If + Else + If o.Value.GetType Is obj.GetSourceObject.GetType Then + If i = offset Then + Return o.Key + Else + i += 1 + End If End If End If Next Index: CSelectInCriteria.vb =================================================================== RCS file: /cvsroot/jcframework/dotnet/CSelectInCriteria.vb,v retrieving revision 1.12 retrieving revision 1.13 diff -u -d -r1.12 -r1.13 --- CSelectInCriteria.vb 25 May 2005 01:26:12 -0000 1.12 +++ CSelectInCriteria.vb 10 Jul 2005 11:35:39 -0000 1.13 @@ -22,7 +22,7 @@ Private m_udamaps As Collection Private m_fromCMaps As Collection Private m_selectAttribute As AttributeMap - Private m_joins As Join + 'Private m_joins As Join Private Shared m_subQueryCount As Integer Private m_SQC As Integer Private m_alias As String Index: CInjectedObjects.vb =================================================================== RCS file: /cvsroot/jcframework/dotnet/CInjectedObjects.vb,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- CInjectedObjects.vb 23 May 2005 07:23:55 -0000 1.10 +++ CInjectedObjects.vb 10 Jul 2005 11:35:39 -0000 1.11 @@ -403,7 +403,7 @@ ''' </history> ''' ----------------------------------------------------------------------------- Public Overloads Function Find(ByVal obj As InjectedObject, ByVal useFindAttributes As Boolean) As InjectedObject - Return Find(obj, useFindAttributes, True) + Return Find(obj, useFindAttributes, False) End Function ''' ----------------------------------------------------------------------------- Index: CJoin.vb =================================================================== RCS file: /cvsroot/jcframework/dotnet/CJoin.vb,v retrieving revision 1.15 retrieving revision 1.16 diff -u -d -r1.15 -r1.16 --- CJoin.vb 24 May 2005 07:43:42 -0000 1.15 +++ CJoin.vb 10 Jul 2005 11:35:39 -0000 1.16 @@ -337,8 +337,13 @@ s = s & " " & db.GetClauseStringAnd & " " End If udaEntry = Association.GetEntry(i) - s = s & udaEntry.FromAttrMap.ColumnMap.GetAliasQualifiedName(LeftTableAlias) & " = " _ - & udaEntry.ToAttrMap.ColumnMap.GetAliasQualifiedName(TableAlias) + If Not Association.FromClass Is Nothing AndAlso Not Association.FromClass.Equals(Association.ToClass) AndAlso Association.FromClass.ChildrenMaps.Count > 0 Then + s = s & udaEntry.FromAttrMap.ColumnMap.GetAliasQualifiedName(Me.GetClassMapTableAlias(Association.FromClass)) & " = " _ + & udaEntry.ToAttrMap.ColumnMap.GetAliasQualifiedName(TableAlias) + Else + s = s & udaEntry.FromAttrMap.ColumnMap.GetAliasQualifiedName(LeftTableAlias) & " = " _ + & udaEntry.ToAttrMap.ColumnMap.GetAliasQualifiedName(TableAlias) + End If Next i s = s & rightBracket Else Index: AtomsFramework.xml =================================================================== RCS file: /cvsroot/jcframework/dotnet/AtomsFramework.xml,v retrieving revision 1.15 retrieving revision 1.16 diff -u -d -r1.15 -r1.16 --- AtomsFramework.xml 25 May 2005 01:26:10 -0000 1.15 +++ AtomsFramework.xml 10 Jul 2005 11:35:39 -0000 1.16 @@ -2681,7 +2681,7 @@ <history> [rbanks] 27/11/2003 Created </history></member> - <member name="M:AtomsFramework.ClassMap.GetInheritedAssociations"> + <member name="M:AtomsFramework.ClassMap.GetInheritedAssociations(AtomsFramework.Join)"> <summary> Gets SQL text for processing inheritance associations. </summary> @@ -6409,6 +6409,29 @@ <history> [rbanks] 24/05/2005 Created </history></member> + <member name="M:AtomsFramework.PersistenceBroker.GetAll(System.Type)"> + <summary> + Returns all objects in the database of the same type. + </summary> + <param name="type">Object type to return</param> + <returns>Arraylist. All objects of the same type</returns> + <remarks> + </remarks> + <history> + [danmayer] 10/7/2005 Created + </history></member> + <member name="M:AtomsFramework.PersistenceBroker.GetAll(System.Type,System.Boolean)"> + <summary> + Returns all objects of the same type and their associated objects from the database. + </summary> + <param name="type">Object type to return</param> + <param name="getAssociations">True - get all associated object.</param> + <returns>Arraylist. All objects of the same type</returns> + <remarks> + </remarks> + <history> + [danmayer] 10/7/2005 Created + </history></member> <member name="M:AtomsFramework.PersistenceBroker.FindObject(System.Object@)"> <summary> Finds an object in the database using the Find attributes. Index: CInjectedObject.vb =================================================================== RCS file: /cvsroot/jcframework/dotnet/CInjectedObject.vb,v retrieving revision 1.31 retrieving revision 1.32 diff -u -d -r1.31 -r1.32 --- CInjectedObject.vb 24 May 2005 07:43:42 -0000 1.31 +++ CInjectedObject.vb 10 Jul 2005 11:35:39 -0000 1.32 @@ -835,17 +835,25 @@ Exit Sub End If + Dim v As Object Dim dotPos As Integer dotPos = name.IndexOf(".") Try If dotPos = -1 Then - If TypeOf (value) Is System.SByte Then - CallByName(obj, name, CallType.Set, IIf(value.ToString = "1", True, False)) - ElseIf TypeOf (value) Is System.Guid Then - CallByName(obj, name, CallType.Set, CType(value, Guid).ToString("N")) + If TypeOf (value) Is InjectedObject Then + v = CType(value, InjectedObject).ReferencedObject + If TypeOf (v) Is System.SByte Then + CallByName(obj, name, CallType.Set, IIf(v.ToString = "1", True, False)) + Else + CallByName(obj, name, CallType.Set, v) + End If Else - CallByName(obj, name, CallType.Set, value) + If TypeOf (value) Is System.SByte Then + CallByName(obj, name, CallType.Set, IIf(value.ToString = "1", True, False)) + Else + CallByName(obj, name, CallType.Set, value) + End If End If Else Dim o As Object @@ -981,10 +989,10 @@ udamap = classMap.GetStraightAssociationMap(i) If udamap.CardinalityType = AssociationMap.Cardinality.OneToOne Then obj.SetAttributeValue(udamap.FromClassTarget, Me.GetObjectByAttribute(udamap.FromClassTarget)) - If Not ci Is Nothing Then ci.SetAttributeValue(ci.m_originalObject, udamap.FromClassTarget, Me.GetObjectByAttribute(m_originalObject, udamap.FromClassTarget)) + If Not ci Is Nothing Then ci.SetAttributeValue(ci.m_originalObject, udamap.FromClassTarget, Me.GetObjectByAttribute(m_object, udamap.FromClassTarget)) ElseIf udamap.CardinalityType = AssociationMap.Cardinality.OneToMany Or udamap.CardinalityType = AssociationMap.Cardinality.ManyToMany Then obj.SetAttributeValue(udamap.FromClassTarget, Me.GetCollectionByAttribute(udamap.FromClassTarget)) - If Not ci Is Nothing Then ci.SetAttributeValue(ci.m_originalObject, udamap.FromClassTarget, Me.GetCollectionByAttribute(m_originalObject, udamap.FromClassTarget)) + If Not ci Is Nothing Then ci.SetAttributeValue(ci.m_originalObject, udamap.FromClassTarget, Me.GetCollectionByAttribute(m_object, udamap.FromClassTarget)) End If Next i Dim AttrMap As AttributeMap @@ -1004,10 +1012,10 @@ udamap = cm.GetStraightAssociationMap(i) If udamap.CardinalityType = AssociationMap.Cardinality.OneToOne Then obj.SetAttributeValue(udamap.FromClassTarget, Me.GetObjectByAttribute(udamap.FromClassTarget)) - If Not ci Is Nothing Then ci.SetAttributeValue(ci.m_originalObject, udamap.FromClassTarget, Me.GetObjectByAttribute(m_originalObject, udamap.FromClassTarget)) + If Not ci Is Nothing Then ci.SetAttributeValue(ci.m_originalObject, udamap.FromClassTarget, Me.GetObjectByAttribute(m_object, udamap.FromClassTarget)) ElseIf udamap.CardinalityType = AssociationMap.Cardinality.OneToMany Or udamap.CardinalityType = AssociationMap.Cardinality.ManyToMany Then obj.SetAttributeValue(udamap.FromClassTarget, Me.GetCollectionByAttribute(udamap.FromClassTarget)) - If Not ci Is Nothing Then ci.SetAttributeValue(ci.m_originalObject, udamap.FromClassTarget, Me.GetCollectionByAttribute(m_originalObject, udamap.FromClassTarget)) + If Not ci Is Nothing Then ci.SetAttributeValue(ci.m_originalObject, udamap.FromClassTarget, Me.GetCollectionByAttribute(m_object, udamap.FromClassTarget)) End If Next i Index: CPersistentCriteria.vb =================================================================== RCS file: /cvsroot/jcframework/dotnet/CPersistentCriteria.vb,v retrieving revision 1.15 retrieving revision 1.16 diff -u -d -r1.15 -r1.16 --- CPersistentCriteria.vb 24 May 2005 07:43:43 -0000 1.15 +++ CPersistentCriteria.vb 10 Jul 2005 11:35:39 -0000 1.16 @@ -172,6 +172,8 @@ Private m_Associations As Collection Private m_WhereCondition As CriteriaCondition + Protected m_joins As Join + '''----------------------------------------------------------------------------- ''' <summary> ''' A collection of the various sub-criteria that make up this criteria. @@ -354,7 +356,7 @@ Dim clauseConditionAdded As Boolean = False Dim cm As ClassMap - inheritedAssoc = Me.ClassMap.GetInheritedAssociations + inheritedAssoc = Me.ClassMap.GetInheritedAssociations(m_joins) If inheritedAssoc Is Nothing Then inheritedAssoc = "" End If Index: CClassMap.vb =================================================================== RCS file: /cvsroot/jcframework/dotnet/CClassMap.vb,v retrieving revision 1.61 retrieving revision 1.62 diff -u -d -r1.61 -r1.62 --- CClassMap.vb 25 May 2005 01:26:11 -0000 1.61 +++ CClassMap.vb 10 Jul 2005 11:35:39 -0000 1.62 @@ -1866,7 +1866,7 @@ ''' [rbanks] 27/11/2003 Created ''' </history> '''----------------------------------------------------------------------------- - Public Function GetInheritedAssociations() As String + Public Function GetInheritedAssociations(ByVal join As Join) As String Dim strTemp As String Dim addAndClause As Boolean Dim i As Short @@ -1879,8 +1879,13 @@ If addAndClause Then strTemp = strTemp & " " & Me.RelationalDatabase.GetClauseStringAnd & " " End If - strTemp = strTemp & clMap.GetReferenceAttributeMap(i).ColumnMap.GetFullyQualifiedName _ - & "=" & clMap.GetReferenceAttributeMap(i).AttributeMap.ColumnMap.GetFullyQualifiedName + If Not join Is Nothing Then + strTemp = strTemp & clMap.GetReferenceAttributeMap(i).ColumnMap.GetAliasQualifiedName(join.GetClassMapTableAlias(clMap)) _ + & " = " & clMap.GetReferenceAttributeMap(i).AttributeMap.ColumnMap.GetAliasQualifiedName(join.GetClassMapTableAlias(clMap.SuperClass)) + Else + strTemp = strTemp & clMap.GetReferenceAttributeMap(i).ColumnMap.GetFullyQualifiedName _ + & " = " & clMap.GetReferenceAttributeMap(i).AttributeMap.ColumnMap.GetFullyQualifiedName + End If addAndClause = True Next i clMap = clMap.SuperClass @@ -2006,23 +2011,28 @@ cm3 = cm2 cm2 = cm2.SuperClass End While - For Each de In Me.AssociationMaps - udamap = de.Value - If udamap.RetrieveAutomatic Then - classMapCount += 1 - mapName = "t" & classMapCount.ToString - If udamap.CardinalityType = AssociationMap.Cardinality.ManyToMany AndAlso Me.Name <> udamap.FromClass.Name Then - rMaps.Add(mapName, udamap.FromClass) - m_joinSet = New Join(m_joinSet, udamap.FromClass, mapName, udamap) - broker.CreateJoinForMultipleInheritance(udamap.FromClass, classMapCount, m_joinSet, rMaps) - Else - rMaps.Add(mapName, udamap.ToClass) - m_joinSet = New Join(m_joinSet, udamap.ToClass, mapName, udamap) - 'Add joins for multiple inheritance - broker.CreateJoinForMultipleInheritance(udamap.ToClass, classMapCount, m_joinSet, rMaps) + + cm2 = Me + Do + For Each de In cm2.AssociationMaps + udamap = de.Value + If udamap.RetrieveAutomatic Then + classMapCount += 1 + mapName = "t" & classMapCount.ToString + If udamap.CardinalityType = AssociationMap.Cardinality.ManyToMany AndAlso cm2.Name <> udamap.FromClass.Name Then + rMaps.Add(mapName, udamap.FromClass) + m_joinSet = New Join(m_joinSet, udamap.FromClass, mapName, udamap) + broker.CreateJoinForMultipleInheritance(udamap.FromClass, classMapCount, m_joinSet, rMaps) + Else + rMaps.Add(mapName, udamap.ToClass) + m_joinSet = New Join(m_joinSet, udamap.ToClass, mapName, udamap) + 'Add joins for multiple inheritance + broker.CreateJoinForMultipleInheritance(udamap.ToClass, classMapCount, m_joinSet, rMaps) + End If End If - End If - Next + Next + cm2 = cm2.SuperClass + Loop While Not cm2 Is Nothing 'Now build the SQL statement statement.AddSqlClause(Me.RelationalDatabase.GetClauseStringSelect & " ") @@ -2148,23 +2158,28 @@ cm3 = cm2 cm2 = cm2.SuperClass End While - For Each de In Me.AssociationMaps - udamap = de.Value - If udamap.RetrieveAutomatic Then - classMapCount += 1 - mapName = "t" & classMapCount.ToString - If udamap.CardinalityType = AssociationMap.Cardinality.ManyToMany AndAlso Me.Name <> udamap.FromClass.Name Then - rMaps.Add(mapName, udamap.FromClass) - m_joinSet = New Join(m_joinSet, udamap.FromClass, mapName, udamap) - broker.CreateJoinForMultipleInheritance(udamap.FromClass, classMapCount, m_joinSet, rMaps) - Else - rMaps.Add(mapName, udamap.ToClass) - m_joinSet = New Join(m_joinSet, udamap.ToClass, mapName, udamap) - 'Add joins for multiple inheritance - broker.CreateJoinForMultipleInheritance(udamap.ToClass, classMapCount, m_joinSet, rMaps) + + cm2 = Me + Do + For Each de In cm2.AssociationMaps + udamap = de.Value + If udamap.RetrieveAutomatic Then + classMapCount += 1 + mapName = "t" & classMapCount.ToString + If udamap.CardinalityType = AssociationMap.Cardinality.ManyToMany AndAlso cm2.Name <> udamap.FromClass.Name Then + rMaps.Add(mapName, udamap.FromClass) + m_joinSet = New Join(m_joinSet, udamap.FromClass, mapName, udamap) + broker.CreateJoinForMultipleInheritance(udamap.FromClass, classMapCount, m_joinSet, rMaps) + Else + rMaps.Add(mapName, udamap.ToClass) + m_joinSet = New Join(m_joinSet, udamap.ToClass, mapName, udamap) + 'Add joins for multiple inheritance + broker.CreateJoinForMultipleInheritance(udamap.ToClass, classMapCount, m_joinSet, rMaps) + End If End If - End If - Next + Next + cm2 = cm2.SuperClass + Loop While Not cm2 Is Nothing 'Now build the SQL statement statement.AddSqlClause(Me.RelationalDatabase.GetClauseStringSelect & " ") |