From: Richard B. <rb...@us...> - 2004-11-09 11:46:13
|
Update of /cvsroot/jcframework/dotnet In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13726 Modified Files: CClassMap.vb CCursor.vb CPersistenceBroker.vb CXMLConfigLoader.vb modAliasNull.vb Log Message: Extra case check in modAliasNull Changes CClassmap to use populateObject instead of retrieveObject to reduce confusion Fix for mappings where child classes override mappings in the parent. Index: modAliasNull.vb =================================================================== RCS file: /cvsroot/jcframework/dotnet/modAliasNull.vb,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- modAliasNull.vb 1 Nov 2004 04:08:23 -0000 1.5 +++ modAliasNull.vb 9 Nov 2004 11:46:04 -0000 1.6 @@ -75,9 +75,10 @@ If InValue Is Nothing Then blnValue = True End If - ' If Trim(InValue) = NULL_STRING Then blnValue = True Case VariantType.Byte If InValue = NULL_BYTE Then blnValue = True + Case VariantType.DataObject.Null + blnValue = True Case Else If InValue Is Nothing Then blnValue = True @@ -86,8 +87,6 @@ blnValue = True End If End If - ' bytes and boleans - 'Debug.Assert False End Select Return blnValue End Function Index: CPersistenceBroker.vb =================================================================== RCS file: /cvsroot/jcframework/dotnet/CPersistenceBroker.vb,v retrieving revision 1.78 retrieving revision 1.79 diff -u -d -r1.78 -r1.79 --- CPersistenceBroker.vb 5 Nov 2004 01:39:17 -0000 1.78 +++ CPersistenceBroker.vb 9 Nov 2004 11:46:04 -0000 1.79 @@ -329,7 +329,7 @@ rs = conn.processSelectStatement(statement) Debug.WriteLine("Select statement returned " & rs.ResultSet.Tables(0).Rows.Count & " row(s)") If rs.ResultSet.Tables(0).Rows.Count > 0 Then - cm.retrieveObject(cm, obj, rs, "t1") + cm.populateObject(cm, obj, rs, "t1") 'Mark associations as retrieved (even though they aren't yet) to stop circular references in processing obj.AssociationsLoaded = True Else @@ -356,7 +356,7 @@ End If If rs.ResultSet.Tables(0).Rows.Count > 0 Then mapName = "t" & classMapCount.ToString - cm.retrieveObject(cm2, obj, rs, mapName) + cm.populateObject(cm2, obj, rs, mapName, True, cm) End If cm3 = cm2 cm2 = cm2.SuperClass @@ -383,9 +383,9 @@ '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.retrieveObject(cm3, targetobj, rs, joins.GetTableAlias(cm3)) + cm2.populateObject(cm3, targetobj, rs, joins.GetTableAlias(cm3)) Else - cm2.retrieveObject(cm2, targetobj, rs, mapName) + cm2.populateObject(cm2, targetobj, rs, mapName) End If If targetobj.Persistent Then tmpObj = m_cache.Item(targetobj) @@ -447,7 +447,7 @@ targetobj = udamap.ForClass.CreateObjectInstance If Not targetobj Is Nothing Then - cm2.retrieveObject(cm2, targetobj, rs, mapName) + cm2.populateObject(cm2, targetobj, rs, mapName) If targetobj.Persistent Then tmpObj = m_cache.Item(targetobj) If Not (tmpObj Is Nothing) Then @@ -527,7 +527,7 @@ targetobj = udamap.ForClass.CreateObjectInstance rw = rs.ResultSet.Tables(0).Rows(i) - cm2.retrieveObject(cm2, targetobj, rw, mapName) + cm2.populateObject(cm2, targetobj, rw, mapName) If targetobj.Persistent Then tmpObj = m_cache.Item(targetobj) If Not (tmpObj Is Nothing) Then @@ -2089,7 +2089,7 @@ cm1 = classMap.SuperClass cm2 = classMap While Not cm1 Is Nothing - classMap.retrieveObject(cm1, obj, dataRow, joins.GetTableAlias(cm1)) + classMap.populateObject(cm1, obj, dataRow, joins.GetTableAlias(cm1), True, classMap) cm2 = cm1 cm1 = cm1.SuperClass End While @@ -2097,7 +2097,7 @@ 'set persistent to false because the parent will allways be persistent obj.Persistent = False 'Now retrieve the class details - classMap.retrieveObject(classMap, obj, dataRow, joins.GetTableAlias(classMap)) + classMap.populateObject(classMap, obj, dataRow, joins.GetTableAlias(classMap)) 'Dim tmpobj As CPersistentObject 'tmpobj = m_cache.Item(obj) Index: CCursor.vb =================================================================== RCS file: /cvsroot/jcframework/dotnet/CCursor.vb,v retrieving revision 1.13 retrieving revision 1.14 diff -u -d -r1.13 -r1.14 --- CCursor.vb 1 Nov 2004 00:10:50 -0000 1.13 +++ CCursor.vb 9 Nov 2004 11:46:04 -0000 1.14 @@ -261,7 +261,7 @@ _alias = mr.getObjectAlias(injObj, offset) clMap = pbroker.getClassMap(obj.GetType) If Not m_holdsProxies Then - clMap.retrieveObject(clMap, injObj, m_row, _alias) + clMap.populateObject(clMap, injObj, m_row, _alias) If clMap.AssociationMapCount > 0 Then injObj.AssociationsLoaded = False Else @@ -270,7 +270,7 @@ pbroker.InjectedObjects.Add(injObj) Else 'need to retrieve the proxy and then load the object - clMap.retrieveProxy(injObj, m_row, _alias) + clMap.populateProxy(injObj, m_row, _alias) pbroker.retrieveObject(injObj, False, True) pbroker.InjectedObjects.Add(injObj) End If @@ -280,7 +280,7 @@ clMap = pbroker.getClassMap(obj.GetType) If Not m_holdsProxies Then - clMap.retrieveObject(injObj, m_row) + clMap.populateObject(injObj, m_row) If clMap.AssociationMapCount > 0 Then injObj.AssociationsLoaded = False Else @@ -289,7 +289,7 @@ pbroker.InjectedObjects.Add(injObj) Else 'need to retrieve the proxy and then load the object - clMap.retrieveProxy(injObj, m_row) + clMap.populateProxy(injObj, m_row) pbroker.retrieveObject(injObj, False, True) pbroker.InjectedObjects.Add(injObj) End If @@ -334,7 +334,7 @@ _alias = cm.getObjectAlias(obj, offset) clMap = obj.getClassMap If Not m_holdsProxies Then - clMap.retrieveObject(clMap, obj, m_row, _alias) + clMap.populateObject(clMap, obj, m_row, _alias) If obj.getClassMap().AssociationMapCount > 0 Then obj.AssociationsLoaded = False Else @@ -342,7 +342,7 @@ End If Else 'need to retrieve the proxy and then load the object - clMap.retrieveProxy(obj, m_row, _alias) + clMap.populateProxy(obj, m_row, _alias) obj.Retrieve() End If Exit Sub @@ -350,7 +350,7 @@ End If If Not m_holdsProxies Then - obj.getClassMap().retrieveObject(obj, m_row) + obj.getClassMap().populateObject(obj, m_row) If obj.getClassMap().AssociationMapCount > 0 Then obj.AssociationsLoaded = False Else @@ -358,7 +358,7 @@ End If Else 'need to retrieve the proxy and then load the object - obj.getClassMap(obj).retrieveProxy(obj, m_row) + obj.getClassMap(obj).populateProxy(obj, m_row) obj.Retrieve() End If End Sub @@ -400,14 +400,14 @@ _alias = cm.getObjectAlias(obj, offset) clMap = obj.getClassMap If Not m_holdsProxies Then - clMap.retrieveObject(clMap, obj, m_row, _alias) + clMap.populateObject(clMap, obj, m_row, _alias) obj.IsDirty = False broker.addToCache(obj) broker.retrieveAssociations(obj, obj.getClassMap(obj).RelationalDatabase.getConnection(Nothing), m_classMap, True) obj.IsProxy = False broker.addToCache(obj) Else - clMap.retrieveProxy(obj, m_row, _alias) + clMap.populateProxy(obj, m_row, _alias) obj.Retrieve() End If Exit Sub @@ -416,7 +416,7 @@ 'TO DO: Handle errors If Not m_holdsProxies Then - obj.getClassMap(obj).retrieveObject(obj, m_row) + obj.getClassMap(obj).populateObject(obj, m_row) obj.IsDirty = False 'Clear the dirty flag after initial loading of the object 'Add object to cache broker.addToCache(obj) @@ -426,7 +426,7 @@ broker.addToCache(obj) Else 'need to retrieve the proxy and then load the object - obj.getClassMap(obj).retrieveProxy(obj, m_row) + obj.getClassMap(obj).populateProxy(obj, m_row) obj.Retrieve() End If End Sub @@ -467,13 +467,13 @@ cm = m_parentCriteria _alias = cm.getObjectAlias(injObj, offset) clMap = pbroker.getClassMap(obj.GetType) - clMap.retrieveProxy(injObj, m_row, _alias) + clMap.populateProxy(injObj, m_row, _alias) Exit Sub End If End If clMap = pbroker.getClassMap(obj.GetType) - clMap.retrieveProxy(injObj, m_row) + clMap.populateProxy(injObj, m_row) End Sub @@ -488,12 +488,12 @@ cm = m_parentCriteria _alias = cm.getObjectAlias(obj, offset) clMap = obj.getClassMap - clMap.retrieveProxy(obj, m_row, _alias) + clMap.populateProxy(obj, m_row, _alias) Exit Sub End If End If - obj.getClassMap(obj).retrieveProxy(obj, m_row) + obj.getClassMap(obj).populateProxy(obj, m_row) End Sub Index: CClassMap.vb =================================================================== RCS file: /cvsroot/jcframework/dotnet/CClassMap.vb,v retrieving revision 1.42 retrieving revision 1.43 diff -u -d -r1.42 -r1.43 --- CClassMap.vb 2 Nov 2004 05:36:13 -0000 1.42 +++ CClassMap.vb 9 Nov 2004 11:46:04 -0000 1.43 @@ -1382,13 +1382,13 @@ ''' [rbanks] 27/11/2003 Created ''' </history> '''----------------------------------------------------------------------------- - Public Sub retrieveObject(ByRef obj As IPersistableObject, ByVal rs As CResultset) + Public Sub populateObject(ByRef obj As IPersistableObject, ByVal rs As CResultset) Dim tm As CTableMap Dim ClassMap As CClassMap ClassMap = Me Do tm = ClassMap.Tables.Item(1) - Call retrieveObject(ClassMap, obj, rs, tm.Name) + Call populateObject(ClassMap, obj, rs, tm.Name) ClassMap = ClassMap.SuperClass Loop While Not ClassMap Is Nothing obj.IsDirty = False @@ -1414,17 +1414,29 @@ ''' </history> '''----------------------------------------------------------------------------- - Public Sub retrieveObject(ByRef cm As CClassMap, ByRef obj As IPersistableObject, ByVal rs As CResultset, ByVal pAlias As String) + Public Sub populateObject(ByRef cm As CClassMap, ByRef obj As IPersistableObject, ByVal rs As CResultset, ByVal pAlias As String) + Call populateObject(cm, obj, rs, pAlias, False, Nothing) + End Sub + Public Sub populateObject(ByRef cm As CClassMap, ByRef obj As IPersistableObject, ByVal rs As CResultset, ByVal pAlias As String, ByVal checkForDuplicateAttributes As Boolean, ByVal classMapToCheck As CClassMap) Dim i As Short Dim AttrMap As CAttributeMap Dim val As Object Dim rw As DataRow + Dim skipAttribute As Boolean rw = rs.ResultSet.Tables(0).Rows(0) For i = 1 To cm.getSize AttrMap = cm.getAttributeMap(i) + skipAttribute = False + If checkForDuplicateAttributes Then + Try + If Not classMapToCheck.getAttributeMapByString(AttrMap.Name, False) Is Nothing Then + skipAttribute = True + End If + Catch + End Try + End If 'Attempt to load column via alias first, then table qualified name then column name - 'find the correct variation of the column name in the row and the retrieve the value val = Nothing Try @@ -1462,13 +1474,13 @@ ''' [rbanks] 27/11/2003 Created ''' </history> '''----------------------------------------------------------------------------- - Public Sub retrieveObject(ByRef obj As IPersistableObject, ByVal rw As DataRow) + Public Sub populateObject(ByRef obj As IPersistableObject, ByVal rw As DataRow) Dim tm As CTableMap Dim ClassMap As CClassMap ClassMap = Me Do tm = ClassMap.Tables.Item(1) - Call retrieveObject(ClassMap, obj, rw, tm.Name) + Call populateObject(ClassMap, obj, rw, tm.Name) ClassMap = ClassMap.SuperClass Loop While Not ClassMap Is Nothing obj.IsDirty = False @@ -1493,8 +1505,12 @@ ''' [rbanks] 27/11/2003 Created ''' </history> '''----------------------------------------------------------------------------- - Public Sub retrieveObject(ByRef ClassMap As CClassMap, ByRef obj As IPersistableObject, ByVal rw As DataRow, ByVal pAlias As String) + Public Sub populateObject(ByRef ClassMap As CClassMap, ByRef obj As IPersistableObject, ByVal rw As DataRow, ByVal pAlias As String) + Call populateObject(ClassMap, obj, rw, pAlias, False, Nothing) + End Sub + Public Sub populateObject(ByRef ClassMap As CClassMap, ByRef obj As IPersistableObject, ByVal rw As DataRow, ByVal pAlias As String, ByVal checkForDuplicateAttributes As Boolean, ByVal classMapToCheck As CClassMap) Dim tmpObj As Object + Dim skipAttribute As Boolean If obj Is Nothing Then Throw New RetrieveException("Source object not instantiated yet") End If @@ -1503,7 +1519,15 @@ For i = 1 To ClassMap.getSize AttrMap = ClassMap.getAttributeMap(i) 'Attempt to load column via alias first, then table qualified name then column name - + skipAttribute = False + If checkForDuplicateAttributes Then + Try + If Not classMapToCheck.getAttributeMapByString(AttrMap.Name, False) Is Nothing Then + skipAttribute = True + End If + Catch + End Try + End If tmpObj = Nothing Try If rw.Table.Columns.Contains(AttrMap.ColumnMap.getAliasName(pAlias)) Then @@ -1535,10 +1559,10 @@ ''' [rbanks] 27/11/2003 Created ''' </history> '''----------------------------------------------------------------------------- - Public Sub retrieveProxy(ByRef obj As IPersistableObject, ByVal rw As DataRow) + Public Sub populateProxy(ByRef obj As IPersistableObject, ByVal rw As DataRow) Dim tm As CTableMap tm = obj.GetClassMap.Tables.Item(1) - Call retrieveProxy(obj, rw, tm.Name) + Call populateProxy(obj, rw, tm.Name) End Sub '''----------------------------------------------------------------------------- @@ -1554,7 +1578,7 @@ ''' [rbanks] 27/11/2003 Created ''' </history> '''----------------------------------------------------------------------------- - Public Sub retrieveProxy(ByRef obj As IPersistableObject, ByVal rw As DataRow, ByVal pAlias As String) + Public Sub populateProxy(ByRef obj As IPersistableObject, ByVal rw As DataRow, ByVal pAlias As String) Dim ClassMap As CClassMap Dim tmpObj As Object If obj Is Nothing Then Index: CXMLConfigLoader.vb =================================================================== RCS file: /cvsroot/jcframework/dotnet/CXMLConfigLoader.vb,v retrieving revision 1.28 retrieving revision 1.29 diff -u -d -r1.28 -r1.29 --- CXMLConfigLoader.vb 2 Nov 2004 05:36:13 -0000 1.28 +++ CXMLConfigLoader.vb 9 Nov 2004 11:46:04 -0000 1.29 @@ -294,11 +294,22 @@ Else If Not attrClassNameSpace Is Nothing Then ClassMap.SuperClass = m_classMap.Item(ClassMap.ClassNameSpace & "." & attrSuperClassName.Value) - ClassMap.SuperClassNameSpace = attrClassNameSpace.Value + If ClassMap.SuperClass Is Nothing Then + ClassMap.SuperClass = m_classMap.Item(attrSuperClassName.Value) + Else + ClassMap.SuperClassNameSpace = attrClassNameSpace.Value + End If Else ClassMap.SuperClass = m_classMap.Item(attrSuperClassName.Value) End If End If + If ClassMap.SuperClass Is Nothing Then + If attrSuperClassNameSpace Is Nothing Then + Throw New XMLMappingException([String].Format("Could not find superclass with name {0}", attrSuperClassName.Value)) + Else + Throw New XMLMappingException([String].Format("Could not find superclass with name {0} and namespace {1}", attrSuperClassName.Value, attrSuperClassNameSpace.Value)) + End If + End If ClassMap.SuperClass.addChildrenMap(ClassMap) If Not attrSharedValue Is Nothing Then ClassMap.SharedTableValue = attrSharedValue.Value |