From: Richard B. <rb...@us...> - 2004-11-01 00:11:03
|
Update of /cvsroot/jcframework/dotnet In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23410 Modified Files: AFCustomAttributes.vb CClassMap.vb CConnection.vb CCursor.vb CPersistenceBroker.vb CUDAMap.vb CXMLConfigLoader.vb Log Message: Lazy loading Usage: For XML Mappings: change retrieveAutomatic="true" to retrieveAutomatic="lazy" in assocation definitions For attribute based mappings, add "LazyLoad:=True" to AFAssociation attribute. Also corrected problem in getTableSchema if a table is locked Index: CPersistenceBroker.vb =================================================================== RCS file: /cvsroot/jcframework/dotnet/CPersistenceBroker.vb,v retrieving revision 1.74 retrieving revision 1.75 diff -u -d -r1.74 -r1.75 --- CPersistenceBroker.vb 27 Oct 2004 07:38:48 -0000 1.74 +++ CPersistenceBroker.vb 1 Nov 2004 00:10:50 -0000 1.75 @@ -397,7 +397,13 @@ End If obj.SetAttributeValue(udamap.Target, targetobj.GetSourceObject) If Not targetobj.AssociationsLoaded Then - retrievePrivateObject(targetobj, conn, False, False) + 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 CCacheKey(targetobj) @@ -422,7 +428,13 @@ m_cache.Add(targetobj) End If If Not targetobj.AssociationsLoaded Then - retrievePrivateObject(targetobj, conn, False, False) + 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 CCacheKey(targetobj) @@ -445,7 +457,13 @@ m_cache.Add(targetobj) End If If Not targetobj.AssociationsLoaded Then - retrievePrivateObject(targetobj, conn, False, False) + 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 CCacheKey(targetobj) @@ -489,7 +507,13 @@ If Not gotValue Then If Not targetobj.AssociationsLoaded Then - retrievePrivateObject(targetobj, conn, False, False) + 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 CCacheKey(targetobj) @@ -527,7 +551,13 @@ Next If Not gotValue Then If Not targetobj.AssociationsLoaded Then - retrievePrivateObject(targetobj, conn, False, False) + 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 CCacheKey(targetobj) @@ -575,43 +605,43 @@ ''' [rbanks] 16/12/2003 Created ''' </history> '''----------------------------------------------------------------------------- - Friend Sub retrieveAssociations(ByRef obj As CPersistentObject, ByVal conn As _CConnection, ByVal cm As CClassMap, ByVal useCache As Boolean) + Friend Sub retrieveAssociations(ByRef obj As IPersistableObject, ByVal conn As _CConnection, ByVal cm As CClassMap, ByVal useCache As Boolean) Dim j, i, k As Short Dim colCriteriaParameters As New Collection Dim udaMap As CUDAMap Dim aCriteria As CRetrieveCriteria Dim cursor As CCursor - Dim Value As CPersistentObject + Dim Value As IPersistableObject Dim ValueObj As Object Dim ValueVar As String Dim tmpOIDValue As String Dim gotValue As Boolean - Dim col As CPersistentCollection + Dim col As IList Dim myKeys(cm.AssociationMaps.Count) As String cm.AssociationMaps.Keys.CopyTo(myKeys, 0) - Dim anObjPers As CPersistentObject + Dim anObjPers As IPersistableObject For i = 0 To cm.AssociationMaps.Count - 1 udaMap = cm.AssociationMaps.Item(myKeys(i)) If udaMap.RetrieveAutomatic Then aCriteria = New CRetrieveCriteria aCriteria.ClassMap = udaMap.ForClass If udaMap.Cardinality = CUDAMap.CardinalityEnum.ONE_TO_ONE Then - Value = obj.getObjectByAttribute(udaMap.Target) + Value = obj.GetObjectByAttribute(udaMap.Target) gotValue = False If Not Value Is Nothing Then 'Need to know if returned object is persistent and has a legitimate key - If Value.hasValidKey Then - anObjPers = m_cache.Item(Value) - If anObjPers Is Nothing Then - retrieveObject(Value, False, False) - Else - Value = anObjPers - End If - Value.IsDirty = False - Value.OriginalCacheKey = New CCacheKey(Value) - obj.setAttributeValue(udaMap.Target, Value.GetSourceObject) - gotValue = True + 'If Value.hasValidKey Then + anObjPers = m_cache.Item(Value) + If anObjPers Is Nothing Then + retrieveObject(Value, False, False) + Else + Value = anObjPers End If + Value.IsDirty = False + Value.OriginalCacheKey = New CCacheKey(Value) + obj.SetAttributeValue(udaMap.Target, Value.GetSourceObject) + gotValue = True + 'End If End If If Not gotValue Then 'Object doesn't exist - let's create it @@ -619,16 +649,12 @@ If Not Value Is Nothing Then 'Loop through fields in the association For j = 1 To udaMap.getSize - ValueObj = obj.getValueByAttribute(udaMap.getEntry(j).FromAttrMap.Name) + ValueObj = obj.GetValueByAttribute(udaMap.getEntry(j).FromAttrMap.Name) If Not ValueObj Is Nothing Then - Value.setAttributeValue(udaMap.getEntry(j).ToAttrMap.Name, ValueObj) + Value.SetAttributeValue(udaMap.getEntry(j).ToAttrMap.Name, ValueObj) End If Next j - 'If useCache And m_useCache Then anObjPers = m_cache.Item(Value) - 'Else - ' anObjPers = Nothing - 'End If If anObjPers Is Nothing Then retrieveObject(Value, False, False) Else @@ -636,35 +662,36 @@ End If Value.IsDirty = False 'After populating a new object Value.OriginalCacheKey = New CCacheKey(Value) - obj.setAttributeValue(udaMap.Target, Value.GetSourceObject) + obj.SetAttributeValue(udaMap.Target, Value.GetSourceObject) End If End If ElseIf udaMap.Cardinality = CUDAMap.CardinalityEnum.ONE_TO_MANY Then For j = 1 To udaMap.getSize - ValueVar = cm.getValueForRelationalDatabase(obj.getValueByAttribute(udaMap.getEntry(j).FromAttrMap.Name)) + ValueVar = cm.getValueForRelationalDatabase(obj.GetValueByAttribute(udaMap.getEntry(j).FromAttrMap.Name)) aCriteria.WhereCondition.addSelectEqualTo(udaMap.getEntry(j).ToAttrMap.Name, ValueVar) - ' colCriteriaParameters.Add(ValueVar) Next j + aCriteria.ReturnFullObjects = Not udaMap.LazyLoad cursor = processCriteria(aCriteria, colCriteriaParameters, conn) - col = obj.getCollectionByAttribute(udaMap.Target) + col = obj.GetCollectionByAttribute(udaMap.Target) If col Is Nothing Then - Throw New RetrieveException("Collection " & udaMap.Target & " is not initialised for " & obj.GetType.ToString) + Throw New RetrieveException("Collection " & udaMap.Target & " is not initialised for " & obj.GetObjectType.ToString) End If col.Clear() 'Clear the collection before polpulating, just to be sure - Value = udaMap.ForClass.CreateObjectInstance While cursor.hasElements And Not cursor.EOF - anObjPers = Value.getNewObject - cursor.loadObject(anObjPers) - 'recursive call to retrieve any further auto objects - retrieveAssociations(anObjPers, conn, anObjPers.getClassMap(anObjPers), useCache) + anObjPers = Value + If udaMap.LazyLoad Then + cursor.loadProxy(anObjPers.GetSourceObject) + Else + cursor.loadObject(anObjPers.GetSourceObject) + retrieveAssociations(anObjPers, conn, anObjPers.GetClassMap, useCache) + End If anObjPers.IsDirty = False 'After populating a new object anObjPers.OriginalCacheKey = New CCacheKey(anObjPers) - col.Add(anObjPers) + col.Add(anObjPers.GetSourceObject) m_cache.Add(anObjPers) 'Add retrieved objects to the cache cursor.nextCursor() End While - 'col.Remove((1)) End If End If Next i @@ -698,7 +725,7 @@ SyncLock GetType(CPersistenceBroker) Dim conn As _CConnection Dim cm As CClassMap - cm = obj.getClassMap + cm = obj.GetClassMap conn = cm.RelationalDatabase.getConnection(Nothing) Try conn.startTransaction() @@ -747,7 +774,7 @@ Dim statement As CSqlStatement Dim rs As CResultset - clMap = obj.getClassMap + clMap = obj.GetClassMap cm = clMap 'Clear dirty flag so that recursion in the class structure doesn't cause an infinite loop obj.IsDirty = False @@ -761,8 +788,8 @@ statement = cm.getInsertSqlFor(obj) conn.processStatement(statement) If cm.getIdentitySize > 0 Then - If CInt(cm.RelationalDatabase.getValueFor(obj.getValueByAttribute(cm.getIdentityAttributeMap(1).Name))) = 0 Then - obj.setAttributeValue(cm.getIdentityAttributeMap(1).Name, cm.RelationalDatabase.getIdentityValue(conn)) + If CInt(cm.RelationalDatabase.getValueFor(obj.GetValueByAttribute(cm.getIdentityAttributeMap(1).Name))) = 0 Then + obj.SetAttributeValue(cm.getIdentityAttributeMap(1).Name, cm.RelationalDatabase.getIdentityValue(conn)) End If End If End If @@ -816,7 +843,7 @@ SyncLock GetType(CPersistenceBroker) Dim cm As CClassMap Dim x As DeleteException - cm = obj.getClassMap + cm = obj.GetClassMap Dim conn As _CConnection conn = cm.RelationalDatabase.getConnection(Nothing) conn.startTransaction() @@ -872,7 +899,7 @@ '''----------------------------------------------------------------------------- Private Sub deletePrivateObject(ByRef obj As IPersistableObject, ByVal conn As _CConnection, ByVal deleteSuperClass As Boolean) Dim clMap As CClassMap - clMap = obj.getClassMap + clMap = obj.GetClassMap Dim cm As CClassMap cm = clMap @@ -895,7 +922,7 @@ If udaMap.DeleteAutomatic Then For j = 1 To udaMap.getSize If udaMap.Cardinality = CUDAMap.CardinalityEnum.ONE_TO_ONE Then - Value = obj.getObjectByAttribute(udaMap.Target) + Value = obj.GetObjectByAttribute(udaMap.Target) If Not Value Is Nothing Then If retrieveObject(Value, False, True) Then 'If Value.Retrieve() Then @@ -903,7 +930,7 @@ End If End If ElseIf udaMap.Cardinality = CUDAMap.CardinalityEnum.ONE_TO_MANY Then - col = obj.getCollectionByAttribute(udaMap.Target) + col = obj.GetCollectionByAttribute(udaMap.Target) If Not col Is Nothing Then For k = 0 To col.Count - 1 Value = col.Item(k) @@ -927,7 +954,7 @@ cm = cm.SuperClass If Not cm Is Nothing Then 'delete super class and its associations - Value = obj.getObjectByClassMap(cm) + Value = obj.GetObjectByClassMap(cm) If retrieveObject(Value, False, True) Then 'If Value.Retrieve() Then deletePrivateObject(Value, conn, True) @@ -1720,6 +1747,7 @@ Dim cc As Collection Dim colMap As CColumnMap Dim refAttr As CAttributeMap + Dim x As XMLMappingException Try 'get all the types from the assembly. @@ -1766,8 +1794,16 @@ relDb = m_databases.Item(dbMap.Name) If Not relDb Is Nothing Then conn = relDb.getConnection(relDb) - dt = conn.getTableSchema(tblMap.Name) - conn.CloseConnection() + Try + dt = conn.getTableSchema(tblMap.Name) + Catch ex As Exception + x = New XMLMappingException("Schema for table " & tblMap.Name & " could not be read. Check table exists and that you have permissions to access it.", ex) + Finally + conn.CloseConnection() + If Not x Is Nothing Then + Throw x + End If + End Try Dim myfield As DataRow Dim myproperty As DataColumn @@ -1953,6 +1989,10 @@ udaAm.DeleteAutomatic = afAssociation.Delete udaAm.SaveAutomatic = afAssociation.Save udaAm.RetrieveAutomatic = afAssociation.Retrieve + udaAm.LazyLoad = afAssociation.LazyLoad + If udaAm.LazyLoad = True And udaAm.RetrieveAutomatic = False Then + udaAm.RetrieveAutomatic = True + End If If afAssociation.Name Is Nothing OrElse afAssociation.Name = [String].Empty Then udaAm.Name = udaAm.Target Else @@ -2045,6 +2085,7 @@ Next 'Not any of the childrens, so check classMap + obj = classMap.CreateObjectInstance 'Retrieve superclass details first Index: CCursor.vb =================================================================== RCS file: /cvsroot/jcframework/dotnet/CCursor.vb,v retrieving revision 1.12 retrieving revision 1.13 diff -u -d -r1.12 -r1.13 --- CCursor.vb 20 Oct 2004 06:44:23 -0000 1.12 +++ CCursor.vb 1 Nov 2004 00:10:50 -0000 1.13 @@ -442,10 +442,42 @@ ''' [rbanks] 4/12/2003 Created ''' </history> '''----------------------------------------------------------------------------- - Public Sub loadProxy(ByRef obj As CPersistentObject) - loadProxy(obj, 0) + Public Sub loadProxy(ByRef obj As Object) + If obj.GetType.IsSubclassOf(GetType(CPersistentObject)) OrElse TypeOf (obj) Is CPersistentObject Then + loadPersistentProxy(obj, 0) + Else + loadProxy(obj, 0) + End If End Sub - Public Sub loadProxy(ByRef obj As CPersistentObject, ByVal offset As Integer) + Public Sub loadProxy(ByRef obj As Object, ByVal offset As Integer) + If obj.GetType.IsSubclassOf(GetType(CPersistentObject)) OrElse TypeOf (obj) Is CPersistentObject Then + loadPersistentProxy(obj, offset) + Exit Sub + End If + + Dim _alias As String = "" + Dim cm As CMultiRetrieveCriteria + Dim clMap As CClassMap + Dim pbroker As CPersistenceBroker = modPersistenceBrokerSingleton.getPersistenceBrokerInstance + Dim injObj As CInjectedObject + + injObj = pbroker.LocateOrCreateInjObject(obj) + If Not m_parentCriteria Is Nothing Then + If m_parentCriteria.GetType Is GetType(CMultiRetrieveCriteria) Then + cm = m_parentCriteria + _alias = cm.getObjectAlias(injObj, offset) + clMap = pbroker.getClassMap(obj.GetType) + clMap.retrieveProxy(injObj, m_row, _alias) + Exit Sub + End If + End If + + clMap = pbroker.getClassMap(obj.GetType) + clMap.retrieveProxy(injObj, m_row) + + End Sub + + Public Sub loadPersistentProxy(ByRef obj As CPersistentObject, ByVal offset As Integer) Dim _alias As String = "" Dim cm As CMultiRetrieveCriteria @@ -465,6 +497,7 @@ End Sub + '''----------------------------------------------------------------------------- ''' <summary> ''' Advances the cursor to the next CResultset position. Index: CXMLConfigLoader.vb =================================================================== RCS file: /cvsroot/jcframework/dotnet/CXMLConfigLoader.vb,v retrieving revision 1.26 retrieving revision 1.27 diff -u -d -r1.26 -r1.27 --- CXMLConfigLoader.vb 25 Oct 2004 07:12:32 -0000 1.26 +++ CXMLConfigLoader.vb 1 Nov 2004 00:10:51 -0000 1.27 @@ -362,7 +362,7 @@ Try dt = conn.getTableSchema(tblMap.Name) Catch ex As Exception - x = New XMLMappingException("Database table " & tblMap.Name & " does not exist", ex) + x = New XMLMappingException("Schema for table " & tblMap.Name & " could not be read. Check table exists and that you have permissions to access it.", ex) Finally conn.CloseConnection() If Not x Is Nothing Then @@ -535,6 +535,7 @@ Dim attrFromClassNameSpace As XmlAttribute Dim attrToClassNameSpace As XmlAttribute Dim keyStr As String + Dim tmpStr As String attrFromClass = node.GetAttributeNode("fromClass") attrToClass = node.GetAttributeNode("toClass") @@ -572,13 +573,23 @@ udaAm.Target = attrTarget.Value udaAm.DeleteAutomatic = node.GetAttributeNode("deleteAutomatic").Value udaAm.SaveAutomatic = node.GetAttributeNode("saveAutomatic").Value - udaAm.RetrieveAutomatic = node.GetAttributeNode("retrieveAutomatic").Value + tmpStr = node.GetAttributeNode("retrieveAutomatic").Value + If UCase(tmpStr) = "TRUE" OrElse UCase(tmpStr) = "LAZY" Then + udaAm.RetrieveAutomatic = True + If tmpStr = "lazy" Then + udaAm.LazyLoad = True + End If + Else + udaAm.RetrieveAutomatic = False + End If If attrName Is Nothing Then udaAm.Name = udaAm.Target Else udaAm.Name = attrName.Value End If - udaAm.Inverse = node.GetAttributeNode("inverse").Value + If Not node.GetAttribute("inverse") Is Nothing Then + udaAm.Inverse = node.GetAttributeNode("inverse").Value + End If If Not attrCardinality Is Nothing Then If UCase(attrCardinality.Value) = "ONETOONE" Then udaAm.Cardinality = CUDAMap.CardinalityEnum.ONE_TO_ONE Index: CConnection.vb =================================================================== RCS file: /cvsroot/jcframework/dotnet/CConnection.vb,v retrieving revision 1.27 retrieving revision 1.28 diff -u -d -r1.27 -r1.28 --- CConnection.vb 18 Oct 2004 03:31:51 -0000 1.27 +++ CConnection.vb 1 Nov 2004 00:10:50 -0000 1.28 @@ -590,6 +590,7 @@ dt = dr.GetSchemaTable Catch ex As Exception dt = Nothing + Throw ex End Try Return dt End Function @@ -1077,6 +1078,7 @@ dt = dr.GetSchemaTable Catch ex As Exception dt = Nothing + Throw ex End Try Return dt End Function @@ -1562,6 +1564,7 @@ dt = dr.GetSchemaTable Catch ex As Exception dt = Nothing + Throw ex End Try Return dt End Function @@ -1981,6 +1984,7 @@ dt = dr.GetSchemaTable Catch ex As Exception dt = Nothing + Throw ex End Try Return dt End Function Index: AFCustomAttributes.vb =================================================================== RCS file: /cvsroot/jcframework/dotnet/AFCustomAttributes.vb,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- AFCustomAttributes.vb 20 Oct 2004 22:29:00 -0000 1.7 +++ AFCustomAttributes.vb 1 Nov 2004 00:10:35 -0000 1.8 @@ -564,7 +564,8 @@ Private attrName As String Private attrDeleteAutomatic As Boolean Private attrSaveAutomatic As Boolean - Private attrRetrieveAutomatic As Boolean + Private attrRetrieveAutomatic As Boolean + Private attrLazyLoad As Boolean ''' ----------------------------------------------------------------------------- ''' <summary> @@ -726,6 +727,28 @@ attrRetrieveAutomatic = Value End Set End Property + + ''' ----------------------------------------------------------------------------- + ''' <summary> + ''' Indicates that proxy objects should be retrieved when an object's + ''' associated objects are retrieved. + ''' </summary> + ''' <returns></returns> + ''' <remarks> + ''' </remarks> + ''' <history> + ''' [rbanks] 19/05/2004 Created + ''' </history> + ''' ----------------------------------------------------------------------------- + Public Property LazyLoad() As Boolean + Get + Return attrLazyLoad + End Get + Set(ByVal Value As Boolean) + attrLazyLoad = Value + End Set + End Property + End Class ''' ----------------------------------------------------------------------------- @@ -746,80 +769,80 @@ ''' ----------------------------------------------------------------------------- <AttributeUsage(AttributeTargets.Class, allowmultiple:=True)> _ Public Class AFAssociationEntryAttribute - Inherits System.Attribute + Inherits System.Attribute - Private attrAFAssociation As String - Private attrFromProperty As String - Private attrToProperty As String + Private attrAFAssociation As String + Private attrFromProperty As String + Private attrToProperty As String - ''' ----------------------------------------------------------------------------- - ''' <summary> - ''' Constructor to define a property pairing for use by an association - ''' </summary> - ''' <param name="AFAssociationName">The association to be used</param> - ''' <param name="FromProperty">The property in the current class</param> - ''' <param name="ToProperty">The target property in the target class</param> - ''' <remarks> - ''' </remarks> - ''' <history> - ''' [rbanks] 19/05/2004 Created - ''' </history> - ''' ----------------------------------------------------------------------------- - Public Sub New(ByVal AFAssociationName As String, ByVal FromProperty As String, ByVal ToProperty As String) - attrAFAssociation = AFAssociationName - attrFromProperty = FromProperty - attrToProperty = ToProperty - End Sub + ''' ----------------------------------------------------------------------------- + ''' <summary> + ''' Constructor to define a property pairing for use by an association + ''' </summary> + ''' <param name="AFAssociationName">The association to be used</param> + ''' <param name="FromProperty">The property in the current class</param> + ''' <param name="ToProperty">The target property in the target class</param> + ''' <remarks> + ''' </remarks> + ''' <history> + ''' [rbanks] 19/05/2004 Created + ''' </history> + ''' ----------------------------------------------------------------------------- + Public Sub New(ByVal AFAssociationName As String, ByVal FromProperty As String, ByVal ToProperty As String) + attrAFAssociation = AFAssociationName + attrFromProperty = FromProperty + attrToProperty = ToProperty + End Sub - ''' ----------------------------------------------------------------------------- - ''' <summary> - ''' ReadOnly. The name of the association this pairing belongs to. - ''' </summary> - ''' <returns></returns> - ''' <remarks> - ''' </remarks> - ''' <history> - ''' [rbanks] 19/05/2004 Created - ''' </history> - ''' ----------------------------------------------------------------------------- - Public ReadOnly Property AFAssociationName() As String - Get - Return attrAFAssociation - End Get - End Property + ''' ----------------------------------------------------------------------------- + ''' <summary> + ''' ReadOnly. The name of the association this pairing belongs to. + ''' </summary> + ''' <returns></returns> + ''' <remarks> + ''' </remarks> + ''' <history> + ''' [rbanks] 19/05/2004 Created + ''' </history> + ''' ----------------------------------------------------------------------------- + Public ReadOnly Property AFAssociationName() As String + Get + Return attrAFAssociation + End Get + End Property - ''' ----------------------------------------------------------------------------- - ''' <summary> - ''' ReadOnly. The name of a property in this class. - ''' </summary> - ''' <returns></returns> - ''' <remarks> - ''' </remarks> - ''' <history> - ''' [rbanks] 19/05/2004 Created - ''' </history> - ''' ----------------------------------------------------------------------------- - Public ReadOnly Property FromProperty() As String - Get - Return attrFromProperty - End Get - End Property + ''' ----------------------------------------------------------------------------- + ''' <summary> + ''' ReadOnly. The name of a property in this class. + ''' </summary> + ''' <returns></returns> + ''' <remarks> + ''' </remarks> + ''' <history> + ''' [rbanks] 19/05/2004 Created + ''' </history> + ''' ----------------------------------------------------------------------------- + Public ReadOnly Property FromProperty() As String + Get + Return attrFromProperty + End Get + End Property - ''' ----------------------------------------------------------------------------- - ''' <summary> - ''' ReadOnly. The name of a property in the target class. - ''' </summary> - ''' <returns></returns> - ''' <remarks> - ''' </remarks> - ''' <history> - ''' [rbanks] 19/05/2004 Created - ''' </history> - ''' ----------------------------------------------------------------------------- - Public ReadOnly Property ToProperty() As String - Get - Return attrToProperty - End Get - End Property + ''' ----------------------------------------------------------------------------- + ''' <summary> + ''' ReadOnly. The name of a property in the target class. + ''' </summary> + ''' <returns></returns> + ''' <remarks> + ''' </remarks> + ''' <history> + ''' [rbanks] 19/05/2004 Created + ''' </history> + ''' ----------------------------------------------------------------------------- + Public ReadOnly Property ToProperty() As String + Get + Return attrToProperty + End Get + End Property End Class \ No newline at end of file Index: CUDAMap.vb =================================================================== RCS file: /cvsroot/jcframework/dotnet/CUDAMap.vb,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- CUDAMap.vb 21 Jul 2004 02:55:38 -0000 1.6 +++ CUDAMap.vb 1 Nov 2004 00:10:51 -0000 1.7 @@ -61,6 +61,7 @@ Private m_entries As Collection Private m_inverse As Boolean Private m_name As String + Private m_lazyLoad As Boolean '''----------------------------------------------------------------------------- ''' <summary> @@ -174,6 +175,29 @@ '''----------------------------------------------------------------------------- ''' <summary> + ''' The association will retrieve proxy versions of the target object(s) when the source object is retrieved. + ''' </summary> + ''' <value>True if the proxy versions of the target objects should be retrieved when the source object is + ''' retrieved.</value> + ''' <remarks>When the source object is retrieved any target objects will also be retrieved. + ''' <para>This property in conjuntion with the DeleteAutomatic and SaveAutomatic + ''' properties can be used to implement object aggregations and compostions</para> + ''' </remarks> + ''' <history> + ''' [rbanks] 18/12/2003 Created + ''' </history> + '''----------------------------------------------------------------------------- + Public Property LazyLoad() As Boolean + Get + Return m_lazyLoad + End Get + Set(ByVal Value As Boolean) + m_lazyLoad = Value + End Set + End Property + + '''----------------------------------------------------------------------------- + ''' <summary> ''' The from class of the association (the "from" class) ''' </summary> ''' <value>The class map of the from class</value> Index: CClassMap.vb =================================================================== RCS file: /cvsroot/jcframework/dotnet/CClassMap.vb,v retrieving revision 1.38 retrieving revision 1.39 diff -u -d -r1.38 -r1.39 --- CClassMap.vb 28 Oct 2004 00:16:11 -0000 1.38 +++ CClassMap.vb 1 Nov 2004 00:10:50 -0000 1.39 @@ -1803,6 +1803,8 @@ Dim de As DictionaryEntry Dim isfirst As Boolean = True Dim am As CAttributeMap + Dim baseTables As Integer + Dim currentIndex As Integer rMaps.Add("t1", Me) m_joinSet = New CJoin(Me, "t1") @@ -1820,6 +1822,7 @@ cm3 = cm2 cm2 = cm2.SuperClass End While + baseTables = classMapCount For Each de In Me.AssociationMaps udamap = de.Value If udamap.RetrieveAutomatic Then @@ -1836,15 +1839,18 @@ statement.addSqlClause(Me.RelationalDatabase.getClauseStringSelect & " ") For Each de In rMaps cm2 = de.Value + currentIndex = CInt(Mid(de.Key, 2)) 'Load each individual column, and process in order of objects being joined For i = 1 To cm2.getSize - If isfirst Then - isfirst = False - Else - statement.addSqlClause(", ") + If currentIndex < baseTables OrElse cm2.getAttributeMap(i).IsProxy Then + If isfirst Then + isfirst = False + Else + statement.addSqlClause(", ") + End If + statement.addSqlClause(cm2.getAttributeMap(i).ColumnMap.getAliasQualifiedName(de.Key) & _ + Me.RelationalDatabase.getClauseStringAs & cm2.getAttributeMap(i).ColumnMap.getAliasName(de.Key)) End If - statement.addSqlClause(cm2.getAttributeMap(i).ColumnMap.getAliasQualifiedName(de.Key) & _ - Me.RelationalDatabase.getClauseStringAs & cm2.getAttributeMap(i).ColumnMap.getAliasName(de.Key)) Next i Next statement.addSqlClause(" " & Me.RelationalDatabase.getClauseStringFrom & " ") @@ -1924,6 +1930,8 @@ Dim de As DictionaryEntry Dim isfirst As Boolean = True Dim am As CAttributeMap + Dim baseTables As Integer + Dim currentIndex As Integer rMaps.Add("t1", Me) 'Joins are not depending on method used for retrieve (ie find or retrieve) so don't @@ -1943,6 +1951,7 @@ cm3 = cm2 cm2 = cm2.SuperClass End While + baseTables = classMapCount For Each de In Me.AssociationMaps udamap = de.Value If udamap.RetrieveAutomatic Then @@ -1959,15 +1968,18 @@ statement.addSqlClause(Me.RelationalDatabase.getClauseStringSelect & " ") For Each de In rMaps cm2 = de.Value + currentIndex = CInt(Mid(de.Key, 2)) 'Load each individual column, and process in order of objects being joined For i = 1 To cm2.getSize - If isfirst Then - isfirst = False - Else - statement.addSqlClause(", ") + If currentIndex < baseTables OrElse cm2.getAttributeMap(i).IsProxy Then + If isfirst Then + isfirst = False + Else + statement.addSqlClause(", ") + End If + statement.addSqlClause(cm2.getAttributeMap(i).ColumnMap.getAliasQualifiedName(de.Key) & _ + Me.RelationalDatabase.getClauseStringAs & cm2.getAttributeMap(i).ColumnMap.getAliasName(de.Key)) End If - statement.addSqlClause(cm2.getAttributeMap(i).ColumnMap.getAliasQualifiedName(de.Key) & _ - Me.RelationalDatabase.getClauseStringAs & cm2.getAttributeMap(i).ColumnMap.getAliasName(de.Key)) Next i Next statement.addSqlClause(" " & Me.RelationalDatabase.getClauseStringFrom & " ") |