You can subscribe to this list here.
2004 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(56) |
Nov
(13) |
Dec
(36) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2005 |
Jan
(7) |
Feb
(55) |
Mar
(33) |
Apr
(71) |
May
(12) |
Jun
|
Jul
(5) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: Richard B. <rb...@us...> - 2004-11-03 01:31:08
|
Update of /cvsroot/jcframework/dotnet In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23381 Modified Files: CCacheEntry.vb Log Message: Fixed further issues with cache referencing Index: CCacheEntry.vb =================================================================== RCS file: /cvsroot/jcframework/dotnet/CCacheEntry.vb,v retrieving revision 1.20 retrieving revision 1.21 diff -u -d -r1.20 -r1.21 --- CCacheEntry.vb 1 Nov 2004 21:28:02 -0000 1.20 +++ CCacheEntry.vb 3 Nov 2004 01:30:58 -0000 1.21 @@ -877,8 +877,14 @@ Private Function GetCachedObject(ByVal ce As CCacheEntry) As IPersistableObject If m_objectsLoading Then - Debug.WriteLine(" - returning original object " & ce.PersistentObject.GetObjectType.Name) - Return ce.OriginalObject + 'If the object is already fully loaded and is persistent then I can return a copy instead of the original + If ce.PersistentObject.AssociationsLoaded And ce.PersistentObject.Persistent Then + Debug.WriteLine(" - returning copy of object " & ce.PersistentObject.GetObjectType.Name) + Return ce.PersistentObject.Copy + Else + Debug.WriteLine(" - returning original object " & ce.PersistentObject.GetObjectType.Name) + Return ce.OriginalObject + End If Else Debug.WriteLine(" - returning copy of object " & ce.PersistentObject.GetObjectType.Name) Return ce.PersistentObject.Copy @@ -901,7 +907,7 @@ pObj = ce.PersistentObject ck = x.Key outString &= i.ToString & ">" & ce.ToString & vbCrLf & _ - i.ToString & " (Cache Key)>" & ck.ToString & vbCrLf + i.ToString & " (Cache Key)>" & ck.ToString & vbCrLf i += 1 Next x outString &= ">>>> END CACHE DUMP <<<<" |
From: Richard B. <rb...@us...> - 2004-11-02 05:36:23
|
Update of /cvsroot/jcframework/dotnet In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20314 Modified Files: CClassMap.vb CPersistenceBroker.vb CPersistentCriteria.vb CXMLConfigLoader.vb Log Message: Fixed problem with ProcessDirectSQL when using namespaces Fixed issues with shared tables and SQL generation Index: CPersistenceBroker.vb =================================================================== RCS file: /cvsroot/jcframework/dotnet/CPersistenceBroker.vb,v retrieving revision 1.76 retrieving revision 1.77 diff -u -d -r1.76 -r1.77 --- CPersistenceBroker.vb 1 Nov 2004 21:28:02 -0000 1.76 +++ CPersistenceBroker.vb 2 Nov 2004 05:36:13 -0000 1.77 @@ -1502,6 +1502,7 @@ Dim am As CAttributeMap Dim i As Integer Dim preString, postString As String + Dim tmpStr As String clauses = Split(inSQL) Try @@ -1527,24 +1528,45 @@ Loop If subclause.IndexOf(".") > 0 Then objString = Split(subclause, ".") - Try - clMap = Me.getClassMap(objString(0)) - Catch ex As Exception - Throw New NoClassMapException("Unknown class in SQL statement: " & subclause) - End Try + tmpStr = "" + For i = 0 To objString.Length - 2 + If tmpStr.Length > 0 Then tmpStr &= "." + tmpStr &= objString(i) + Try + clMap = Me.getClassMap(tmpStr) + Catch ex As Exception + End Try + Next If clMap Is Nothing Then - Throw New NoClassMapException("Unknown class in SQL statement: " & subclause) - End If - If firstClassMap Is Nothing Then firstClassMap = clMap - Try - am = clMap.getAttributeMapByString(objString(1), True) - Catch - Throw New NoAttributeMapException("Could not find attribute map for: " & subclause) - End Try - If am Is Nothing Then - Throw New NoAttributeMapException("Could not find attribute map for: " & subclause) + 'See if subclause is a class name + Try + clMap = Me.getClassMap(subclause) + Catch + Throw New NoClassMapException("Unknown class in SQL statement: " & subclause) + End Try + If firstClassMap Is Nothing Then firstClassMap = clMap + Dim t As CTableMap + Try + t = clMap.Tables(1) + Catch + Throw New NoTableMapException("Could not load table map for " & subclause) + End Try + If t Is Nothing Then + Throw New NoTableMapException("Could not load table map for " & subclause) + End If + subclause = t.Name + Else + If firstClassMap Is Nothing Then firstClassMap = clMap + Try + am = clMap.getAttributeMapByString(objString(objString.Length - 1), True) + Catch + Throw New NoAttributeMapException("Could not find attribute map for: " & subclause) + End Try + If am Is Nothing Then + Throw New NoAttributeMapException("Could not find attribute map for: " & subclause) + End If + subclause = am.ColumnMap.getFullyQualifiedName End If - subclause = am.ColumnMap.getFullyQualifiedName Else Try clMap = Me.getClassMap(subclause) Index: CPersistentCriteria.vb =================================================================== RCS file: /cvsroot/jcframework/dotnet/CPersistentCriteria.vb,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- CPersistentCriteria.vb 28 Oct 2004 00:16:12 -0000 1.9 +++ CPersistentCriteria.vb 2 Nov 2004 05:36:13 -0000 1.10 @@ -153,6 +153,10 @@ cm = m_classMap Do Tables.Add(cm.Tables.Item(1)) + While Not cm Is Nothing AndAlso Not cm.SharedTableValue Is Nothing + 'Need to skip parents of shared table classes + cm = cm.SuperClass + End While cm = cm.SuperClass Loop While Not cm Is Nothing criCond = New CCriteriaCondition @@ -198,7 +202,7 @@ persistentBroker = getPersistenceBrokerInstance() m_className = pClassName - m_classMap = persistentBroker.getClassMap(m_className) + Me.ClassMap = persistentBroker.getClassMap(m_className) End Sub '''----------------------------------------------------------------------------- @@ -230,6 +234,7 @@ Public Sub fillStatementWithWhere(ByRef statement As CSqlStatement) Implements _CPersistentCriteria.fillStatementWithWhere Dim inheritedAssoc As String Dim clauseConditionAdded As Boolean = False + Dim cm As CClassMap inheritedAssoc = Me.ClassMap.getInheritedAssociations If inheritedAssoc Is Nothing Then @@ -256,7 +261,19 @@ End If End If WhereCondition.fillStatement(statement) + clauseConditionAdded = True End If + cm = Me.ClassMap + While Not cm Is Nothing + If Not cm.SharedTableValue Is Nothing Then + If clauseConditionAdded Then + statement.addSqlClause(" " & cm.RelationalDatabase.getClauseStringAnd & " ") + clauseConditionAdded = True + End If + statement.addSqlClause(CType(cm.Tables(1), CTableMap).Name & "." & cm.SharedTableField & cm.RelationalDatabase.getClauseStringEqualTo(cm.RelationalDatabase.getValueFor(cm.SharedTableValue))) + End If + cm = cm.SuperClass + End While End Sub '''----------------------------------------------------------------------------- Index: CXMLConfigLoader.vb =================================================================== RCS file: /cvsroot/jcframework/dotnet/CXMLConfigLoader.vb,v retrieving revision 1.27 retrieving revision 1.28 diff -u -d -r1.27 -r1.28 --- CXMLConfigLoader.vb 1 Nov 2004 00:10:51 -0000 1.27 +++ CXMLConfigLoader.vb 2 Nov 2004 05:36:13 -0000 1.28 @@ -606,8 +606,16 @@ attrFromAttribute = elementChild.GetAttributeNode("fromAttribute") attrToAttribute = elementChild.GetAttributeNode("toAttribute") If ((Not attrFromAttribute Is Nothing) And (Not attrToAttribute Is Nothing)) Then - amFromAttribute = fromClassMap.getAttributeMapByString(attrFromAttribute.Value, False) - amToAttribute = toClassMap.getAttributeMapByString(attrToAttribute.Value, False) + If fromClassMap.SharedTableValue Is Nothing Then + amFromAttribute = fromClassMap.getAttributeMapByString(attrFromAttribute.Value, False) + Else + amFromAttribute = fromClassMap.getAttributeMapByString(attrFromAttribute.Value, True) + End If + If toClassMap.SharedTableValue Is Nothing Then + amToAttribute = toClassMap.getAttributeMapByString(attrToAttribute.Value, False) + Else + amToAttribute = toClassMap.getAttributeMapByString(attrToAttribute.Value, True) + End If If amFromAttribute Is Nothing Then Throw New XMLMappingException("Error in association definition") End If @@ -624,7 +632,7 @@ End If udaAm.addEntry(entry) End If - End If + End If End If nodeChild = nodeChild.NextSibling Loop Index: CClassMap.vb =================================================================== RCS file: /cvsroot/jcframework/dotnet/CClassMap.vb,v retrieving revision 1.41 retrieving revision 1.42 diff -u -d -r1.41 -r1.42 --- CClassMap.vb 1 Nov 2004 21:28:02 -0000 1.41 +++ CClassMap.vb 2 Nov 2004 05:36:13 -0000 1.42 @@ -999,10 +999,11 @@ statement.addSqlClause(", ") End If statement.addSqlClause(ClassMap.getAttributeMap(i).ColumnMap.getFullyQualifiedName) - ' statement.addSqlClause(ClassMap.getAttributeMap(i).ColumnMap.getFullyQualifiedName & _ - ' Me.RelationalDatabase.getClauseStringAs & ClassMap.getAttributeMap(i).ColumnMap.getFullyQualifiedName) End If Next i + While Not ClassMap Is Nothing AndAlso Not ClassMap.SharedTableValue Is Nothing + ClassMap = ClassMap.SuperClass + End While ClassMap = ClassMap.SuperClass Loop While Not ClassMap Is Nothing getSelectSql = statement @@ -1282,7 +1283,7 @@ End If m_updateWhereParamPosition = Me.getSize For Each AttrMap In Me.AttributeMaps - If AttrMap.ColumnMap.IsIdentity OrElse (Not Me.SharedTableValue Is Nothing AndAlso AttrMap.AttributeMap Is Nothing) Then + If AttrMap.ColumnMap.IsIdentity OrElse (Not Me.SharedTableValue Is Nothing AndAlso Not AttrMap.AttributeMap Is Nothing) Then m_updateWhereParamPosition -= 1 End If Next |
From: Richard B. <rb...@us...> - 2004-11-01 21:28:19
|
Update of /cvsroot/jcframework/dotnet In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26918 Modified Files: CCacheEntry.vb CClassMap.vb CPersistenceBroker.vb CPersistentObject.vb IPersistentObject.vb Log Message: Fixed problem with cache and retrieving collections (was possible to change original cache entry after an object was loaded). Improved DumpCacheDetails output format as well. Also fixed potential problems with XML mappings of shared tables repeating the key fields from the parent. Index: CPersistenceBroker.vb =================================================================== RCS file: /cvsroot/jcframework/dotnet/CPersistenceBroker.vb,v retrieving revision 1.75 retrieving revision 1.76 diff -u -d -r1.75 -r1.76 --- CPersistenceBroker.vb 1 Nov 2004 00:10:50 -0000 1.75 +++ CPersistenceBroker.vb 1 Nov 2004 21:28:02 -0000 1.76 @@ -1305,30 +1305,7 @@ ''' </history> '''----------------------------------------------------------------------------- Public Function DumpCacheDetails() As String - Dim x As DictionaryEntry - Dim ce As CCacheEntry - Dim i As Integer - Dim t As Type - Dim outString As String - Dim obj As IPersistableObject - Dim ck As CCacheKey - - outString = ">>>> START CACHE DUMP <<<<" & vbCrLf - i = 1 - For Each x In m_cache - ce = x.Value - obj = ce.PersistentObject - t = obj.GetObjectType - ck = x.Key - outString &= i.ToString & "> " & t.ToString & " Dirty:" & obj.IsDirty.ToString & _ - " Persistent:" & obj.Persistent.ToString & _ - " Loading:" & obj.IsLoading.ToString & _ - " AssocationsLoaded:" & obj.AssociationsLoaded.ToString & _ - vbCrLf & ck.ToString & vbCrLf - i += 1 - Next x - outString &= ">>>> END CACHE DUMP <<<<" - Return outString + Return m_cache.ToString End Function '''----------------------------------------------------------------------------- Index: IPersistentObject.vb =================================================================== RCS file: /cvsroot/jcframework/dotnet/IPersistentObject.vb,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- IPersistentObject.vb 20 Oct 2004 06:44:23 -0000 1.5 +++ IPersistentObject.vb 1 Nov 2004 21:28:03 -0000 1.6 @@ -31,7 +31,6 @@ Sub ResetOriginalDates() Function GetObjectByClassMap(ByVal classMap As CClassMap) As IPersistableObject Function GetSourceObject() As Object - End Interface Public Interface IPersistentObject Index: CClassMap.vb =================================================================== RCS file: /cvsroot/jcframework/dotnet/CClassMap.vb,v retrieving revision 1.40 retrieving revision 1.41 diff -u -d -r1.40 -r1.41 --- CClassMap.vb 1 Nov 2004 04:08:23 -0000 1.40 +++ CClassMap.vb 1 Nov 2004 21:28:02 -0000 1.41 @@ -1163,12 +1163,18 @@ m_insertStatement.addSqlClause("(") isFirst = True For i = 1 To Me.getSize - If Not Me.getAttributeMap(i).ColumnMap.IsIdentity Then - If isFirst Then - m_insertStatement.addSqlClause(Me.getAttributeMap(i).ColumnMap.Name) - isFirst = False - Else - m_insertStatement.addSqlClause(", " & Me.getAttributeMap(i).ColumnMap.Name) + AttrMap = Me.getAttributeMap(i) + If Not AttrMap.ColumnMap.IsIdentity Then + 'Shared tables that are mapped with a reference field (ie repeat of the key) + 'should not have the extra key columns included. An attributemap on an attributemap + 'indicates that the attribute is a reference to the parent. + If Me.SharedTableValue Is Nothing OrElse AttrMap.AttributeMap Is Nothing Then + If isFirst Then + m_insertStatement.addSqlClause(AttrMap.ColumnMap.Name) + isFirst = False + Else + m_insertStatement.addSqlClause(", " & AttrMap.ColumnMap.Name) + End If End If End If Next i @@ -1187,11 +1193,13 @@ For i = 1 To Me.getSize AttrMap = Me.getAttributeMap(i) If Not AttrMap.ColumnMap.IsIdentity Then - If isFirst Then - m_insertStatement.addSqlClause(RelationalDatabase.getParamHolder(i)) - isFirst = False - Else - m_insertStatement.addSqlClause(", " & RelationalDatabase.getParamHolder(i)) + If Me.SharedTableValue Is Nothing OrElse AttrMap.AttributeMap Is Nothing Then + If isFirst Then + m_insertStatement.addSqlClause(RelationalDatabase.getParamHolder(i)) + isFirst = False + Else + m_insertStatement.addSqlClause(", " & RelationalDatabase.getParamHolder(i)) + End If End If End If Next i @@ -1211,7 +1219,9 @@ For i = 1 To Me.getSize AttrMap = Me.getAttributeMap(i) If Not AttrMap.ColumnMap.IsIdentity Then - m_insertStatement.addSqlParameter(i, obj.GetValueByAttribute(AttrMap.Name), AttrMap.ColumnMap) + If Me.SharedTableValue Is Nothing OrElse AttrMap.AttributeMap Is Nothing Then + m_insertStatement.addSqlParameter(i, obj.GetValueByAttribute(AttrMap.Name), AttrMap.ColumnMap) + End If End If Next i If Not Me.SharedTableValue Is Nothing Then @@ -1253,30 +1263,41 @@ 'add each field m_updateStatement.addSqlClause(RelationalDatabase.getClauseStringSet & " ") isFirst = True - For i = 1 To Me.getSize - AttrMap = Me.getAttributeMap(i) + i = 0 + For Each AttrMap In Me.AttributeMaps If Not AttrMap.ColumnMap.IsIdentity Then - If Not isFirst Then - m_updateStatement.addSqlClause(", " & Me.getAttributeMap(i).ColumnMap.Name & "=" & m_relationalDatabase.getParamHolder(i)) - Else - 'This is the first attribute - m_updateStatement.addSqlClause("" & Me.getAttributeMap(i).ColumnMap.Name & "=" & m_relationalDatabase.getParamHolder(i)) - isFirst = False + If Me.SharedTableValue Is Nothing OrElse AttrMap.AttributeMap Is Nothing Then + i += 1 + If Not isFirst Then + m_updateStatement.addSqlClause(", " & AttrMap.ColumnMap.Name & "=" & m_relationalDatabase.getParamHolder(i)) + Else + 'This is the first attribute + m_updateStatement.addSqlClause("" & AttrMap.ColumnMap.Name & "=" & m_relationalDatabase.getParamHolder(i)) + isFirst = False + End If End If End If - Next i + Next m_sqlUpdateStub = m_updateStatement.SqlString End If m_updateWhereParamPosition = Me.getSize + For Each AttrMap In Me.AttributeMaps + If AttrMap.ColumnMap.IsIdentity OrElse (Not Me.SharedTableValue Is Nothing AndAlso AttrMap.AttributeMap Is Nothing) Then + m_updateWhereParamPosition -= 1 + End If + Next 'Add Parameter values - For i = 1 To Me.getSize - AttrMap = Me.getAttributeMap(i) + i = 0 + For Each AttrMap In Me.AttributeMaps If Not AttrMap.ColumnMap.IsIdentity Then - m_updateStatement.addSqlParameter(i, obj.GetValueByAttribute(AttrMap.Name), AttrMap.ColumnMap) + If Me.SharedTableValue Is Nothing OrElse AttrMap.AttributeMap Is Nothing Then + i += 1 + m_updateStatement.addSqlParameter(i, obj.GetValueByAttribute(AttrMap.Name), AttrMap.ColumnMap) + End If End If - Next i - paramCount = Me.getSize + Next + paramCount = i 'Add WHERE clause m_updateStatement.addSqlClause(" " & RelationalDatabase.getClauseStringWhere & " ") isFirst = True @@ -1289,13 +1310,11 @@ If Not obj.OriginalCacheKey Is Nothing Then For i = 1 To Me.getKeySize AttrMap = Me.getKeyAttributeMap(i) - 'keyValuesCol.Add(m_relationalDatabase.getValueFor(obj.OriginalCacheKey.GetKeyValue(i))) keyValuesCol.Add(obj.OriginalCacheKey.GetKeyValue(i)) Next Else For i = 1 To Me.getKeySize AttrMap = Me.getKeyAttributeMap(i) - 'keyValuesCol.Add(m_relationalDatabase.getValueFor(obj.getValueByAttribute(AttrMap.Name))) keyValuesCol.Add(obj.GetValueByAttribute(AttrMap.Name)) Next End If @@ -1304,12 +1323,8 @@ AttrMap = Me.getKeyAttributeMap(i) paramCount += 1 If Not isFirst Then - 'm_updateStatement.addSqlClause(" " & RelationalDatabase.getClauseStringAnd & " " & AttrMap.ColumnMap.getFullyQualifiedName & m_relationalDatabase.getClauseStringEqualTo(m_relationalDatabase.getValueFor(keyValuesCol.Item(i)))) - 'm_updateStatement.addSqlClause(" " & RelationalDatabase.getClauseStringAnd & " " & AttrMap.ColumnMap.getFullyQualifiedName & "=" & m_relationalDatabase.getParamHolder(paramCount)) m_updateStatement.addSqlClause(" " & RelationalDatabase.getClauseStringAnd) End If - 'm_updateStatement.addSqlClause("" & AttrMap.ColumnMap.getFullyQualifiedName & m_relationalDatabase.getClauseStringEqualTo(m_relationalDatabase.getValueFor(keyValuesCol.Item(i)))) - 'm_updateStatement.addSqlClause(AttrMap.ColumnMap.getFullyQualifiedName & "=" & m_relationalDatabase.getParamHolder(paramCount)) m_updateStatement.addSqlClause(" " & AttrMap.ColumnMap.getFullyQualifiedName & m_relationalDatabase.getClauseStringEqualTo("_" & paramCount.ToString & "_")) isFirst = False m_updateStatement.addSqlParameter(paramCount, keyValuesCol.Item(i), AttrMap.ColumnMap) @@ -1326,8 +1341,6 @@ 'process timestamp attributes If Me.getAttributeMap(i).isTimeStamp Then paramCount += 1 - 'm_updateStatement.addSqlClause(" " & RelationalDatabase.getClauseStringAnd & " " & Me.getAttributeMap(i).ColumnMap.getFullyQualifiedName & m_relationalDatabase.getClauseStringEqualTo(m_relationalDatabase.getValueFor(obj.getValueByAttribute("Original" & Me.getAttributeMap(i).Name)))) - 'm_updateStatement.addSqlClause(" " & RelationalDatabase.getClauseStringAnd & " " & Me.getAttributeMap(i).ColumnMap.getFullyQualifiedName & "=" & m_relationalDatabase.getParamHolder(paramCount)) m_updateStatement.addSqlClause(" " & RelationalDatabase.getClauseStringAnd & " " & Me.getAttributeMap(i).ColumnMap.getFullyQualifiedName & m_relationalDatabase.getClauseStringEqualTo("_" & paramCount.ToString & "_")) m_updateStatement.addSqlParameter(paramCount, obj.GetValueByAttribute("Original" & Me.getAttributeMap(i).Name), Me.getAttributeMap(i).ColumnMap) End If Index: CCacheEntry.vb =================================================================== RCS file: /cvsroot/jcframework/dotnet/CCacheEntry.vb,v retrieving revision 1.19 retrieving revision 1.20 diff -u -d -r1.19 -r1.20 --- CCacheEntry.vb 15 Oct 2004 06:42:55 -0000 1.19 +++ CCacheEntry.vb 1 Nov 2004 21:28:02 -0000 1.20 @@ -126,6 +126,82 @@ Friend Sub resetExpiry(ByVal lifetime As Double) m_expiryTime = DateAdd(DateInterval.Minute, lifetime, Now) End Sub + + Public Overrides Function ToString() As String + Dim s As String + Dim i As Short + Dim indent As Integer + Dim formatString As String + + Dim cm As CClassMap + Dim am As CAttributeMap + Dim x As Object + Dim y As Object + Dim xstring As String + Dim ystring As String + + If m_object Is Nothing Then + Return "No persistent object" + End If + + s = m_object.GetObjectType.Name & ": " + indent = s.Length + If m_object.IsDirty Then + s &= "Dirty" + Else + s &= "Not Dirty" + End If + If m_object.Persistent Then + s &= ", Persistent" + Else + s &= ", NonPersistent" + End If + If m_object.IsLoading Then + s &= ", Loading" + Else + s &= ", Loaded" + End If + If m_object.AssociationsLoaded Then + s &= ", Assoc. Loaded" + Else + s &= ", No Assoc. Loaded" + End If + s &= vbCrLf + formatString = Space(indent) & "{0,-9}" & vbTab & "{1,-13}" & vbTab & "{2,-13}" & vbCrLf + s &= [String].Format(formatString, "Attribute", "Current Value", "Original Value") + s &= [String].Format(formatString, "---------", "-------------", "--------------") + i = 0 + cm = m_object.GetClassMap() + For i = 1 To cm.getKeySize + am = cm.getKeyAttributeMap(i) + x = m_object.GetValueByAttribute(am.Name) + Try + xstring = x.ToString + Catch ex As Exception + If x Is Nothing Then + xstring = "Nothing" + Else + xstring = "Unprintable" + End If + End Try + Try + If m_originalObject Is Nothing Then + ystring = "N/A" + Else + y = m_originalObject.GetValueByAttribute(am.Name) + ystring = y.ToString + End If + Catch ex As Exception + If y Is Nothing Then + ystring = "Nothing" + Else + ystring = "Unprintable" + End If + End Try + s &= [String].Format(formatString, am.Name, xstring, ystring) + Next + Return s + End Function End Class '''----------------------------------------------------------------------------- @@ -186,10 +262,10 @@ m_keyvalues = New Collection m_type = obj.GetObjectType m_hasLegitValues = True - cm = obj.getClassMap + cm = obj.GetClassMap For i = 1 To cm.getKeySize am = cm.getKeyAttributeMap(i) - x = obj.getValueByAttribute(am.Name) + x = obj.GetValueByAttribute(am.Name) 'Keys cannot have entries set to nothing If x Is Nothing Then m_hasLegitValues = False @@ -395,7 +471,7 @@ s = s & vbTab & i.ToString & ") " & obj.GetType.ToString & ": " & obj.ToString Catch x As Exception If obj Is Nothing Then - s = s & vbTab & i.ToString & ") --Null Reference--: " & "unprintable data" + s = s & vbTab & i.ToString & ") --Null Reference--: " & "Nothing" Else s = s & vbTab & i.ToString & ") " & obj.GetType.ToString & ": " & "unprintable data" End If @@ -477,7 +553,7 @@ Else ce.resetExpiry(m_expiryInterval) End If - If obj.getClassMap.RelationalDatabase.getConnection(Nothing).Started Then + If obj.GetClassMap.RelationalDatabase.getConnection(Nothing).Started Then ce.TransactionType = CCacheEntry.CacheTransaction.Saved ce.CopyObject() End If @@ -497,7 +573,7 @@ End If ce.PersistentObject = obj.Copy ce.OriginalObject = obj - If obj.getClassMap.RelationalDatabase.getConnection(Nothing).Started Then + If obj.GetClassMap.RelationalDatabase.getConnection(Nothing).Started Then ce.TransactionType = CCacheEntry.CacheTransaction.Added End If MyBase.Add(ckey, ce) @@ -529,7 +605,7 @@ Dim t As Type Dim interval As Double - cm = obj.getClassMap + cm = obj.GetClassMap 'Debug.WriteLine("Cache - Attempt to Find() <" & cm.Name & "> object in cache") @@ -554,7 +630,7 @@ found = True For i = 1 To cm.getFindSize attrmap = cm.FindAttributeMaps(i) - If obj.getValueByAttribute(attrmap.Name) <> ce.PersistentObject.getValueByAttribute(attrmap.Name) Then + If obj.GetValueByAttribute(attrmap.Name) <> ce.PersistentObject.GetValueByAttribute(attrmap.Name) Then found = False Exit For End If @@ -669,7 +745,7 @@ Exit Sub End If 'Debug.WriteLine("Cache - Delete object with keys:" & vbCrLf & ckey.ToString) - If obj.getClassMap.RelationalDatabase.getConnection(Nothing).Started Then + If obj.GetClassMap.RelationalDatabase.getConnection(Nothing).Started Then ce = MyBase.Item(ckey) If Not (ce Is Nothing) Then ce.TransactionType = CCacheEntry.CacheTransaction.Deleted @@ -724,7 +800,7 @@ ce = x.Value If (ce.TransactionType = CCacheEntry.CacheTransaction.Saved Or _ ce.TransactionType = CCacheEntry.CacheTransaction.Added) _ - AndAlso ce.PersistentObject.getClassMap.RelationalDatabase Is reldb Then + AndAlso ce.PersistentObject.GetClassMap.RelationalDatabase Is reldb Then ce.TransactionType = CCacheEntry.CacheTransaction.None End If Next @@ -732,7 +808,7 @@ 'Now look for cache entries to be deleted and remove them For Each x In Me ce = x.Value - If ce.TransactionType = CCacheEntry.CacheTransaction.Deleted AndAlso ce.PersistentObject.getClassMap.RelationalDatabase Is reldb Then + If ce.TransactionType = CCacheEntry.CacheTransaction.Deleted AndAlso ce.PersistentObject.GetClassMap.RelationalDatabase Is reldb Then al.Add(New CCacheKey(ce.PersistentObject)) End If Next @@ -750,11 +826,11 @@ For Each x In Me ce = x.Value 'Lets cancel deletes first - just means resetting transaction to None - If ce.TransactionType = CCacheEntry.CacheTransaction.Deleted AndAlso ce.PersistentObject.getClassMap.RelationalDatabase Is reldb Then + If ce.TransactionType = CCacheEntry.CacheTransaction.Deleted AndAlso ce.PersistentObject.GetClassMap.RelationalDatabase Is reldb Then ce.TransactionType = CCacheEntry.CacheTransaction.None End If 'Now look for cache entries to be saved and restore them - If ce.TransactionType = CCacheEntry.CacheTransaction.Saved AndAlso ce.PersistentObject.getClassMap.RelationalDatabase Is reldb Then + If ce.TransactionType = CCacheEntry.CacheTransaction.Saved AndAlso ce.PersistentObject.GetClassMap.RelationalDatabase Is reldb Then ce.RestoreObject() ce.TransactionType = CCacheEntry.CacheTransaction.None End If @@ -763,7 +839,7 @@ 'Now look for cache entries to be removed and get rid of them For Each x In Me ce = x.Value - If ce.TransactionType = CCacheEntry.CacheTransaction.Added AndAlso ce.PersistentObject.getClassMap.RelationalDatabase Is reldb Then + If ce.TransactionType = CCacheEntry.CacheTransaction.Added AndAlso ce.PersistentObject.GetClassMap.RelationalDatabase Is reldb Then al.Add(New CCacheKey(ce.PersistentObject)) End If Next @@ -777,6 +853,24 @@ Return m_objectsLoading End Get Set(ByVal Value As Boolean) + If m_objectsLoading And Value = False Then + 'we are turning off the objects loading flag. + 'When this flag is on, references to the original object are returned + 'so that collections can be populated properly, etc. Which means that + 'at this point in time it is quite likely that some collections have + 'direct references to the original object of a cache entry and could easily + 'change that value (which should not happen). + ' For this reason we need to now go through each cache entry and copy the + 'current original_object over the top of itself. Collections will still + 'be referencing a proper and valid object, but changing it will not then + 'affect the contents of the cache. + Debug.WriteLine("Cache: ObjectsLoading turned off so now resetting m_originalobject for all cache entries") + Dim ce As CCacheEntry + For Each de As DictionaryEntry In Me + ce = de.Value + ce.OriginalObject = ce.OriginalObject.Copy + Next de + End If m_objectsLoading = Value End Set End Property @@ -790,4 +884,28 @@ Return ce.PersistentObject.Copy End If End Function + + Public Overrides Function ToString() As String + Dim x As DictionaryEntry + Dim ce As CCacheEntry + Dim i As Integer + Dim t As Type + Dim outString As String + Dim pObj As IPersistableObject + Dim ck As CCacheKey + + outString = ">>>> START CACHE DUMP <<<<" & vbCrLf + i = 1 + For Each x In Me + ce = x.Value + pObj = ce.PersistentObject + ck = x.Key + outString &= i.ToString & ">" & ce.ToString & vbCrLf & _ + i.ToString & " (Cache Key)>" & ck.ToString & vbCrLf + i += 1 + Next x + outString &= ">>>> END CACHE DUMP <<<<" + Return outString + + End Function End Class \ No newline at end of file Index: CPersistentObject.vb =================================================================== RCS file: /cvsroot/jcframework/dotnet/CPersistentObject.vb,v retrieving revision 1.48 retrieving revision 1.49 diff -u -d -r1.48 -r1.49 --- CPersistentObject.vb 27 Oct 2004 07:38:48 -0000 1.48 +++ CPersistentObject.vb 1 Nov 2004 21:28:03 -0000 1.49 @@ -1819,4 +1819,5 @@ Public Function GetSourceObject() As Object Implements IPersistableObject.GetSourceObject Return Me End Function + End Class |
From: Richard B. <rb...@us...> - 2004-11-01 21:27:27
|
Update of /cvsroot/jcframework/Nunit/InheritedClasses In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26746/InheritedClasses Modified Files: AtomsFrameworkTests.vb CSharedClasses.vb SharedTests.vb TableA_B.vb Log Message: New tests to check cache behaviour for collections, and shared table classes that repeat XML information from the parent. Index: CSharedClasses.vb =================================================================== RCS file: /cvsroot/jcframework/Nunit/InheritedClasses/CSharedClasses.vb,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- CSharedClasses.vb 19 Oct 2004 00:13:38 -0000 1.1 +++ CSharedClasses.vb 1 Nov 2004 21:27:10 -0000 1.2 @@ -3,6 +3,7 @@ Namespace InheritedClasses Public Class SharedParent Inherits CPersistentObject + Private _field1 As String Public Overrides Function getNewObject() As AToMSFramework.CPersistentObject Return New SharedParent @@ -11,15 +12,35 @@ Public Overrides Function IsValid() As Boolean Return True End Function + + Public Property Field1() As String + Get + Return _field1 + End Get + Set(ByVal Value As String) + _field1 = Value + SetDirtyFlag() + End Set + End Property End Class Public Class SharedChild Inherits SharedParent + Private _field2 As String + Public Overrides Function getNewObject() As AToMSFramework.CPersistentObject Return New SharedChild End Function + Public Property Field2() As String + Get + Return _field2 + End Get + Set(ByVal Value As String) + _field2 = Value + End Set + End Property End Class End Namespace \ No newline at end of file Index: SharedTests.vb =================================================================== RCS file: /cvsroot/jcframework/Nunit/InheritedClasses/SharedTests.vb,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- SharedTests.vb 25 Oct 2004 07:14:15 -0000 1.3 +++ SharedTests.vb 1 Nov 2004 21:27:10 -0000 1.4 @@ -43,6 +43,8 @@ Dim origOid As String = String.Empty Dim newOid As String = String.Empty sc.IsDirty = True + sc.Field1 = "a" + sc.Field2 = "b" sc.Save() origOid = sc.OIDValue sc = New SharedChild @@ -61,11 +63,14 @@ Dim result As Boolean Dim origOid As String = String.Empty sc.IsDirty = True + sc.Field1 = "xx" + sc.Field2 = "yy" sc.Save() origOid = sc.OIDValue sp.OIDValue = origOid result = sp.Retrieve() Assert.IsTrue(sp.OIDValue = origOid) + Assert.AreEqual("xx", sp.Field1) Assert.IsTrue(result) Assert.IsFalse(sp.IsDirty) Assert.IsFalse(sp.GetType Is GetType(SharedChild)) Index: TableA_B.vb =================================================================== RCS file: /cvsroot/jcframework/Nunit/InheritedClasses/TableA_B.vb,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- TableA_B.vb 21 Oct 2004 23:36:46 -0000 1.2 +++ TableA_B.vb 1 Nov 2004 21:27:10 -0000 1.3 @@ -26,7 +26,7 @@ End Set End Property - Private _tableBCol As New CPersistentCollection + Private WithEvents _tableBCol As New CPersistentCollection Public Property TableBCollection() As CPersistentCollection Get Return _tableBCol @@ -53,6 +53,10 @@ Public Overrides Function IsValid() As Boolean Return True End Function + + Private Sub _tableBCol_ItemDirtied(ByVal sender As Object, ByVal e As System.EventArgs) Handles _tableBCol.ItemDirtied + Me.SetDirtyFlag() + End Sub End Class Public Class TableB Index: AtomsFrameworkTests.vb =================================================================== RCS file: /cvsroot/jcframework/Nunit/InheritedClasses/AtomsFrameworkTests.vb,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- AtomsFrameworkTests.vb 31 Oct 2004 23:08:36 -0000 1.5 +++ AtomsFrameworkTests.vb 1 Nov 2004 21:27:10 -0000 1.6 @@ -266,5 +266,60 @@ Assert.AreEqual(4, a.TableCCollection.Count) End Sub + <Test()> Public Sub CheckCacheBehaviour() + Dim a As New TableA + Dim b As New TableB + Dim c As New TableC + a.Id = "aaa" + b.Id = "bbb1" + b.TableA = a + a.TableBCollection.Add(b) + b = New TableB + b.Id = "bbb2" + b.TableA = a + a.TableBCollection.Add(b) + b = New TableB + b.Id = "bbb3" + b.TableA = a + a.TableBCollection.Add(b) + b = New TableB + b.Id = "bbb4" + b.TableA = a + a.TableBCollection.Add(b) + c = New TableC + c.Id = "ccc1" + c.TableA = a + a.TableCCollection.Add(c) + c = New TableC + c.Id = "ccc2" + c.TableA = a + a.TableCCollection.Add(c) + a.Save() + Assert.AreEqual(4, a.TableBCollection.Count) + Assert.AreEqual(2, a.TableCCollection.Count) + pbroker.ClearCache() + a = New TableA + a.Id = "aaa" + a.Retrieve(a) + Assert.AreEqual(4, a.TableBCollection.Count) + Assert.AreEqual(2, a.TableCCollection.Count) + b = a.TableBCollection(2) + b.field1 = "a3" + b.Id = "bbb5" + Debug.WriteLine(pbroker.DumpCacheDetails()) + a = New TableA + a.Id = "aaa" + a.Retrieve(a, False) + 'Bug existed where code above caused cached objects to change values + Assert.AreEqual("bbb3", CType(a.TableBCollection(2), TableB).Id) + a.field1 = "aa2" + a.Save() + a = New TableA + a.Id = "aaa" + a.Retrieve(a, False) + Assert.AreEqual(4, a.TableBCollection.Count) + Assert.AreEqual(2, a.TableCCollection.Count) + End Sub + End Class End Namespace \ No newline at end of file |
From: Richard B. <rb...@us...> - 2004-11-01 21:27:27
|
Update of /cvsroot/jcframework/Nunit In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26746 Modified Files: AtomsFramework.xml Nunit_AtomsFramework.vbproj original db1.mdb Log Message: New tests to check cache behaviour for collections, and shared table classes that repeat XML information from the parent. Index: Nunit_AtomsFramework.vbproj =================================================================== RCS file: /cvsroot/jcframework/Nunit/Nunit_AtomsFramework.vbproj,v retrieving revision 1.12 retrieving revision 1.13 diff -u -d -r1.12 -r1.13 --- Nunit_AtomsFramework.vbproj 31 Oct 2004 23:08:35 -0000 1.12 +++ Nunit_AtomsFramework.vbproj 1 Nov 2004 21:27:09 -0000 1.13 @@ -70,11 +70,6 @@ AssemblyName = "System.Xml" /> <Reference - Name = "AToMSFramework" - AssemblyName = "AToMSFramework" - HintPath = "..\Atoms_Framework\bin\AToMSFramework.dll" - /> - <Reference Name = "nunit.framework" AssemblyName = "nunit.framework" HintPath = "..\..\..\Program Files\NUnit 2.2\bin\nunit.framework.dll" @@ -90,6 +85,11 @@ AssemblyName = "System.Windows.Forms" HintPath = "..\..\..\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.Windows.Forms.dll" /> + <Reference + Name = "AToMSFramework" + Project = "{8FFD05CF-E733-4D8E-BC0E-D9DD37B87384}" + Package = "{F184B08F-C81C-45F6-A57F-5ABD9991F28F}" + /> </References> <Imports> <Import Namespace = "Microsoft.VisualBasic" /> Index: original db1.mdb =================================================================== RCS file: /cvsroot/jcframework/Nunit/original db1.mdb,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 Binary files /tmp/cvsOj2UxP and /tmp/cvsfw0Efh differ Index: AtomsFramework.xml =================================================================== RCS file: /cvsroot/jcframework/Nunit/AtomsFramework.xml,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -r1.11 -r1.12 --- AtomsFramework.xml 31 Oct 2004 23:08:35 -0000 1.11 +++ AtomsFramework.xml 1 Nov 2004 21:27:08 -0000 1.12 @@ -11,8 +11,13 @@ <attribute name="OIDValue" column="oid" key="primary"/> <attribute name="CreatedDate" column="created" timestamp="true"/> <attribute name="ModifiedDate" column="modified" timestamp="true"/> + <attribute name="Field1" column="field1" /> </class> +<!-- Proper XML mapping here would be to not have the OIDValue attribute since it + inherits from the parent class (for shared tables). It is here for testing only. --> <class name="SharedChild" table="SharedClasses" superclass="SharedParent" database="MSA" sharedtablefield="IType" sharedtablevalue="PLN" namespace="NunitTests.InheritedClasses"> + <attribute name="OIDValue" column="oid" key="primary" reference="OIDValue"/> + <attribute name="Field2" column="field2" /> </class> <class name="NPJob" table="NPJobs" database="MSA" namespace="NunitTests.StandardClasses"> |
From: Richard B. <rb...@us...> - 2004-11-01 04:08:33
|
Update of /cvsroot/jcframework/dotnet In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28472 Modified Files: CClassMap.vb modAliasNull.vb Log Message: DBNull was not being detected as a null alias UseANSINulls flag was being compared to false instead of true Index: modAliasNull.vb =================================================================== RCS file: /cvsroot/jcframework/dotnet/modAliasNull.vb,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- modAliasNull.vb 21 Jul 2004 02:55:38 -0000 1.4 +++ modAliasNull.vb 1 Nov 2004 04:08:23 -0000 1.5 @@ -79,11 +79,17 @@ Case VariantType.Byte If InValue = NULL_BYTE Then blnValue = True Case Else - If InValue Is Nothing Then blnValue = True + If InValue Is Nothing Then + blnValue = True + Else + If IsDBNull(InValue) Then + blnValue = True + End If + End If ' bytes and boleans 'Debug.Assert False End Select - IsNullAlias = blnValue + Return blnValue End Function Index: CClassMap.vb =================================================================== RCS file: /cvsroot/jcframework/dotnet/CClassMap.vb,v retrieving revision 1.39 retrieving revision 1.40 diff -u -d -r1.39 -r1.40 --- CClassMap.vb 1 Nov 2004 00:10:50 -0000 1.39 +++ CClassMap.vb 1 Nov 2004 04:08:23 -0000 1.40 @@ -794,7 +794,7 @@ For i = 1 To Me.getKeySize p = m_deleteStatement.Parameters.Item(i) If IsNullAlias(p.Value) Then - If Me.RelationalDatabase.UseANSINulls = False Then + If Me.RelationalDatabase.UseANSINulls = True Then x = x.Replace(" = _" & i.ToString & "_", " is NULL") p.Ignore = True Else @@ -1338,7 +1338,7 @@ For i = m_updateWhereParamPosition To m_updateStatement.Parameters.Count p = m_updateStatement.Parameters.Item(i) If IsNullAlias(p.Value) Then - If Me.RelationalDatabase.UseANSINulls = False Then + If Me.RelationalDatabase.UseANSINulls = True Then x = x.Replace(" = _" & i.ToString & "_", " is NULL") p.Ignore = True Else @@ -1803,8 +1803,6 @@ 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") @@ -1822,7 +1820,6 @@ cm3 = cm2 cm2 = cm2.SuperClass End While - baseTables = classMapCount For Each de In Me.AssociationMaps udamap = de.Value If udamap.RetrieveAutomatic Then @@ -1839,18 +1836,15 @@ 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 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)) + 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)) Next i Next statement.addSqlClause(" " & Me.RelationalDatabase.getClauseStringFrom & " ") @@ -1909,7 +1903,7 @@ For i = 1 To params.Count o = params.Item(i) If IsNullAlias(o.value) Then - If Me.RelationalDatabase.UseANSINulls = False Then + If Me.RelationalDatabase.UseANSINulls = True Then x = x.Replace(" = _" & i.ToString & "_", " is NULL") o.Ignore = True Else @@ -1930,8 +1924,6 @@ 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 @@ -1951,7 +1943,6 @@ cm3 = cm2 cm2 = cm2.SuperClass End While - baseTables = classMapCount For Each de In Me.AssociationMaps udamap = de.Value If udamap.RetrieveAutomatic Then @@ -1968,18 +1959,15 @@ 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 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)) + 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)) Next i Next statement.addSqlClause(" " & Me.RelationalDatabase.getClauseStringFrom & " ") |
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 & " ") |
From: Richard B. <rb...@us...> - 2004-10-31 23:08:47
|
Update of /cvsroot/jcframework/Nunit/StandardClasses In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11585/StandardClasses Modified Files: NonInheritedTests.vb Added Files: LazyEmployee.vb Log Message: Tests for lazy loading of objects in associations. Index: NonInheritedTests.vb =================================================================== RCS file: /cvsroot/jcframework/Nunit/StandardClasses/NonInheritedTests.vb,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- NonInheritedTests.vb 25 Oct 2004 07:14:15 -0000 1.3 +++ NonInheritedTests.vb 31 Oct 2004 23:08:36 -0000 1.4 @@ -211,5 +211,14 @@ Assert.AreEqual("slave", emp2.Name) End Sub + <Test()> Public Sub LazyLoadEmployees() + Dim emp1 As New LazyEmployee + emp1.Name = "aa" + pbroker.FindObject(emp1) + Assert.AreEqual("aa", emp1.Name) + Assert.AreEqual("ac", emp1.ReportsTo.Name) + Assert.AreEqual(emp1.ReportsToName, emp1.ReportsTo.Name) + Assert.AreEqual(0, emp1.ReportsTo.Workers.Count) + End Sub End Class End Namespace \ No newline at end of file --- NEW FILE: LazyEmployee.vb --- Namespace StandardClasses Public Class LazyEmployee Private m_name As String Private m_parentname As String Private m_parent As LazyEmployee Private m_children As ArrayList Private m_teamname As String Public Property Name() As String Get Return m_name End Get Set(ByVal Value As String) m_name = Value End Set End Property Public Property ReportsTo() As LazyEmployee Get Return m_parent End Get Set(ByVal Value As LazyEmployee) If Not Value Is Nothing Then m_parent = Value m_parentname = Value.Name End If End Set End Property Public Property ReportsToName() As String Get If m_parent Is Nothing Then Return m_parentname Else Return (m_parent.Name) End If End Get Set(ByVal Value As String) m_parentname = Value End Set End Property Public Property Workers() As ArrayList Get Return m_children End Get Set(ByVal Value As ArrayList) m_children = Value End Set End Property Public Sub New() MyBase.New() m_children = New ArrayList End Sub End Class End Namespace |
From: Richard B. <rb...@us...> - 2004-10-31 23:08:47
|
Update of /cvsroot/jcframework/Nunit In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11585 Modified Files: AtomsFramework.xml Nunit_AtomsFramework.vbproj Log Message: Tests for lazy loading of objects in associations. Index: Nunit_AtomsFramework.vbproj =================================================================== RCS file: /cvsroot/jcframework/Nunit/Nunit_AtomsFramework.vbproj,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -r1.11 -r1.12 --- Nunit_AtomsFramework.vbproj 25 Oct 2004 07:14:12 -0000 1.11 +++ Nunit_AtomsFramework.vbproj 31 Oct 2004 23:08:35 -0000 1.12 @@ -80,6 +80,16 @@ HintPath = "..\..\..\Program Files\NUnit 2.2\bin\nunit.framework.dll" AssemblyFolderKey = "hklm\dn\nunit.framework" /> + <Reference + Name = "System.Drawing" + AssemblyName = "System.Drawing" + HintPath = "..\..\..\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.Drawing.dll" + /> + <Reference + Name = "System.Windows.Forms" + AssemblyName = "System.Windows.Forms" + HintPath = "..\..\..\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.Windows.Forms.dll" + /> </References> <Imports> <Import Namespace = "Microsoft.VisualBasic" /> @@ -195,6 +205,11 @@ BuildAction = "Compile" /> <File + RelPath = "StandardClasses\LazyEmployee.vb" + SubType = "Code" + BuildAction = "Compile" + /> + <File RelPath = "StandardClasses\NonInheritedRetreiveCriteria.vb" SubType = "Code" BuildAction = "Compile" Index: AtomsFramework.xml =================================================================== RCS file: /cvsroot/jcframework/Nunit/AtomsFramework.xml,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- AtomsFramework.xml 25 Oct 2004 07:14:12 -0000 1.10 +++ AtomsFramework.xml 31 Oct 2004 23:08:35 -0000 1.11 @@ -261,26 +261,41 @@ <association fromClass="NunitTests.InheritedClasses.ManyToManyA" toClass="NunitTests.InheritedClasses.ManyToManyAB" cardinality="OneToMany" target="M2MABCollection" - retrieveAutomatic="True" saveAutomatic="true" deleteAutomatic="true" inverse="false"> + retrieveAutomatic="true" saveAutomatic="true" deleteAutomatic="true" inverse="false"> <entry fromAttribute="GUIDValue" toAttribute="AGuidValue"/> </association> <association fromClass="NunitTests.InheritedClasses.ManyToManyB" toClass="NunitTests.InheritedClasses.ManyToManyAB" cardinality="OneToMany" target="M2MABCollection" - retrieveAutomatic="True" saveAutomatic="true" deleteAutomatic="true" inverse="false"> + retrieveAutomatic="true" saveAutomatic="true" deleteAutomatic="true" inverse="false"> <entry fromAttribute="GUIDValue" toAttribute="BGuidValue"/> </association> <association fromClass="NunitTests.InheritedClasses.ManyToManyAB" toClass="NunitTests.InheritedClasses.ManyToManyA" cardinality="OneToOne" target="M2MA" - retrieveAutomatic="True" saveAutomatic="true" deleteAutomatic="true" inverse="false"> + retrieveAutomatic="true" saveAutomatic="true" deleteAutomatic="true" inverse="false"> <entry fromAttribute="AGuidValue" toAttribute="GUIDValue"/> </association> <association fromClass="NunitTests.InheritedClasses.ManyToManyAB" toClass="NunitTests.InheritedClasses.ManyToManyB" cardinality="OneToOne" target="M2MB" - retrieveAutomatic="True" saveAutomatic="true" deleteAutomatic="true" inverse="false"> + retrieveAutomatic="true" saveAutomatic="true" deleteAutomatic="true" inverse="false"> <entry fromAttribute="BGuidValue" toAttribute="GUIDValue"/> </association> + <class name="LazyEmployee" table="NPEmployee" database="MSA" namespace="NunitTests.StandardClasses"> + <attribute name="Name" column="name" find="true" key="primary"/> + <attribute name="ReportsToName" column="parentname" /> + <attribute name="ReportsTo" /> + <attribute name="Workers" /> + </class> + <association fromClass="NunitTests.StandardClasses.LazyEmployee" toClass="NunitTests.StandardClasses.LazyEmployee" target="ReportsTo" cardinality="OneToOne" + retrieveAutomatic="lazy" saveAutomatic="true" deleteAutomatic="false" inverse="false"> + <entry fromAttribute="ReportsToName" toAttribute="Name"/> + </association> + <association fromClass="NunitTests.StandardClasses.LazyEmployee" toClass="NunitTests.StandardClasses.LazyEmployee" target="Workers" cardinality="OneToMany" + retrieveAutomatic="lazy" saveAutomatic="true" deleteAutomatic="false" inverse="false"> + <entry fromAttribute="Name" toAttribute="ReportsToName"/> + </association> + </map> \ No newline at end of file |
From: Richard B. <rb...@us...> - 2004-10-31 23:08:46
|
Update of /cvsroot/jcframework/Nunit/InheritedClasses In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11585/InheritedClasses Modified Files: AtomsFrameworkTests.vb Log Message: Tests for lazy loading of objects in associations. Index: AtomsFrameworkTests.vb =================================================================== RCS file: /cvsroot/jcframework/Nunit/InheritedClasses/AtomsFrameworkTests.vb,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- AtomsFrameworkTests.vb 25 Oct 2004 07:14:14 -0000 1.4 +++ AtomsFrameworkTests.vb 31 Oct 2004 23:08:36 -0000 1.5 @@ -145,7 +145,7 @@ End Sub <Test(), ExpectedException(GetType(AssertionException))> _ - Public Sub CheckCacheCopiesAreDifferent() + Public Sub CheckCacheCopiesAreDifferent() Dim emp2 As CEmployee emp.Name = "ac" emp.Find() |
From: Richard B. <rb...@us...> - 2004-10-28 22:48:53
|
Update of /cvsroot/jcframework/dotnet In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29296 Modified Files: README.txt Log Message: Index: README.txt =================================================================== RCS file: /cvsroot/jcframework/dotnet/README.txt,v retrieving revision 1.14 retrieving revision 1.15 diff -u -d -r1.14 -r1.15 --- README.txt 19 Sep 2004 22:44:53 -0000 1.14 +++ README.txt 28 Oct 2004 22:48:43 -0000 1.15 @@ -1,36 +1,109 @@ -AtomsFramework v1.23 -Released: 20-Sep-2004 - ------------ - -Thank you for choosing to use the AtomsFramework. We trust that you enjoy using it and that you find it -useful. If you have any questions please visit the project home page and leave a message in the -forums. - -- Richard. - -http://jcframework.sourceforge.net - ------------ - -INSTALLATION - -Since this is a source code release installation is fairly trivial. - -To get this project working you must have installed the ADO.NET provider for MySQL (even if you don't use MySQL). -This is included in the archive (ByteFX and SharpZipLib) or you can get the latest from http://sourceforge.net/projects/mysqlnet/ -Make sure the .dll files are in the same directory as your executable otherwise you may have problems. - -The archive also includes sample projects to get you started. - -VBSample is written in VB.NET +AtomsFramework v2.0 Release Candidate 1 +Released: 29-Oct-2004 +----------- + +Thank you for choosing to use the AtomsFramework. We trust that you enjoy using it and that you find it useful. +If you have any questions please visit the project home page and leave a message in the forums. + +- Richard. + +http://jcframework.sourceforge.net + +----------- +INSTALLATION + +This is a source code release so installation is fairly trivial. +To get this project working you must have installed the ADO.NET provider for MySQL (even if you don't use MySQL). +This is included in the archive (ByteFX and SharpZipLib) or you can get the latest from http://sourceforge.net/projects/mysqlnet/ + +The archive also includes sample projects and NUnit tests (Nunit 2.2) to get you started. + +VBSample is written in VB.NET CSSample is the same project written in C# -DataBoundSample is a VB.NET project showing data bound collections - -------------- - -CHANGE LOG - +DataBoundSample is a VB.NET project showing data bound collections + +-------------CHANGE LOG--------------- +Changes in v2.0 RC1 (29-Oct-2004) + +Bugs: +----- +(#1035044) Fixes for MultipleInheritence + +(#1035044) Loading classes from Multiple Assemblies + Late binding of objects was not working is some situations + +(#1035273) Can't change key field values + When a key field of an object was changed, the object could not be saved. + +(#1038623) Incomplete Parameters + Where clauses for single object SQL statements now use parameters instead of string literals. This can improve SQL server performance in some cases. + +(#1038521) Error in CCursor.LoadProxy + Multiple problems in the LoadProxy method were fixed + +(#1046809) Correct handling of ANSI Nulls + Databases handle Nulls in where clauses differently depending on their ANSI Null behaviour. A new "ansinulls" parameter has been added to the XML database configuration to control this behaviour + +(#1046405) Wrong alias used in join + MutliRetrieveCriteria joins were always joining against the left most table. + +(#1055503) Incomplete SQL when using summary with group by + Grouped fields were not included in the result. Fixed by Exelrud. + +(N/A) Saving objects in shared tables + Various issues with shared tables existed and are now fixed. + +(N/A) Problems with code based attribute mappings using OID/Guid + Classes mapped using <AFxxx()> custom attributes had problems when using OID or GUID values for primary keys + +(N/A) String.Empty and columns marked as NOT NULL + NOT NULL String columns could not be saved if the value was String.Empty + +(N/A) Duplicate objects when retrieving multiple collections + Objects with more than one one-to-many association were incorrectly retrieving duplicate objects + +(N/A) Problems with Many-to-Many associations + The pivot objects in a many-to-many association were being saved multiple times resulting in duplicate index errors. + +(N/A) Could not update value types mapped using <attribute>.<property> syntax in XML. + Value types needed to be handled differently to objects in SetAttribute... methods + +(N/A) Using offsets on Microsoft SQL generated invalid SQL + Microsoft SQL (and Access) do not natively support offsets. Changes made to mimic offset behaviour for these databases. + + +Modifications: +-------------- +(#1035044) Enhanced method for saving objects + Dirty objects in an object tree can still be saved even if the root object is not dirty + +(#1035044) Deletion + Option added to optionally delete an objects parent when an object is deleted + +(#1035044) Attributes for CPersistentObject and CPersistentCollection + Properties in these classes have been marked as Browsable(False), NonSerialized and as advanced editor properties where appropriate + +(#1013994) Ordering criteria based on associated objects + CMultiRetrieveCriteria can now order by properties of associated objects. (exelrud) + +(#1041860) Add SSPI Support to Microsoft SQL databases + To use SSPI set the user name to SSPI in the XML database configuration. No password is required + +(N/A) Added NOT BETWEEN selection criteria + +(N/A) Implemented Dispose on various objects + Improved garbage collection and resource management + +(N/A) New method added for DeleteAll(). Thanks mfo + +(N/A) Added ability to persist objects without inheriting from CPersistentObject + See posts in the forums for more information + +(N/A) Added ability to persist objects based on interfaces + See posts in the forums for more information + + + --------------- Changes in v1.23 (20-Sep-2004) @@ -105,8 +178,7 @@ (N/A) Added AtomsFramework specific Exception types (N/A) Added support for Pessimistic Locking strategies ---------------- -Changes in v0.1.8 (17-Jun-2004) +---------------Changes in v0.1.8 (17-Jun-2004) Bug Fixes: @@ -123,64 +195,4 @@ --------------- Changes in v0.1.7 (19-May-2004) -Bug Fixes: - -(#955563) Cannot load object from MultiRetrieve criteria -(#955537) Row limit fails on SQL Server -(#955534) Spurious AND in where condition -(#955532) Table alias not working on some conditions -(#953690) is not NULL clause not working -(#943648) Problem with two databases in SQL Server 2000 -(#943372) Bug in deleting objects from a collection -(N/A) Fixed problem with loading associations incorrectly - -Requests: -(#943383) Simplify criteria condition creation - ---------------- -Changes in v0.1.6 (23-Apr-2004) - -- New custom attributes to embed class mappings in code (RFE #938389) - -- Improved where clause support - CCriteriaConditions (RFE #934141) - -- Added extra debug console output - -- Fix for Time only values in MSSQL Server (Bug #935421) - -- Fix incorrect population of CPersistentCollections under certain circumstances (Bug #914244) - ---------------- -Changes in v0.1.5 (26-Feb-2004) - -[BUG FIX RELEASE] - -- Fixed Data Type Mismatch Error (Bug #888782) - -- Fixed Object Deletion error for SQL Server (Bug #895458) - -- Fixed Duplicate Parameter error (Bug #898309) - -- Fixed Timestamp Date Errors (Bug #900364) - -- Fixed Millisecond rounding issue on timestamps (Bug #900373) - ---------------- -Changes in v0.1.4 (30-Jan-2004) - -- Added support for BLOBs - -- Added GUID generation support. - -- Added Serializable() attribute to the CPersistentObject and COID classes. - -- Updated documentation. - ---------------- -Changes in v0.1.3 (18-Dec-2003) - -- Completed documentation. Full CHM and web based MSDN style documentation now available - -- Added extra methods to CPersistentObject for simplifying object retrieval (Marcos Flavio de Oliviera) - -- Added method for determining if an object is referenced by other objects \ No newline at end of file +Bug Fixes:(#955563) Cannot load object from MultiRetrieve criteria(#955537) Row limit fails on SQL Server(#955534) Spurious AND in where condition(#955532) Table alias not working on some conditions(#953690) is not NULL clause not working(#943648) Problem with two databases in SQL Server 2000(#943372) Bug in deleting objects from a collection(N/A) Fixed problem with loading associations incorrectlyRequests:(#943383) Simplify criteria condition creation---------------Changes in v0.1.6 (23-Apr-2004)- New custom attributes to embed class mappings in code (RFE #938389)- Improved where clause support - CCriteriaConditions (RFE #934141)- Added extra debug console output- Fix for Time only values in MSSQL Server (Bug #935421)- Fix incorrect population of CPersistentCollections under certain circumstances (Bug #914244)---------------Changes in v0.1.5 (26-Feb-2004)[BUG FIX RELEASE]- Fixed Data Type Mismatch Error (Bug #888782)- Fixed Object Deletion error for SQL Server (Bug #895458)- Fixed Duplicate Parameter error (Bug #898309)- Fixed Timestamp Date Errors (Bug #900364)- Fixed Millisecond rounding issue on timestamps (Bug #900373)---------------Changes in v0.1.4 (30-Jan-2004)- Added support for BLOBs- Added GUID generation support.- Added Serializable() attribute to the CPersistentObject and COID classes.- Updated documentation.---------------Changes in v0.1.3 (18-Dec-2003)- Completed documentation. Full CHM and web based MSDN style documentation now available- Added extra methods to CPersistentObject for simplifying object retrieval (Marcos Flavio de Oliviera)- Added method for determining if an object is referenced by other objects \ No newline at end of file |
From: Richard B. <rb...@us...> - 2004-10-28 00:17:38
|
Update of /cvsroot/jcframework/Nunit/InheritedClasses In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3298/InheritedClasses Modified Files: RetrieveCriteriaTests.vb Log Message: Added simple unit test for row limits and offsets Index: RetrieveCriteriaTests.vb =================================================================== RCS file: /cvsroot/jcframework/Nunit/InheritedClasses/RetrieveCriteriaTests.vb,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- RetrieveCriteriaTests.vb 19 Oct 2004 03:30:42 -0000 1.2 +++ RetrieveCriteriaTests.vb 28 Oct 2004 00:17:28 -0000 1.3 @@ -63,6 +63,16 @@ Assert.IsTrue(c.EOF) End Sub + <Test()> Public Sub RetrieveCriteriaOffset() + r = New CRetrieveCriteria + r.ClassMap = emp.getClassMap + r.RowLimit = 1 + r.Offset = 1 + c = r.perform + Assert.IsTrue(c.hasElements) + Assert.AreEqual(1, c.TotalRows) + End Sub + <Test()> Public Sub LoadFullObjects() r = New CRetrieveCriteria r.ReturnFullObjects = True |
From: Richard B. <rb...@us...> - 2004-10-28 00:16:43
|
Update of /cvsroot/jcframework/dotnet In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2951 Modified Files: CClassMap.vb CColumnMap.vb CCriteriaCondition.vb CMsAccessDatabase.vb CMultiRetrieveCriteria.vb CMultiSummaryCriteria.vb CMySqlDatabase.vb CPersistentCriteria.vb CRelationalDatabase.vb CRetrieveCriteria.vb CSelectInCriteria.vb CSummaryCriteria.vb Log Message: Fixes as per bug #1055503 (Summary criteria) Also, changes to better handle offsets for databases that do not natively provide offset support (ie MSSQL, Access, etc) Index: CRelationalDatabase.vb =================================================================== RCS file: /cvsroot/jcframework/dotnet/CRelationalDatabase.vb,v retrieving revision 1.20 retrieving revision 1.21 diff -u -d -r1.20 -r1.21 --- CRelationalDatabase.vb 18 Oct 2004 03:31:51 -0000 1.20 +++ CRelationalDatabase.vb 28 Oct 2004 00:16:12 -0000 1.21 @@ -555,6 +555,19 @@ ''' </history> ''' ----------------------------------------------------------------------------- Function useBracketsForJoins() As Boolean + ''' ----------------------------------------------------------------------------- + ''' <summary> + ''' Indicates that the database supports offsets in the TOP clause (mysql) + ''' </summary> + ''' <returns></returns> + ''' <remarks>Not all database support offsets for select statements. Those that + ''' don't must use a different method to skip rows. + ''' </remarks> + ''' <history> + ''' [rbanks] 2/09/2004 Created + ''' </history> + ''' ----------------------------------------------------------------------------- + Function supportsSelectOffsets() As Boolean End Interface '''----------------------------------------------------------------------------- @@ -1254,4 +1267,7 @@ Dispose(False) End Sub + Public Overridable Function supportsSelectOffsets() As Boolean Implements _CRelationalDatabase.supportsSelectOffsets + Return False + End Function End Class \ No newline at end of file Index: CCriteriaCondition.vb =================================================================== RCS file: /cvsroot/jcframework/dotnet/CCriteriaCondition.vb,v retrieving revision 1.15 retrieving revision 1.16 diff -u -d -r1.15 -r1.16 --- CCriteriaCondition.vb 8 Oct 2004 00:06:25 -0000 1.15 +++ CCriteriaCondition.vb 28 Oct 2004 00:16:12 -0000 1.16 @@ -20,10 +20,10 @@ 'Condition for criteria's WHERE and HAVING parts Private m_Simple As Boolean - Private m_Parts As New Collection - Private m_Associations As New Collection + Private m_Parts As New Collection + Private m_Associations As New Collection Private m_classMap As CClassMap - Private m_Tables As New Collection + Private m_Tables As New Collection Private m_parent As CCriteriaCondition Private m_useOrWithParent As Boolean @@ -232,13 +232,13 @@ ''' </history> ''' ----------------------------------------------------------------------------- Public Sub addSubCriteria(ByVal subCriteria As CCriteriaCondition, ByVal useOr As Boolean) - m_Simple = False - If subCriteria.ClassMap Is Nothing Then - subCriteria.ClassMap = Me.ClassMap - End If - m_Parts.Add(subCriteria) - subCriteria.useOrWithParent = useOr - subCriteria.Parent = Me + m_Simple = False + If subCriteria.ClassMap Is Nothing Then + subCriteria.ClassMap = Me.ClassMap + End If + m_Parts.Add(subCriteria) + subCriteria.useOrWithParent = useOr + subCriteria.Parent = Me End Sub @@ -615,10 +615,10 @@ End Function Public Function addSelectLike(ByVal Name As String, ByVal ValueA As Object) As CSelectionCriteria - Return addSelectlike(Name, ValueA, "", False) + Return addSelectLike(Name, ValueA, "", False) End Function Public Function addSelectLike(ByVal Name As String, ByVal ValueA As Object, ByVal useOr As Boolean) As CSelectionCriteria - Return addSelectlike(Name, ValueA, "", useOr) + Return addSelectLike(Name, ValueA, "", useOr) End Function '''----------------------------------------------------------------------------- ''' <summary> Index: CSelectInCriteria.vb =================================================================== RCS file: /cvsroot/jcframework/dotnet/CSelectInCriteria.vb,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- CSelectInCriteria.vb 18 Oct 2004 00:08:10 -0000 1.6 +++ CSelectInCriteria.vb 28 Oct 2004 00:16:12 -0000 1.7 @@ -26,6 +26,7 @@ Private Shared m_subQueryCount As Integer = 0 Private m_SQC As Integer Private m_alias As String + Private m_rows As Short '''----------------------------------------------------------------------------- ''' <summary> @@ -111,6 +112,25 @@ '''----------------------------------------------------------------------------- ''' <summary> + ''' The number of records to retrieve in the sub condition + ''' </summary> + ''' <value>Short specifying the maximum number of records to retrieve from the database.</value> + ''' <remarks>The value is used in SQL generation only.</remarks> + ''' <history> + ''' [rbanks] 28/10/2004 Created + ''' </history> + '''----------------------------------------------------------------------------- + Public Property RowLimit() As Short + Get + Return m_rows + End Get + Set(ByVal Value As Short) + m_rows = Value + End Set + End Property + + '''----------------------------------------------------------------------------- + ''' <summary> ''' Creates a new instance of the CSelectInCriteria and sets the primary object. ''' </summary> ''' <param name="obj">The object to use in the sub-query.</param> @@ -261,10 +281,19 @@ statement.addSqlClause("(" & Me.ClassMap.RelationalDatabase.getClauseStringSelect & " ") + If m_rows > 0 And Me.ClassMap.RelationalDatabase.limitClauseAtStart Then + statement.addSqlClause(" " & Me.ClassMap.RelationalDatabase.getClauseStringLimit) + statement.addSqlClause(" " & Str(m_rows) & " ") + End If + statement.addSqlClause(m_selectAttribute.ColumnMap.getAliasQualifiedName(m_alias)) statement.addSqlClause(" " & Me.ClassMap.RelationalDatabase.getClauseStringFrom & " ") - statement.addSqlClause(m_joins.GetSQLString) + If m_joins Is Nothing Then + statement.addSqlClause(Me.Tables(1).Name) + Else + statement.addSqlClause(m_joins.GetSQLString) + End If 'Need to set correct table aliases for the selection criteria in the where condition Dim obj As Object @@ -285,6 +314,10 @@ fillStatementWithWhere(statement) + If m_rows > 0 And Not Me.ClassMap.RelationalDatabase.limitClauseAtStart Then + statement.addSqlClause(" " & Me.ClassMap.RelationalDatabase.getClauseStringLimit) + statement.addSqlClause(" " & Str(m_rows)) + End If statement.addSqlClause(")") Return statement.SqlString End Function Index: CMsAccessDatabase.vb =================================================================== RCS file: /cvsroot/jcframework/dotnet/CMsAccessDatabase.vb,v retrieving revision 1.18 retrieving revision 1.19 diff -u -d -r1.18 -r1.19 --- CMsAccessDatabase.vb 18 Oct 2004 03:31:51 -0000 1.18 +++ CMsAccessDatabase.vb 28 Oct 2004 00:16:12 -0000 1.19 @@ -321,4 +321,11 @@ End If End Sub + Public Overrides Function limitClauseAtStart() As Boolean + Return True + End Function + + Public Overrides Function getClauseStringLimit() As String + Return "TOP" + End Function End Class \ No newline at end of file Index: CPersistentCriteria.vb =================================================================== RCS file: /cvsroot/jcframework/dotnet/CPersistentCriteria.vb,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- CPersistentCriteria.vb 20 Oct 2004 06:44:23 -0000 1.8 +++ CPersistentCriteria.vb 28 Oct 2004 00:16:12 -0000 1.9 @@ -17,6 +17,7 @@ Sub fillStatementWithCondition(ByRef statement As CSqlStatement) Sub fillStatementWithWhere(ByRef statement As CSqlStatement) Function getSize() As Short + Sub addOffsetSubCriteria(ByVal offset As Integer) End Interface '''----------------------------------------------------------------------------- @@ -289,4 +290,29 @@ End If MyBase.Finalize() End Sub + + Public Sub addOffsetSubCriteria(ByVal offset As Integer) Implements _CPersistentCriteria.addOffsetSubCriteria + + Dim si As CSelectInCriteria + Dim baseClassConditions As New CCriteriaCondition + + baseClassConditions.ClassMap = Me.ClassMap + baseClassConditions.Tables = Me.Tables + For Each cc As CSelectionCriteria In WhereCondition.Parts + If cc.ClassMap.Name = Me.ClassMap.Name Then + baseClassConditions.Parts.Add(cc) + End If + Next + + For Each am As CAttributeMap In ClassMap.KeyAttributeMaps + si = New CSelectInCriteria + si.Tables = Me.Tables + si.ClassMap = Me.ClassMap + si.WhereCondition = baseClassConditions + si.SetSelectAttribute(am.Name) + si.RowLimit = offset + Me.WhereCondition.addSelectNotIn(am.Name, si) + Next + End Sub + End Class \ No newline at end of file Index: CMultiSummaryCriteria.vb =================================================================== RCS file: /cvsroot/jcframework/dotnet/CMultiSummaryCriteria.vb,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -r1.11 -r1.12 --- CMultiSummaryCriteria.vb 18 Oct 2004 00:08:10 -0000 1.11 +++ CMultiSummaryCriteria.vb 28 Oct 2004 00:16:12 -0000 1.12 @@ -380,10 +380,10 @@ statement.addSqlClause(ClassMap.RelationalDatabase.getClauseStringSelect) If m_rows > 0 And Me.ClassMap.RelationalDatabase.limitClauseAtStart Then statement.addSqlClause(" " & Me.ClassMap.RelationalDatabase.getClauseStringLimit) - If m_offset >= 0 Then - statement.addSqlClause(Str(m_offset) & ", ") + If m_offset > 0 AndAlso Me.ClassMap.RelationalDatabase.supportsSelectOffsets Then + statement.addSqlClause(" " & Str(m_offset) & ",") End If - statement.addSqlClause(Str(m_rows)) + statement.addSqlClause(" " & Str(m_rows)) End If statement.addSqlClause(" ") isFirst = True @@ -414,6 +414,9 @@ statement.addSqlClause(" " & Me.ClassMap.RelationalDatabase.getClauseStringFrom & " ") statement.addSqlClause(m_joins.GetSQLString) + If m_offset > 0 And Not Me.ClassMap.RelationalDatabase.supportsSelectOffsets Then + addOffsetSubCriteria(m_offset) + End If fillStatementWithWhere(statement) Dim attMap As CAttributeMap @@ -451,10 +454,10 @@ If m_rows > 0 And Not Me.ClassMap.RelationalDatabase.limitClauseAtStart Then statement.addSqlClause(" " & Me.ClassMap.RelationalDatabase.getClauseStringLimit) - If m_offset >= 0 Then - statement.addSqlClause(Str(m_offset) & ", ") + If m_offset > 0 AndAlso Me.ClassMap.RelationalDatabase.supportsSelectOffsets Then + statement.addSqlClause(" " & Str(m_offset) & ",") End If - statement.addSqlClause(Str(m_rows)) + statement.addSqlClause(" " & Str(m_rows)) End If getSqlStatementParameters = statement Index: CMultiRetrieveCriteria.vb =================================================================== RCS file: /cvsroot/jcframework/dotnet/CMultiRetrieveCriteria.vb,v retrieving revision 1.17 retrieving revision 1.18 diff -u -d -r1.17 -r1.18 --- CMultiRetrieveCriteria.vb 19 Oct 2004 03:32:08 -0000 1.17 +++ CMultiRetrieveCriteria.vb 28 Oct 2004 00:16:12 -0000 1.18 @@ -126,7 +126,7 @@ m_offset = -1 m_rows = -1 m_Having = Nothing - m_fullObjects = False 'default to proxy objects only + m_fullObjects = False 'default to proxy objects only End Sub Public Sub New(ByVal obj As CPersistentObject) @@ -349,10 +349,10 @@ statement.addSqlClause(Me.ClassMap.RelationalDatabase.getClauseStringSelect) If m_rows > 0 And Me.ClassMap.RelationalDatabase.limitClauseAtStart Then statement.addSqlClause(" " & Me.ClassMap.RelationalDatabase.getClauseStringLimit) - If m_offset > 0 Then - statement.addSqlClause(Str(m_offset) & ", ") + If m_offset > 0 AndAlso Me.ClassMap.RelationalDatabase.supportsSelectOffsets Then + statement.addSqlClause(" " & Str(m_offset) & ",") End If - statement.addSqlClause(Str(m_rows)) + statement.addSqlClause(" " & Str(m_rows)) End If statement.addSqlClause(" ") j = 0 @@ -388,6 +388,9 @@ UpdateConditionAliases(WhereCondition, mapName, cm.Name) Next + If m_offset > 0 And Not Me.ClassMap.RelationalDatabase.supportsSelectOffsets Then + addOffsetSubCriteria(m_offset) + End If fillStatementWithWhere(statement) Dim attMap As CAttributeMap @@ -414,10 +417,10 @@ If m_rows > 0 And Not Me.ClassMap.RelationalDatabase.limitClauseAtStart Then statement.addSqlClause(" " & Me.ClassMap.RelationalDatabase.getClauseStringLimit) - If m_offset > 0 Then - statement.addSqlClause(Str(m_offset) & ", ") + If m_offset > 0 AndAlso Me.ClassMap.RelationalDatabase.supportsSelectOffsets Then + statement.addSqlClause(" " & Str(m_offset) & ",") End If - statement.addSqlClause(Str(m_rows)) + statement.addSqlClause(" " & Str(m_rows)) End If getSqlStatementParameters = statement Index: CRetrieveCriteria.vb =================================================================== RCS file: /cvsroot/jcframework/dotnet/CRetrieveCriteria.vb,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- CRetrieveCriteria.vb 16 Aug 2004 04:16:54 -0000 1.10 +++ CRetrieveCriteria.vb 28 Oct 2004 00:16:12 -0000 1.11 @@ -215,6 +215,9 @@ statement.addSqlClause(tm.Name) Next i + If m_offset > 0 And Not Me.ClassMap.RelationalDatabase.supportsSelectOffsets Then + addOffsetSubCriteria(m_offset) + End If fillStatementWithWhere(statement) Dim attMap As CAttributeMap @@ -256,10 +259,10 @@ If m_rows > 0 And Not Me.ClassMap.RelationalDatabase.limitClauseAtStart Then statement.addSqlClause(" " & Me.ClassMap.RelationalDatabase.getClauseStringLimit) - If m_offset > 0 Then - statement.addSqlClause(Str(m_offset) & ", ") + If m_offset > 0 AndAlso Me.ClassMap.RelationalDatabase.supportsSelectOffsets Then + statement.addSqlClause(" " & Str(m_offset) & ",") End If - statement.addSqlClause(Str(m_rows)) + statement.addSqlClause(" " & Str(m_rows)) End If getSqlStatementParameters = statement Index: CMySqlDatabase.vb =================================================================== RCS file: /cvsroot/jcframework/dotnet/CMySqlDatabase.vb,v retrieving revision 1.20 retrieving revision 1.21 diff -u -d -r1.20 -r1.21 --- CMySqlDatabase.vb 18 Oct 2004 03:31:51 -0000 1.20 +++ CMySqlDatabase.vb 28 Oct 2004 00:16:12 -0000 1.21 @@ -329,4 +329,8 @@ End If End If End Sub + + Public Overrides Function supportsSelectOffsets() As Boolean + Return True + End Function End Class Index: CColumnMap.vb =================================================================== RCS file: /cvsroot/jcframework/dotnet/CColumnMap.vb,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- CColumnMap.vb 7 Oct 2004 05:57:33 -0000 1.10 +++ CColumnMap.vb 28 Oct 2004 00:16:12 -0000 1.11 @@ -267,7 +267,11 @@ ''' </history> '''----------------------------------------------------------------------------- Public Function getAliasQualifiedName(ByVal pAlias As String) As String - Return pAlias & "." & Me.Name + If pAlias = String.Empty Then + Return Me.Name + Else + Return pAlias & "." & Me.Name + End If End Function '''----------------------------------------------------------------------------- Index: CClassMap.vb =================================================================== RCS file: /cvsroot/jcframework/dotnet/CClassMap.vb,v retrieving revision 1.37 retrieving revision 1.38 diff -u -d -r1.37 -r1.38 --- CClassMap.vb 27 Oct 2004 07:38:48 -0000 1.37 +++ CClassMap.vb 28 Oct 2004 00:16:11 -0000 1.38 @@ -978,10 +978,10 @@ statement.addSqlClause(Me.RelationalDatabase.getClauseStringSelect) If rowLimit > 0 And Me.RelationalDatabase.limitClauseAtStart Then statement.addSqlClause(" " & Me.RelationalDatabase.getClauseStringLimit) - If rowOffset > 0 Then - statement.addSqlClause(Str(rowOffset) & ", ") + If rowOffset > 0 andalso Me.RelationalDatabase.supportsSelectOffsets Then + statement.addSqlClause(" " & Str(rowOffset) & ",") End If - statement.addSqlClause(Str(rowLimit)) + statement.addSqlClause(" " & Str(rowLimit)) End If statement.addSqlClause(" ") Dim isFirst As Boolean Index: CSummaryCriteria.vb =================================================================== RCS file: /cvsroot/jcframework/dotnet/CSummaryCriteria.vb,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- CSummaryCriteria.vb 18 Oct 2004 00:08:10 -0000 1.9 +++ CSummaryCriteria.vb 28 Oct 2004 00:16:12 -0000 1.10 @@ -42,6 +42,7 @@ ''' </history> '''----------------------------------------------------------------------------- Public Enum SumMethod + None Sum Avg Min @@ -150,6 +151,8 @@ '''----------------------------------------------------------------------------- Public Sub addGroupAttribute(ByVal attributeName As String) m_groupAttributes.Add(ClassMap.getAttributeMapByString(attributeName, True)) + m_fieldsForSum.Add(ClassMap.getAttributeMapByString(attributeName, True)) + m_methodsForSum.Add(SumMethod.None) End Sub '''----------------------------------------------------------------------------- @@ -228,15 +231,17 @@ statement.addSqlClause(ClassMap.RelationalDatabase.getClauseStringSelect) If m_rows > 0 And Me.ClassMap.RelationalDatabase.limitClauseAtStart Then statement.addSqlClause(" " & Me.ClassMap.RelationalDatabase.getClauseStringLimit) - If m_offset > 0 Then - statement.addSqlClause(Str(m_offset) & ", ") + If m_offset > 0 AndAlso Me.ClassMap.RelationalDatabase.supportsSelectOffsets Then + statement.addSqlClause(" " & Str(m_offset) & ",") End If - statement.addSqlClause(Str(m_rows)) + statement.addSqlClause(" " & Str(m_rows)) End If statement.addSqlClause(" ") isFirst = True For i = 1 To m_fieldsForSum.Count Select Case m_methodsForSum(i) + Case SumMethod.None + s = m_fieldsForSum(i).ColumnMap.getFullyQualifiedName Case SumMethod.Avg s = ClassMap.RelationalDatabase.getClauseStringAvg(m_fieldsForSum(i).ColumnMap.getFullyQualifiedName) Case SumMethod.Max @@ -248,6 +253,9 @@ Case SumMethod.Count s = ClassMap.RelationalDatabase.getClauseStringCount(m_fieldsForSum(i).ColumnMap.getFullyQualifiedName) End Select + If m_methodsForSum(i) <> SumMethod.None Then + s = s + " as " + m_fieldsForSum(i).ColumnMap.Name + End If If isFirst Then statement.addSqlClause(s) Else @@ -266,6 +274,9 @@ statement.addSqlClause(tm.Name) Next i + If m_offset > 0 And Not Me.ClassMap.RelationalDatabase.supportsSelectOffsets Then + addOffsetSubCriteria(m_offset) + End If fillStatementWithWhere(statement) Dim attMap As CAttributeMap @@ -303,10 +314,10 @@ If m_rows > 0 And Not Me.ClassMap.RelationalDatabase.limitClauseAtStart Then statement.addSqlClause(" " & Me.ClassMap.RelationalDatabase.getClauseStringLimit) - If m_offset > 0 Then - statement.addSqlClause(Str(m_offset) & ", ") + If m_offset > 0 AndAlso Me.ClassMap.RelationalDatabase.supportsSelectOffsets Then + statement.addSqlClause(" " & Str(m_offset) & ",") End If - statement.addSqlClause(Str(m_rows)) + statement.addSqlClause(" " & Str(m_rows)) End If getSqlStatementParameters = statement |
From: Richard B. <rb...@us...> - 2004-10-27 07:39:09
|
Update of /cvsroot/jcframework/dotnet In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9422 Modified Files: CClassMap.vb CInjectedObject.vb CPersistenceBroker.vb CPersistentCollection.vb CPersistentObject.vb Log Message: Fixes to: 1. PersistChanges() to handle new objects being added to tracking when saving object hierarchy 2. Updating ValueTypes (structures) mapped via structure.field naming 3. Getting classmaps for interfaces that use inheritance 4. Persistent flag not being correctly set on LoadProxy Index: CPersistenceBroker.vb =================================================================== RCS file: /cvsroot/jcframework/dotnet/CPersistenceBroker.vb,v retrieving revision 1.73 retrieving revision 1.74 diff -u -d -r1.73 -r1.74 --- CPersistenceBroker.vb 25 Oct 2004 07:12:31 -0000 1.73 +++ CPersistenceBroker.vb 27 Oct 2004 07:38:48 -0000 1.74 @@ -961,14 +961,23 @@ Public Function getClassMap(ByVal pType As Type) As CClassMap Dim ClassMap As CClassMap + Dim tmpCMap As CClassMap ClassMap = getClassMapByTypeName(pType.Name, pType.FullName) If ClassMap Is Nothing Then 'try to find an interface that is mapped - first mapped interface we find will be used Dim intType, interfaces() As Type - For Each intType In pType.GetInterfaces() - ClassMap = getClassMapByTypeName(intType.Name, intType.FullName) - If Not ClassMap Is Nothing Then - Exit For + interfaces = pType.GetInterfaces + For Each intType In interfaces + tmpCMap = getClassMapByTypeName(intType.Name, intType.FullName) + 'If this class has children, iterate through other class maps to see if + 'the object inherits a child class, otherwise we can get the wrong class map + 'returned. + If Not tmpCMap Is Nothing Then + If ClassMap Is Nothing Then ClassMap = tmpCMap + If tmpCMap.ChildrenMaps.Count = 0 Then + ClassMap = tmpCMap + Exit For + End If End If Next End If @@ -2461,7 +2470,13 @@ Try Dim injObj As CInjectedObject m_inPersistChangesLoop = True + 'Need to copy the injected object cache as saving objects may result + 'in new objects being added to the cache (via the object hierarchy) + Dim objectsToPersist As New CInjectedObjects For Each de As DictionaryEntry In m_injectedObjects + objectsToPersist.Add(de.Key, de.Value) + Next + For Each de As DictionaryEntry In objectsToPersist injObj = de.Value PersistChanges(injObj.ReferencedObject) Next Index: CInjectedObject.vb =================================================================== RCS file: /cvsroot/jcframework/dotnet/CInjectedObject.vb,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- CInjectedObject.vb 25 Oct 2004 07:12:31 -0000 1.5 +++ CInjectedObject.vb 27 Oct 2004 07:38:48 -0000 1.6 @@ -99,14 +99,23 @@ Public Function getClassMap() As CClassMap Implements IPersistableObject.getClassMap Dim ClassMap As CClassMap + Dim tmpCMap As CClassMap ClassMap = getClassMap(TypeName(m_object), m_object.GetType.FullName) If ClassMap Is Nothing Then 'try to find an interface that is mapped - first mapped interface we find will be used Dim intType, interfaces() As Type - For Each intType In m_object.GetType.GetInterfaces() - ClassMap = getClassMap(intType.Name, intType.FullName) - If Not ClassMap Is Nothing Then - Exit For + interfaces = m_object.GetType.GetInterfaces + For Each intType In interfaces + tmpCMap = getClassMap(intType.Name, intType.FullName) + 'If this class has children, iterate through other class maps to see if + 'the object inherits a child class, otherwise we can get the wrong class map + 'returned. + If Not tmpCMap Is Nothing Then + If ClassMap Is Nothing Then ClassMap = tmpCMap + If tmpCMap.ChildrenMaps.Count = 0 Then + ClassMap = tmpCMap + Exit For + End If End If Next End If @@ -429,13 +438,24 @@ Dim o As Object Dim objName As String Dim propertyName As String + Dim val As ValueType objName = pName.Substring(0, dotPos) propertyName = pName.Substring(dotPos + 1) o = CallByName(m_object, objName, CallType.Get) - If TypeOf (Value) Is System.SByte Then - CallByName(o, propertyName, CallType.Set, IIf(Value.ToString = "1", True, False)) + If o.GetType.IsValueType Then + val = o + If TypeOf (Value) Is System.SByte Then + CallByName(val, propertyName, CallType.Set, IIf(Value.ToString = "1", True, False)) + Else + CallByName(val, propertyName, CallType.Set, Value) + End If + CallByName(m_object, objName, CallType.Set, val) Else - CallByName(o, propertyName, CallType.Set, Value) + If TypeOf (Value) Is System.SByte Then + CallByName(o, propertyName, CallType.Set, IIf(Value.ToString = "1", True, False)) + Else + CallByName(o, propertyName, CallType.Set, Value) + End If End If End If Catch ex As Exception @@ -537,7 +557,7 @@ 'copy the OriginalModifiedDate and the ModifiedDate from the child to the parent. 'if we don't do this the object won't get saved correctly on subsequent calls. - obj.SetAttributeValue("ModifiedDate", Me.getValueByAttribute("ModifiedDate")) + obj.ModifiedDate = Me.ModifiedDate obj.OriginalModifiedDate = Me.OriginalModifiedDate obj.IsDirty = Me.IsDirty Index: CPersistentObject.vb =================================================================== RCS file: /cvsroot/jcframework/dotnet/CPersistentObject.vb,v retrieving revision 1.47 retrieving revision 1.48 diff -u -d -r1.47 -r1.48 --- CPersistentObject.vb 25 Oct 2004 07:12:32 -0000 1.47 +++ CPersistentObject.vb 27 Oct 2004 07:38:48 -0000 1.48 @@ -49,26 +49,26 @@ Public Event MarkedAsDirty As EventHandler Implements IPersistentObject.MarkedAsDirty Public Event LoadStarted As EventHandler Implements IPersistentObject.LoadStarted Public Event LoadFinished As EventHandler Implements IPersistentObject.LoadFinished - Friend Event RemoveMe(ByVal pObj As CPersistentObject) + Friend Event RemoveMe(ByVal pObj As CPersistentObject) <NonSerialized()> Private m_preEditCopy As CPersistentObject <NonSerialized()> Private m_retrievedCacheKey As CCacheKey #Region "Properties" - '''----------------------------------------------------------------------------- - ''' <summary> - ''' Flag to indicate if the object is read only. - ''' </summary> - ''' <value>Boolean indicating whether the object is read only or not.</value> - ''' <remarks>Objects that are read only can still be modified by the application - ''' however when any of the persistence methods are called (such as save and delete) - ''' an exception will be thrown indicating that the object is read only. - ''' <para>Read only objects are typically used to map database views.</para></remarks> - ''' <history> - ''' [rbanks] 25/11/2003 Created - ''' </history> - '''----------------------------------------------------------------------------- + '''----------------------------------------------------------------------------- + ''' <summary> + ''' Flag to indicate if the object is read only. + ''' </summary> + ''' <value>Boolean indicating whether the object is read only or not.</value> + ''' <remarks>Objects that are read only can still be modified by the application + ''' however when any of the persistence methods are called (such as save and delete) + ''' an exception will be thrown indicating that the object is read only. + ''' <para>Read only objects are typically used to map database views.</para></remarks> + ''' <history> + ''' [rbanks] 25/11/2003 Created + ''' </history> + '''----------------------------------------------------------------------------- <Browsable(False)> Public ReadOnly Property isReadOnly() As Boolean Implements IPersistentObject.isReadOnly Get Return getClassMap(Me).isReadOnly @@ -508,18 +508,29 @@ Dim o As Object Dim objName As String Dim propertyName As String + Dim val As ValueType objName = pName.Substring(0, dotPos) propertyName = pName.Substring(dotPos + 1) o = CallByName(Me, objName, CallType.Get) - If TypeOf (Value) Is System.SByte Then - CallByName(o, propertyName, CallType.Set, IIf(Value.ToString = "1", True, False)) + If o.GetType.IsValueType Then + Val = o + If TypeOf (Value) Is System.SByte Then + CallByName(Val, propertyName, CallType.Set, IIf(Value.ToString = "1", True, False)) + Else + CallByName(Val, propertyName, CallType.Set, Value) + End If + CallByName(Me, objName, CallType.Set, val) Else - CallByName(o, propertyName, CallType.Set, Value) + If TypeOf (Value) Is System.SByte Then + CallByName(o, propertyName, CallType.Set, IIf(Value.ToString = "1", True, False)) + Else + CallByName(o, propertyName, CallType.Set, Value) + End If End If End If Catch ex As Exception Throw New AttributeValueException("Could not set attribute " & pName & " (Value Type: " _ - & Value.GetType.Name & ") in CPersistentObject::SetAttributeValue." & vbCrLf & ex.Message, ex) + & Value.GetType.Name & ") in CPersistentObject::SetAttributeValue." & vbCrLf & ex.Message, ex) End Try End Sub Index: CPersistentCollection.vb =================================================================== RCS file: /cvsroot/jcframework/dotnet/CPersistentCollection.vb,v retrieving revision 1.13 retrieving revision 1.14 diff -u -d -r1.13 -r1.14 --- CPersistentCollection.vb 28 Sep 2004 04:19:04 -0000 1.13 +++ CPersistentCollection.vb 27 Oct 2004 07:38:48 -0000 1.14 @@ -18,26 +18,26 @@ ''' </history> ''' ----------------------------------------------------------------------------- Public Class CPersistentCollection - Inherits CollectionBase + Inherits CollectionBase Implements IComponent Implements IBindingList - Private m_container As CPersistentObject + Private m_container As CPersistentObject - Public Event ItemDirtied As EventHandler + Public Event ItemDirtied As EventHandler #Region "Collection Properties and Methods" - '''----------------------------------------------------------------------------- - ''' <summary> - ''' Back reference to the object that references (owns) this collection object. - ''' </summary> - ''' <value>A CPersistentObject that uses this collection</value> - ''' <remarks>When objects are added to or removed from the collection the - ''' dirty flag on the ContainerObject is set.</remarks> - ''' <history> - ''' [rbanks] 17/12/2003 Created - ''' </history> - '''----------------------------------------------------------------------------- + '''----------------------------------------------------------------------------- + ''' <summary> + ''' Back reference to the object that references (owns) this collection object. + ''' </summary> + ''' <value>A CPersistentObject that uses this collection</value> + ''' <remarks>When objects are added to or removed from the collection the + ''' dirty flag on the ContainerObject is set.</remarks> + ''' <history> + ''' [rbanks] 17/12/2003 Created + ''' </history> + '''----------------------------------------------------------------------------- <Browsable(False)> Public Property ContainerObject() As CPersistentObject Get Return m_container @@ -200,13 +200,13 @@ #End Region #Region "IBindlingList" - Public Overridable Sub AddIndex(ByVal [property] As System.ComponentModel.PropertyDescriptor) Implements System.ComponentModel.IBindingList.AddIndex + Public Overridable Sub AddIndex(ByVal [property] As System.ComponentModel.PropertyDescriptor) Implements System.ComponentModel.IBindingList.AddIndex - End Sub + End Sub - Public Overridable Function AddNew() As Object Implements System.ComponentModel.IBindingList.AddNew + Public Overridable Function AddNew() As Object Implements System.ComponentModel.IBindingList.AddNew - End Function + End Function <Browsable(False)> Public Overridable ReadOnly Property AllowEdit() As Boolean Implements System.ComponentModel.IBindingList.AllowEdit Get @@ -282,42 +282,42 @@ #End Region #Region "Collection Events" - Protected Overrides Sub OnInsertComplete(ByVal index As Integer, ByVal value As Object) - ' Debug.WriteLine("CPColl insert complete - attaching handlers") - AddHandler CType(value, CPersistentObject).RemoveMe, AddressOf Remove - AddHandler CType(value, CPersistentObject).MarkedAsDirty, AddressOf ItemDirtiedHandler - RaiseEvent ListChanged(Me, New ListChangedEventArgs(ListChangedType.ItemAdded, index)) - If Not (m_container Is Nothing) Then - m_container.SetDirtyFlag() - End If - End Sub + Protected Overrides Sub OnInsertComplete(ByVal index As Integer, ByVal value As Object) + ' Debug.WriteLine("CPColl insert complete - attaching handlers") + AddHandler CType(value, CPersistentObject).RemoveMe, AddressOf Remove + AddHandler CType(value, CPersistentObject).MarkedAsDirty, AddressOf ItemDirtiedHandler + RaiseEvent ListChanged(Me, New ListChangedEventArgs(ListChangedType.ItemAdded, index)) + If Not (m_container Is Nothing) Then + m_container.SetDirtyFlag() + End If + End Sub - Protected Overrides Sub OnClearComplete() - ' Debug.WriteLine("CPColl clear complete") - RaiseEvent ListChanged(Me, New ListChangedEventArgs(ListChangedType.Reset, 0)) - End Sub + Protected Overrides Sub OnClearComplete() + ' Debug.WriteLine("CPColl clear complete") + RaiseEvent ListChanged(Me, New ListChangedEventArgs(ListChangedType.Reset, 0)) + End Sub - Protected Overrides Sub OnRemoveComplete(ByVal index As Integer, ByVal value As Object) - ' Debug.WriteLine("CPColl Remove complete (" & index & ") : clearing event handlers") - ' RemoveHandler CType(value, CPersistentObject).MarkedAsDirty, AddressOf ItemDirtiedHandler - ' RemoveHandler CType(value, CPersistentObject).RemoveMe, AddressOf Remove - RaiseEvent ListChanged(Me, New ListChangedEventArgs(ListChangedType.ItemDeleted, index)) - If Not (m_container Is Nothing) Then - m_container.SetDirtyFlag() - End If - End Sub + Protected Overrides Sub OnRemoveComplete(ByVal index As Integer, ByVal value As Object) + ' Debug.WriteLine("CPColl Remove complete (" & index & ") : clearing event handlers") + ' RemoveHandler CType(value, CPersistentObject).MarkedAsDirty, AddressOf ItemDirtiedHandler + ' RemoveHandler CType(value, CPersistentObject).RemoveMe, AddressOf Remove + RaiseEvent ListChanged(Me, New ListChangedEventArgs(ListChangedType.ItemDeleted, index)) + If Not (m_container Is Nothing) Then + m_container.SetDirtyFlag() + End If + End Sub - Protected Overrides Sub OnSetComplete(ByVal index As Integer, ByVal oldValue As Object, ByVal newValue As Object) - 'Debug.WriteLine("CPColl set complete") - RaiseEvent ListChanged(Me, New ListChangedEventArgs(ListChangedType.ItemChanged, index)) - End Sub + Protected Overrides Sub OnSetComplete(ByVal index As Integer, ByVal oldValue As Object, ByVal newValue As Object) + 'Debug.WriteLine("CPColl set complete") + RaiseEvent ListChanged(Me, New ListChangedEventArgs(ListChangedType.ItemChanged, index)) + End Sub - Protected Overrides Sub OnClear() - ' Debug.WriteLine("CPColl clearing list") - For Each cp As CPersistentObject In list - RemoveHandler cp.MarkedAsDirty, AddressOf ItemDirtiedHandler - Next - End Sub + Protected Overrides Sub OnClear() + ' Debug.WriteLine("CPColl clearing list") + For Each cp As CPersistentObject In list + RemoveHandler cp.MarkedAsDirty, AddressOf ItemDirtiedHandler + Next + End Sub #End Region #Region "IComponent Interface" Index: CClassMap.vb =================================================================== RCS file: /cvsroot/jcframework/dotnet/CClassMap.vb,v retrieving revision 1.36 retrieving revision 1.37 diff -u -d -r1.36 -r1.37 --- CClassMap.vb 18 Oct 2004 03:31:51 -0000 1.36 +++ CClassMap.vb 27 Oct 2004 07:38:48 -0000 1.37 @@ -1565,12 +1565,12 @@ Catch ex As Exception End Try obj.SetAttributeValue(AttrMap.Name, tmpObj) + If Not IsDBNull(tmpObj) And Not tmpObj Is Nothing Then + obj.Persistent = True + End If End If Next i ClassMap = ClassMap.SuperClass - If Not IsDBNull(tmpObj) And Not tmpObj Is Nothing Then - obj.Persistent = True - End If Loop While Not ClassMap Is Nothing obj.IsProxy = True obj.IsDirty = False |
From: Richard B. <rb...@us...> - 2004-10-25 07:14:24
|
Update of /cvsroot/jcframework/Nunit/StandardClasses In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27457/StandardClasses Modified Files: NPEmployee.vb NPJob.vb NPTeam.vb NonInheritedTests.vb Log Message: Fix for cache problems when changing key values of objects that don't inherit from CPersistentObject Also fixed problem where many-to-many associations tried to save associationclass multiple times. Index: NPEmployee.vb =================================================================== RCS file: /cvsroot/jcframework/Nunit/StandardClasses/NPEmployee.vb,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- NPEmployee.vb 19 Oct 2004 00:13:38 -0000 1.1 +++ NPEmployee.vb 25 Oct 2004 07:14:15 -0000 1.2 @@ -3,29 +3,11 @@ Public Class NPEmployee Private m_name As String - Private m_parentoid As String + Private m_parentname As String Private m_parent As NPEmployee Private m_children As ArrayList - Private m_team As InheritedClasses.CTeam - Private m_teamoid As String - Private m_oid As AToMSFramework.COID - - Public Property OIDValue() As String - Get - Dim oidfactory As AToMSFramework.COIDFactory - If m_oid Is Nothing Then - oidfactory = AToMSFramework.modOIDFactorySingleton.getOIDFactoryInstance() - m_oid = oidfactory.newOID - End If - OIDValue = m_oid.OID - End Get - Set(ByVal value As String) - If m_oid Is Nothing Then - m_oid = New AToMSFramework.COID - End If - m_oid.OID = value - End Set - End Property + Private m_team As NPTeam + Private m_teamname As String Public Property Name() As String Get @@ -43,21 +25,21 @@ Set(ByVal Value As NPEmployee) If Not Value Is Nothing Then m_parent = Value - m_parentoid = Value.OIDValue + m_parentname = Value.Name End If End Set End Property - Public Property ReportsToOID() As String + Public Property ReportsToName() As String Get If m_parent Is Nothing Then - Return m_parentoid + Return m_parentname Else - Return (m_parent.OIDValue) + Return (m_parent.Name) End If End Get Set(ByVal Value As String) - m_parentoid = Value + m_parentname = Value End Set End Property @@ -70,28 +52,28 @@ End Set End Property - Public Property Team() As InheritedClasses.CTeam + Public Property Team() As NPTeam Get Return m_team End Get - Set(ByVal Value As InheritedClasses.CTeam) + Set(ByVal Value As NPTeam) If Not Value Is Nothing Then m_team = Value - m_teamoid = Value.OIDValue + m_teamname = Value.Name End If End Set End Property - Public Property TeamOID() As String + Public Property TeamName() As String Get If m_team Is Nothing Then - Return m_teamoid + Return m_teamname Else - Return (m_team.OIDValue) + Return (m_team.Name) End If End Get Set(ByVal Value As String) - m_teamoid = Value + m_teamname = Value End Set End Property Index: NPJob.vb =================================================================== RCS file: /cvsroot/jcframework/Nunit/StandardClasses/NPJob.vb,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- NPJob.vb 19 Oct 2004 00:13:38 -0000 1.1 +++ NPJob.vb 25 Oct 2004 07:14:15 -0000 1.2 @@ -23,27 +23,4 @@ End Class - Public Class NPJobWithOIDValue - Inherits NPJob - - Private m_oid As AToMSFramework.COID - - Public Property OIDValue() As String - Get - Dim oidfactory As AToMSFramework.COIDFactory - If m_oid Is Nothing Then - oidfactory = AToMSFramework.modOIDFactorySingleton.getOIDFactoryInstance() - m_oid = oidfactory.newOID - End If - OIDValue = m_oid.OID - End Get - Set(ByVal value As String) - If m_oid Is Nothing Then - m_oid = New AToMSFramework.COID - End If - m_oid.OID = value - End Set - End Property - - End Class End Namespace \ No newline at end of file Index: NPTeam.vb =================================================================== RCS file: /cvsroot/jcframework/Nunit/StandardClasses/NPTeam.vb,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- NPTeam.vb 19 Oct 2004 00:13:38 -0000 1.1 +++ NPTeam.vb 25 Oct 2004 07:14:15 -0000 1.2 @@ -2,29 +2,11 @@ Public Class NPTeam Private m_leader As NPEmployee - Private m_leaderoid As String + Private m_leadername As String Private m_name As String - Private m_job As NPJobWithOIDValue - Private m_joboid As String + Private m_job As NPJob + Private m_jobId As String Private m_members As ArrayList - Private m_oid As AToMSFramework.COID - - Public Property OIDValue() As String - Get - Dim oidfactory As AToMSFramework.COIDFactory - If m_oid Is Nothing Then - oidfactory = AToMSFramework.modOIDFactorySingleton.getOIDFactoryInstance() - m_oid = oidfactory.newOID - End If - OIDValue = m_oid.OID - End Get - Set(ByVal value As String) - If m_oid Is Nothing Then - m_oid = New AToMSFramework.COID - End If - m_oid.OID = value - End Set - End Property Public Property TeamLeader() As NPEmployee Get @@ -32,43 +14,43 @@ End Get Set(ByVal Value As NPEmployee) m_leader = Value - m_leaderoid = Value.OIDValue + m_leadername = Value.Name End Set End Property - Public Property TeamLeaderOID() As String + Public Property TeamLeaderName() As String Get If m_leader Is Nothing Then - Return m_leaderoid + Return m_leadername Else - Return (m_leader.OIDValue) + Return (m_leader.Name) End If End Get Set(ByVal Value As String) - m_leaderoid = Value + m_leadername = Value End Set End Property - Public Property Job() As NPJobWithOIDValue + Public Property Job() As NPJob Get Return m_job End Get - Set(ByVal Value As NPJobWithOIDValue) + Set(ByVal Value As NPJob) m_job = Value - m_joboid = Value.OIDValue + m_jobId = Value.Id End Set End Property - Public Property jobOID() As String + Public Property jobId() As String Get If m_job Is Nothing Then - Return m_joboid + Return m_jobId Else - Return (m_job.OIDValue) + Return (m_job.Id) End If End Get Set(ByVal Value As String) - m_joboid = Value + m_jobId = Value End Set End Property Index: NonInheritedTests.vb =================================================================== RCS file: /cvsroot/jcframework/Nunit/StandardClasses/NonInheritedTests.vb,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- NonInheritedTests.vb 21 Oct 2004 23:36:46 -0000 1.2 +++ NonInheritedTests.vb 25 Oct 2004 07:14:15 -0000 1.3 @@ -39,20 +39,18 @@ <Test()> Public Sub LoadJob_a1() job.Id = "a1" - pbroker.GetObject(job) + pbroker.GetObject(CType(job, NPJob)) Assert.IsTrue(pbroker.getInjectedObject(job).Persistent) Assert.AreEqual("basic", job.Description) End Sub <Test()> Public Sub FindJob_basic() - Dim job As New NPJobWithOIDValue + Dim job As New NPJob job.Description = "basic" - pbroker.FindObject(job) - Assert.AreEqual("000000160002", job.OIDValue) + pbroker.FindObject(CType(job, NPJob)) Assert.AreEqual("basic", job.Description) End Sub - <Test()> Public Sub SaveJob_a2() pbroker.StartTracking(job) job.Id = "a2" @@ -108,9 +106,8 @@ Assert.IsTrue(Not emp.ReportsTo Is Nothing) Assert.AreEqual(emp.ReportsTo.Name, "c") Dim emp2 As NPEmployee - emp2 = emp.ReportsTo.Workers(0) + emp2 = CType(emp.ReportsTo.Workers(0), NPEmployee) Assert.AreEqual(emp2.Name, emp.Name) - Assert.AreEqual(emp2.OIDValue, emp.OIDValue) Assert.AreSame(emp2, emp) End Sub @@ -119,7 +116,7 @@ pbroker.FindObject(emp) Assert.IsTrue(pbroker.getInjectedObject(emp).Persistent) Assert.AreEqual(emp.Workers.Count, 3) - emp = emp.Workers.Item(1) + emp = CType(emp.Workers.Item(1), NPEmployee) Assert.AreEqual(emp.Name, "aa") Assert.AreEqual(emp.ReportsTo.Name, "ac") End Sub @@ -143,11 +140,9 @@ End Sub <Test()> Public Sub LoadSaveandDeleteEmployee() - Dim oidvalue As String emp.Name = "new" pbroker.FindObject(emp) Assert.IsFalse(pbroker.getInjectedObject(emp).Persistent) - oidvalue = emp.OIDValue pbroker.PersistChanges(emp) Assert.IsTrue(pbroker.getInjectedObject(emp).Persistent) Assert.IsTrue(emp.ReportsTo Is Nothing) @@ -156,7 +151,6 @@ emp.Name = "new" pbroker.FindObject(emp) Assert.IsTrue(pbroker.getInjectedObject(emp).Persistent) - Assert.AreEqual(emp.OIDValue, oidvalue) Assert.AreEqual(emp.Name, "new") pbroker.MarkForDeletion(emp) pbroker.PersistChanges(emp) @@ -165,15 +159,12 @@ emp.Name = "new" pbroker.FindObject(emp) Assert.IsFalse(pbroker.getInjectedObject(emp).Persistent) - Assert.IsTrue(emp.OIDValue <> oidvalue) End Sub <Test()> Public Sub ChangeFindFieldValue() - Dim oidvalue As String emp.Name = "SaveThenChange" pbroker.FindObject(emp) Assert.IsFalse(pbroker.getInjectedObject(emp).Persistent) - oidvalue = emp.OIDValue pbroker.PersistChanges(emp) Assert.IsTrue(pbroker.getInjectedObject(emp).Persistent) Assert.IsTrue(emp.ReportsTo Is Nothing) @@ -181,7 +172,6 @@ emp.Name = "SaveThenChange" pbroker.FindObject(emp) Assert.IsTrue(pbroker.getInjectedObject(emp).Persistent) - Assert.AreEqual(emp.OIDValue, oidvalue) Assert.AreEqual(emp.Name, "SaveThenChange") emp.Name = "Changed" pbroker.PersistChanges(emp) @@ -217,7 +207,7 @@ pbroker.FindObject(emp) Assert.AreEqual("middleMgr", emp.ReportsTo.Name) Assert.AreEqual("theBoss", emp.ReportsTo.ReportsTo.Name) - emp2 = emp.ReportsTo.Workers(0) + emp2 = CType(emp.ReportsTo.Workers(0), NPEmployee) Assert.AreEqual("slave", emp2.Name) End Sub |
From: Richard B. <rb...@us...> - 2004-10-25 07:14:24
|
Update of /cvsroot/jcframework/Nunit/Interfaces In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27457/Interfaces Modified Files: EmployeeInterfaceTests.vb IEmployee.vb Log Message: Fix for cache problems when changing key values of objects that don't inherit from CPersistentObject Also fixed problem where many-to-many associations tried to save associationclass multiple times. Index: EmployeeInterfaceTests.vb =================================================================== RCS file: /cvsroot/jcframework/Nunit/Interfaces/EmployeeInterfaceTests.vb,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- EmployeeInterfaceTests.vb 19 Oct 2004 00:13:38 -0000 1.1 +++ EmployeeInterfaceTests.vb 25 Oct 2004 07:14:15 -0000 1.2 @@ -43,9 +43,8 @@ Assert.IsTrue(Not emp.ReportsTo Is Nothing) Assert.AreEqual(emp.ReportsTo.Name, "c") Dim emp2 As IEmployee - emp2 = emp.ReportsTo.Workers(0) + emp2 = CType(emp.ReportsTo.Workers(0), IEmployee) Assert.AreEqual(emp2.Name, emp.Name) - Assert.AreEqual(emp2.OIDValue, emp.OIDValue) Assert.AreSame(emp2, emp) End Sub @@ -54,7 +53,7 @@ pbroker.FindObject(emp) Assert.IsTrue(pbroker.getInjectedObject(emp).Persistent) Assert.AreEqual(emp.Workers.Count, 3) - emp = emp.Workers.Item(1) + emp = CType(emp.Workers.Item(1), IEmployee) Assert.AreEqual(emp.Name, "aa") Assert.AreEqual(emp.ReportsTo.Name, "ac") End Sub Index: IEmployee.vb =================================================================== RCS file: /cvsroot/jcframework/Nunit/Interfaces/IEmployee.vb,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- IEmployee.vb 19 Oct 2004 00:13:38 -0000 1.1 +++ IEmployee.vb 25 Oct 2004 07:14:15 -0000 1.2 @@ -1,42 +1,23 @@ Namespace Interfaces Public Interface IEmployee - Property OIDValue() As String Property Name() As String Property ReportsTo() As IEmployee - Property ReportsToOID() As String + Property ReportsToName() As String Property Workers() As ArrayList Property Team() As InheritedClasses.CTeam - Property TeamOID() As String + Property TeamName() As String End Interface Public Class EmployeeClass Implements IEmployee Private m_name As String - Private m_parentoid As String + Private m_parentName As String Private m_parent As IEmployee Private m_children As ArrayList Private m_team As InheritedClasses.CTeam - Private m_teamoid As String - Private m_oid As AToMSFramework.COID - - Public Property OIDValue() As String Implements IEmployee.OIDValue - Get - Dim oidfactory As AToMSFramework.COIDFactory - If m_oid Is Nothing Then - oidfactory = AToMSFramework.modOIDFactorySingleton.getOIDFactoryInstance() - m_oid = oidfactory.newOID - End If - OIDValue = m_oid.OID - End Get - Set(ByVal value As String) - If m_oid Is Nothing Then - m_oid = New AToMSFramework.COID - End If - m_oid.OID = value - End Set - End Property + Private m_teamName As String Public Property Name() As String Implements IEmployee.Name Get @@ -54,21 +35,21 @@ Set(ByVal Value As IEmployee) If Not Value Is Nothing Then m_parent = Value - m_parentoid = Value.OIDValue + m_parentName = Value.Name End If End Set End Property - Public Property ReportsToOID() As String Implements IEmployee.ReportsToOID + Public Property ReportsToName() As String Implements IEmployee.ReportsToName Get If m_parent Is Nothing Then - Return m_parentoid + Return m_parentName Else - Return (m_parent.OIDValue) + Return (m_parent.Name) End If End Get Set(ByVal Value As String) - m_parentoid = Value + m_parentName = Value End Set End Property @@ -88,21 +69,21 @@ Set(ByVal Value As InheritedClasses.CTeam) If Not Value Is Nothing Then m_team = Value - m_teamoid = Value.OIDValue + m_teamName = Value.OIDValue End If End Set End Property - Public Property TeamOID() As String Implements IEmployee.TeamOID + Public Property TeamName() As String Implements IEmployee.TeamName Get If m_team Is Nothing Then - Return m_teamoid + Return m_teamName Else Return (m_team.OIDValue) End If End Get Set(ByVal Value As String) - m_teamoid = Value + m_teamName = Value End Set End Property |
From: Richard B. <rb...@us...> - 2004-10-25 07:14:24
|
Update of /cvsroot/jcframework/Nunit In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27457 Modified Files: AtomsFramework.xml Nunit_AtomsFramework.vbproj original db1.mdb Log Message: Fix for cache problems when changing key values of objects that don't inherit from CPersistentObject Also fixed problem where many-to-many associations tried to save associationclass multiple times. Index: Nunit_AtomsFramework.vbproj =================================================================== RCS file: /cvsroot/jcframework/Nunit/Nunit_AtomsFramework.vbproj,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- Nunit_AtomsFramework.vbproj 20 Oct 2004 06:43:40 -0000 1.10 +++ Nunit_AtomsFramework.vbproj 25 Oct 2004 07:14:12 -0000 1.11 @@ -140,6 +140,16 @@ BuildAction = "Compile" /> <File + RelPath = "InheritedClasses\ManyToManyClasses.vb" + SubType = "Code" + BuildAction = "Compile" + /> + <File + RelPath = "InheritedClasses\ManyToManyTests.vb" + SubType = "Code" + BuildAction = "Compile" + /> + <File RelPath = "InheritedClasses\MultiRetrieveTestClasses.vb" SubType = "Code" BuildAction = "Compile" Index: original db1.mdb =================================================================== RCS file: /cvsroot/jcframework/Nunit/original db1.mdb,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 Binary files /tmp/cvsoWb2Wq and /tmp/cvs2UuJKu differ Index: AtomsFramework.xml =================================================================== RCS file: /cvsroot/jcframework/Nunit/AtomsFramework.xml,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- AtomsFramework.xml 21 Oct 2004 23:36:45 -0000 1.9 +++ AtomsFramework.xml 25 Oct 2004 07:14:12 -0000 1.10 @@ -19,65 +19,58 @@ <attribute name="Id" column="id" key="primary"/> <attribute name="Description" column="description"/> </class> -<class name="NPJobWithOIDValue" table="jobs" database="MSA" namespace="NunitTests.StandardClasses"> - <attribute name="OIDValue" column="oidvalue" key="primary"/> - <attribute name="Description" column="description" find="true"/> -</class> -<class name="NPEmployee" table="employee" database="MSA" namespace="NunitTests.StandardClasses"> - <attribute name="OIDValue" column="oid" key="primary"/> - <attribute name="Name" column="name" find="true"/> - <attribute name="ReportsToOID" column="parentoid" /> - <attribute name="TeamOID" column="teamoid" /> +<class name="NPEmployee" table="NPEmployee" database="MSA" namespace="NunitTests.StandardClasses"> + <attribute name="Name" column="name" find="true" key="primary"/> + <attribute name="ReportsToName" column="parentname" /> + <attribute name="TeamName" column="teamname" /> <attribute name="Team" /> <attribute name="ReportsTo" /> <attribute name="Workers" /> </class> -<class name="NPTeam" table="teams" database="MSA" namespace="NunitTests.StandardClasses"> - <attribute name="OIDValue" column="oidvalue" key="primary"/> - <attribute name="Name" column="teamname" find="true"/> - <attribute name="TeamLeaderOID" column="teamleader" /> - <attribute name="jobOID" column="joboidvalue" /> +<class name="NPTeam" table="NPTeams" database="MSA" namespace="NunitTests.StandardClasses"> + <attribute name="Name" column="teamname" find="true" key="primary"/> + <attribute name="TeamLeaderName" column="teamleader" /> + <attribute name="jobId" column="jobid" /> <attribute name="TeamLeader" /> <attribute name="Job" /> </class> <association fromClass="NunitTests.StandardClasses.NPEmployee" toClass="NunitTests.StandardClasses.NPEmployee" target="ReportsTo" cardinality="OneToOne" retrieveAutomatic="true" saveAutomatic="true" deleteAutomatic="false" inverse="false"> - <entry fromAttribute="ReportsToOID" toAttribute="OIDValue"/> + <entry fromAttribute="ReportsToName" toAttribute="Name"/> </association> <association fromClass="NunitTests.StandardClasses.NPEmployee" toClass="NunitTests.StandardClasses.NPEmployee" target="Workers" cardinality="OneToMany" retrieveAutomatic="true" saveAutomatic="true" deleteAutomatic="false" inverse="false"> - <entry fromAttribute="OIDValue" toAttribute="ReportsToOID"/> + <entry fromAttribute="Name" toAttribute="ReportsToName"/> </association> <association fromClass="NunitTests.StandardClasses.NPTeam" toClass="NunitTests.StandardClasses.NPEmployee" target="TeamLeader" cardinality="OneToOne" retrieveAutomatic="true" saveAutomatic="false" deleteAutomatic="false" inverse="false"> - <entry fromAttribute="TeamLeaderOID" toAttribute="OIDValue"/> + <entry fromAttribute="TeamLeaderName" toAttribute="Name"/> </association> -<association fromClass="NunitTests.StandardClasses.NPTeam" toClass="NunitTests.StandardClasses.NPJobWithOIDValue" target="Job" cardinality="OneToOne" +<association fromClass="NunitTests.StandardClasses.NPTeam" toClass="NunitTests.StandardClasses.NPJob" target="Job" cardinality="OneToOne" retrieveAutomatic="true" saveAutomatic="false" deleteAutomatic="false" inverse="false"> - <entry fromAttribute="jobOID" toAttribute="OIDValue"/> + <entry fromAttribute="jobId" toAttribute="Id"/> </association> <association fromClass="NunitTests.StandardClasses.NPTeam" toClass="NunitTests.StandardClasses.NPEmployee" target="Members" cardinality="OneToMany" retrieveAutomatic="true" saveAutomatic="false" deleteAutomatic="false" inverse="false"> - <entry fromAttribute="OIDValue" toAttribute="TeamOID"/> + <entry fromAttribute="Name" toAttribute="TeamName"/> </association> -<class name="IEmployee" table="employee" database="MSA" factory="IEmployeeFactory" namespace="NunitTests.Interfaces"> - <attribute name="OIDValue" column="oid" key="primary"/> - <attribute name="Name" column="name" find="true"/> - <attribute name="ReportsToOID" column="parentoid" /> - <attribute name="TeamOID" column="teamoid" /> +<class name="IEmployee" table="NPEmployee" database="MSA" factory="IEmployeeFactory" namespace="NunitTests.Interfaces"> + <attribute name="Name" column="name" key="primary" find="true"/> + <attribute name="ReportsToName" column="parentname" /> + <attribute name="TeamName" column="teamname" /> <attribute name="Team" /> <attribute name="ReportsTo" /> <attribute name="Workers" /> </class> <association fromClass="NunitTests.Interfaces.IEmployee" toClass="NunitTests.Interfaces.IEmployee" target="ReportsTo" cardinality="OneToOne" retrieveAutomatic="true" saveAutomatic="true" deleteAutomatic="false" inverse="false"> - <entry fromAttribute="ReportsToOID" toAttribute="OIDValue"/> + <entry fromAttribute="ReportsToName" toAttribute="Name"/> </association> <association fromClass="NunitTests.Interfaces.IEmployee" toClass="NunitTests.Interfaces.IEmployee" target="Workers" cardinality="OneToMany" retrieveAutomatic="true" saveAutomatic="true" deleteAutomatic="false" inverse="false"> - <entry fromAttribute="OIDValue" toAttribute="ReportsToOID"/> + <entry fromAttribute="Name" toAttribute="ReportsToName"/> </association> @@ -248,4 +241,46 @@ <entry fromAttribute="COID" toAttribute="OIDValue"/> </association> + + <class name="ManyToManyA" table="ManyToManyA" database="MSA" namespace="NunitTests.InheritedClasses"> + <attribute name="GUIDValue" column="GuidValue" key="primary"/> + <attribute name="Description" column="description" /> + <attribute name="M2MABCollection" /> + </class> + <class name="ManyToManyB" table="ManyToManyB" database="MSA" namespace="NunitTests.InheritedClasses"> + <attribute name="GUIDValue" column="GuidValue" key="primary"/> + <attribute name="Description" column="description" /> + <attribute name="M2MABCollection" /> + </class> + <class name="ManyToManyAB" table="ManyToManyAB" database="MSA" namespace="NunitTests.InheritedClasses"> + <attribute name="AGuidValue" column="AGuidValue" key="primary"/> + <attribute name="BGuidValue" column="BGuidValue" key="primary"/> + <attribute name="M2MA"/> + <attribute name="M2MB"/> + </class> + <association fromClass="NunitTests.InheritedClasses.ManyToManyA" + toClass="NunitTests.InheritedClasses.ManyToManyAB" + cardinality="OneToMany" target="M2MABCollection" + retrieveAutomatic="True" saveAutomatic="true" deleteAutomatic="true" inverse="false"> + <entry fromAttribute="GUIDValue" toAttribute="AGuidValue"/> + </association> + <association fromClass="NunitTests.InheritedClasses.ManyToManyB" + toClass="NunitTests.InheritedClasses.ManyToManyAB" + cardinality="OneToMany" target="M2MABCollection" + retrieveAutomatic="True" saveAutomatic="true" deleteAutomatic="true" inverse="false"> + <entry fromAttribute="GUIDValue" toAttribute="BGuidValue"/> + </association> + <association fromClass="NunitTests.InheritedClasses.ManyToManyAB" + toClass="NunitTests.InheritedClasses.ManyToManyA" + cardinality="OneToOne" target="M2MA" + retrieveAutomatic="True" saveAutomatic="true" deleteAutomatic="true" inverse="false"> + <entry fromAttribute="AGuidValue" toAttribute="GUIDValue"/> + </association> + <association fromClass="NunitTests.InheritedClasses.ManyToManyAB" + toClass="NunitTests.InheritedClasses.ManyToManyB" + cardinality="OneToOne" target="M2MB" + retrieveAutomatic="True" saveAutomatic="true" deleteAutomatic="true" inverse="false"> + <entry fromAttribute="BGuidValue" toAttribute="GUIDValue"/> + </association> + </map> \ No newline at end of file |
From: Richard B. <rb...@us...> - 2004-10-25 07:14:24
|
Update of /cvsroot/jcframework/Nunit/InheritedClasses In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27457/InheritedClasses Modified Files: AtomsFrameworkTests.vb MultiRetrieveTestClasses.vb SharedTests.vb Added Files: ManyToManyClasses.vb ManyToManyTests.vb Log Message: Fix for cache problems when changing key values of objects that don't inherit from CPersistentObject Also fixed problem where many-to-many associations tried to save associationclass multiple times. --- NEW FILE: ManyToManyClasses.vb --- Imports AToMSFramework Namespace InheritedClasses #Region "ManyToManyA" Public Class ManyToManyA Inherits CPersistentObject Private _description As String Private _abCol As M2MABCollection Public Property Description() As String Get Return _description End Get Set(ByVal Value As String) _description = Value SetDirtyFlag() End Set End Property Public Property M2MABCollection() As M2MABCollection Get Return _abCol End Get Set(ByVal Value As M2MABCollection) _abCol = Value End Set End Property Public Overrides Function getNewObject() As AToMSFramework.CPersistentObject Return New ManyToManyA End Function Public Overrides Function IsValid() As Boolean Return True End Function Public Sub New() _abCol = New M2MABCollection _abCol.ContainerObject = Me End Sub Default Public Overrides ReadOnly Property Item(ByVal columnName As String) As String Get End Get End Property End Class #End Region #Region "ManyToManyB" Public Class ManyToManyB Inherits CPersistentObject Private _description As String Private _abCol As M2MABCollection Public Property Description() As String Get Return _description End Get Set(ByVal Value As String) _description = Value SetDirtyFlag() End Set End Property Public Property M2MABCollection() As M2MABCollection Get Return _abCol End Get Set(ByVal Value As M2MABCollection) _abCol = Value End Set End Property Public Overrides Function getNewObject() As AToMSFramework.CPersistentObject Return New ManyToManyAB End Function Public Overrides Function IsValid() As Boolean Return True End Function Public Sub New() _abCol = New M2MABCollection _abCol.ContainerObject = Me End Sub End Class #End Region #Region "ManyToManyAB" Public Class ManyToManyAB Inherits CPersistentObject Private _aGuid As Guid = Guid.Empty Private _bGuid As Guid = Guid.Empty Private _a As ManyToManyA Private _b As ManyToManyB Public Property AGuidValue() As String Get If _aGuid.Equals(Guid.Empty) Then _aGuid = Guid.NewGuid End If Return _aGuid.ToString("N") End Get Set(ByVal value As String) _aGuid = New Guid(value) SetDirtyFlag() End Set End Property Public Property BGuidValue() As String Get If _bGuid.Equals(Guid.Empty) Then _bGuid = Guid.NewGuid End If Return _bGuid.ToString("N") End Get Set(ByVal value As String) _bGuid = New Guid(value) SetDirtyFlag() End Set End Property Public Property M2MA() As ManyToManyA Get Return _a End Get Set(ByVal Value As ManyToManyA) _a = Value AGuidValue = _a.GUIDValue End Set End Property Public Property M2MB() As ManyToManyB Get Return _b End Get Set(ByVal Value As ManyToManyB) _b = Value BGuidValue = _b.GUIDValue End Set End Property Public Overrides Function getNewObject() As AToMSFramework.CPersistentObject Return New ManyToManyAB End Function Public Overrides Function IsValid() As Boolean Return True End Function End Class #End Region #Region "M2MABCollection" Public Class M2MABCollection Inherits CPersistentCollection Public Overloads Sub Add(ByVal ab As ManyToManyAB) MyBase.Add(ab) End Sub Public Overloads Sub Add(ByVal b As ManyToManyB) Dim ab As ManyToManyAB If Me.ContainerObject.GetType Is GetType(ManyToManyA) Then ab = New ManyToManyAB ab.M2MA = CType(Me.ContainerObject, ManyToManyA) ab.M2MB = b If Not list.Contains(ab) Then Add(ab) Else Throw New Exception("The b object is already in the collection") End If Else Throw New Exception("This collection belongs to a B object. Add an A instead") End If End Sub Public Overloads Sub Add(ByVal a As ManyToManyA) Dim ab As ManyToManyAB If Me.ContainerObject.GetType Is GetType(ManyToManyB) Then ab = New ManyToManyAB ab.M2MA = a ab.M2MB = CType(Me.ContainerObject, ManyToManyB) If Not list.Contains(ab) Then Add(ab) Else Throw New Exception("The A object is already in the collection") End If Else Throw New Exception("This collection belongs to an A object. Add a B instead") End If End Sub Public Shadows Function Item(ByVal index As Integer) As ManyToManyAB Return CType(MyBase.Item(index), ManyToManyAB) End Function End Class #End Region End Namespace Index: SharedTests.vb =================================================================== RCS file: /cvsroot/jcframework/Nunit/InheritedClasses/SharedTests.vb,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- SharedTests.vb 19 Oct 2004 03:30:42 -0000 1.2 +++ SharedTests.vb 25 Oct 2004 07:14:15 -0000 1.3 @@ -48,7 +48,7 @@ sc = New SharedChild newOid = sc.OIDValue sc.OIDValue = origOid - result = sc.Retrieve(sc) + result = sc.Retrieve() Assert.IsTrue(sc.OIDValue = origOid) Assert.IsTrue(origOid <> newOid) Assert.IsTrue(result) @@ -64,7 +64,7 @@ sc.Save() origOid = sc.OIDValue sp.OIDValue = origOid - result = sp.Retrieve(sp) + result = sp.Retrieve() Assert.IsTrue(sp.OIDValue = origOid) Assert.IsTrue(result) Assert.IsFalse(sp.IsDirty) --- NEW FILE: ManyToManyTests.vb --- Imports AToMSFramework Imports NUnit.Framework Namespace InheritedClasses <TestFixture()> Public Class ManyToManyTests Private pbroker As CPersistenceBroker Private A As ManyToManyA Private B As ManyToManyB Private mrc As CMultiRetrieveCriteria Private rc As CRetrieveCriteria Private c As CCursor <TestFixtureSetUp()> Public Sub Init() Environment.CurrentDirectory = "C:\Projects\MMM\Nunit_AtomsFramework" Dim retry As Boolean = True While retry = True Try 'Remove any existing test database System.IO.File.Delete(".\db1.mdb") retry = False Catch iox As IO.IOException 'file is in use - so we will loop around until it is released GC.Collect() Catch ex As Exception retry = False End Try End While System.IO.File.Copy(".\original db1.mdb", ".\db1.mdb") pbroker = New CPersistenceBroker pbroker.init() End Sub <TestFixtureTearDown()> Public Sub Dispose() pbroker.Dispose() pbroker = Nothing End Sub <Test()> Public Sub SaveThenRetrieve() Dim gval As String Dim x As Integer, y As Integer A = New ManyToManyA A.Description = "A-one" gval = A.GUIDValue B = New ManyToManyB B.Description = "B-one" A.M2MABCollection.Add(B) B.M2MABCollection.Add(A) Dim B2 As ManyToManyB = New ManyToManyB B2.Description = "B-two" A.M2MABCollection.Add(B2) Dim A2 As ManyToManyA = New ManyToManyA A2.Description = "A-two" B2.M2MABCollection.Add(A2) A.Save() pbroker.ClearCache() A = New ManyToManyA A.GUIDValue = gval A.Retrieve() Assert.AreEqual(2, A.M2MABCollection.Count) 'Order of guids can affect order of the collection If A.M2MABCollection.Item(0).M2MB.M2MABCollection.Count = 1 Then x = 0 y = 1 Else x = 1 y = 0 End If B = A.M2MABCollection.Item(x).M2MB Assert.IsNotNull(B) Assert.AreEqual("B-one", B.Description) Assert.AreEqual(1, B.M2MABCollection.Count) Assert.IsTrue(A.Equals(B.M2MABCollection.Item(0).M2MA)) B = A.M2MABCollection.Item(y).M2MB Assert.IsNotNull(B) Assert.AreEqual("B-two", B.Description) Assert.AreEqual(2, B.M2MABCollection.Count) End Sub End Class End Namespace Index: MultiRetrieveTestClasses.vb =================================================================== RCS file: /cvsroot/jcframework/Nunit/InheritedClasses/MultiRetrieveTestClasses.vb,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- MultiRetrieveTestClasses.vb 19 Oct 2004 03:30:42 -0000 1.1 +++ MultiRetrieveTestClasses.vb 25 Oct 2004 07:14:14 -0000 1.2 @@ -101,7 +101,7 @@ Return _field2 End Get Set(ByVal Value As Integer) - _field1 = Value + _field2 = Value End Set End Property @@ -171,7 +171,7 @@ Return _field2 End Get Set(ByVal Value As Integer) - _field1 = Value + _field2 = Value End Set End Property Index: AtomsFrameworkTests.vb =================================================================== RCS file: /cvsroot/jcframework/Nunit/InheritedClasses/AtomsFrameworkTests.vb,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- AtomsFrameworkTests.vb 21 Oct 2004 23:36:46 -0000 1.3 +++ AtomsFrameworkTests.vb 25 Oct 2004 07:14:14 -0000 1.4 @@ -130,7 +130,7 @@ emp.Find() Assert.IsTrue(emp.Persistent) Assert.AreEqual(emp.Workers.Count, 3) - emp = emp.Workers.Item(1) + emp = CType(emp.Workers.Item(1), CEmployee) Assert.AreEqual(emp.Name, "aa") Assert.AreEqual(emp.ReportsTo.Name, "ac") End Sub |
Update of /cvsroot/jcframework/dotnet In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27280 Modified Files: CInjectedObject.vb CInjectedObjects.vb CJoin.vb COID.vb COIDFactory.vb CPersistenceBroker.vb CPersistentObject.vb CXMLConfigLoader.vb Log Message: Fix for cache problems when changing key values of objects that don't inherit from CPersistentObject Also fixed problem where many-to-many associations tried to save associationclass multiple times. Index: CPersistenceBroker.vb =================================================================== RCS file: /cvsroot/jcframework/dotnet/CPersistenceBroker.vb,v retrieving revision 1.72 retrieving revision 1.73 diff -u -d -r1.72 -r1.73 --- CPersistenceBroker.vb 22 Oct 2004 05:33:17 -0000 1.72 +++ CPersistenceBroker.vb 25 Oct 2004 07:12:31 -0000 1.73 @@ -774,6 +774,11 @@ obj.IsDirty = False obj.IsQueued = False 'Update cache key in-case primary key fields have changed value + If Not obj.GetObjectType.IsSubclassOf(GetType(CPersistentObject)) Then + If Not obj.OriginalCacheKey Is Nothing Then + m_cache.Remove(obj.OriginalCacheKey) + End If + End If obj.OriginalCacheKey = New CCacheKey(obj) If m_useCache Then m_cache.Add(obj) 'Add to the cache @@ -2477,6 +2482,8 @@ Dim value As IPersistableObject Dim queue As Queue Dim injObj As CInjectedObject + Dim ckey As CCacheKey + Dim savedKeys As New ArrayList injObj = m_injectedObjects.LocateObject(obj) If injObj Is Nothing Then @@ -2496,7 +2503,14 @@ Do While queue.Count > 0 value = queue.Dequeue() Try - saveObject(value) + ckey = New CCacheKey(value) + If savedKeys.Contains(ckey) Then + 'object was already saved (could be new object referenced by multiple other new objects) + Debug.WriteLine("The object with key " & ckey.ToString & " was already saved once") + Else + saveObject(value) + savedKeys.Add(ckey) + End If Catch ex As Exception 'After an error remove the cached object so that the next retrieve ' will refresh the cache with the item from the database Index: CInjectedObjects.vb =================================================================== RCS file: /cvsroot/jcframework/dotnet/CInjectedObjects.vb,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- CInjectedObjects.vb 15 Oct 2004 06:42:56 -0000 1.2 +++ CInjectedObjects.vb 25 Oct 2004 07:12:31 -0000 1.3 @@ -7,38 +7,42 @@ Private m_keyvalues As Collection Public Sub New(ByVal obj As Object) - m_keyvalues = New Collection - m_hashCode = obj.GetHashCode - Dim injObj As New CInjectedObject(obj) - populateKey(injObj) + If obj.GetType Is GetType(CInjectedObject) Then + NewInjObj(CType(obj, CInjectedObject)) + Else + m_keyvalues = New Collection + m_hashCode = obj.GetHashCode + Dim injObj As New CInjectedObject(obj) + populateKey(injObj) + End If End Sub - Public Sub New(ByVal obj As CInjectedObject) + Public Sub NewInjObj(ByVal injobj As CInjectedObject) m_keyvalues = New Collection - If obj.ReferencedObject Is Nothing Then + If injobj.ReferencedObject Is Nothing Then m_hashCode = 0 Else - m_hashCode = obj.ReferencedObject.GetHashCode + m_hashCode = injobj.ReferencedObject.GetHashCode End If - populateKey(obj) + populateKey(injobj) End Sub Public Overrides Function GetHashCode() As Integer Return m_hashCode End Function - Protected Sub populateKey(ByVal obj As IPersistableObject) + Protected Sub populateKey(ByVal injObj As IPersistableObject) Dim cm As CClassMap - Dim i As Integer + Dim i As Short Dim am As CAttributeMap Dim x As Object m_keyvalues = New Collection - m_type = obj.GetObjectType - cm = obj.getClassMap + m_type = injObj.GetObjectType + cm = injObj.GetClassMap For i = 1 To cm.getKeySize am = cm.getKeyAttributeMap(i) - x = obj.getValueByAttribute(am.Name) + x = injObj.GetValueByAttribute(am.Name) m_keyvalues.Add(x) Next End Sub @@ -47,8 +51,8 @@ Dim flag As Boolean Dim i As Integer Dim key1, key2 As CInjectedObjectKey - key1 = obj1 - key2 = obj2 + key1 = CType(obj1, CInjectedObjectKey) + key2 = CType(obj2, CInjectedObjectKey) Return key1.Equals(key2) End Function @@ -56,7 +60,7 @@ Dim flag As Boolean Dim i As Integer Dim key As CInjectedObjectKey - key = obj1 + key = CType(obj1, CInjectedObjectKey) flag = False For i = 1 To m_keyvalues.Count If Me.GetHashCode <> key.GetHashCode Then @@ -117,7 +121,7 @@ Dim injObj As CInjectedObject injKey = New CInjectedObjectKey(obj) If Not (MyBase.Item(injKey) Is Nothing) Then - injObj = MyBase.Item(injKey) + injObj = CType(MyBase.Item(injKey), CInjectedObject) Return injObj Else Return Nothing @@ -152,11 +156,12 @@ Dim injObj As CInjectedObject Dim x As DictionaryEntry Dim attrmap As CAttributeMap - Dim i As Integer + Dim i As Short Dim found As Boolean Dim cm As CClassMap Dim t As Type Dim interval As Double + Dim ikey As CInjectedObjectKey cm = obj.getClassMap @@ -164,14 +169,14 @@ Dim m_Enumerator As Collections.IEnumerator = Me.GetEnumerator() While m_Enumerator.MoveNext() - x = m_Enumerator.Current - injObj = x.Value + x = CType(m_Enumerator.Current, DictionaryEntry) + injObj = CType(x.Value, CInjectedObject) t = injObj.GetObjectType If t Is obj.GetObjectType Or t.IsSubclassOf(obj.GetObjectType) Then found = True If useFindAttributes Then For i = 1 To cm.getFindSize - attrmap = cm.FindAttributeMaps(i) + attrmap = CType(cm.FindAttributeMaps(i), CAttributeMap) If Not obj.getValueByAttribute(attrmap.Name).Equals(injObj.getValueByAttribute(attrmap.Name)) Then found = False Exit For @@ -179,7 +184,7 @@ Next i Else For i = 1 To cm.getKeySize - attrmap = cm.KeyAttributeMaps(i) + attrmap = CType(cm.KeyAttributeMaps(i), CAttributeMap) If Not obj.getValueByAttribute(attrmap.Name).Equals(injObj.getValueByAttribute(attrmap.Name)) Then found = False Exit For @@ -190,7 +195,8 @@ 'If ce.TransactionType = CCacheEntry.CacheTransaction.Deleted Then ' Return Nothing 'End If - Debug.WriteLine([String].Format("Injection Cache - getting {0} object from cache. Key..." & vbCrLf & x.Key.ToString, x.Key.ObjType.Name)) + ikey = CType(x.Key, CInjectedObjectKey) + Debug.WriteLine([String].Format("Injection Cache - getting object from cache. Key..." & vbCrLf & ikey.ToString)) Return injObj End If End If @@ -218,9 +224,9 @@ outString = ">>>> START TRACKED OBJECTS DUMP <<<<" & vbCrLf i = 1 For Each x In Me - injObj = x.Value + injObj = CType(x.Value, CInjectedObject) t = injObj.GetObjectType - key = x.Key + key = CType(x.Key, CInjectedObjectKey) outString &= i.ToString & "> " & t.ToString & vbCrLf & injObj.ToString & vbCrLf i += 1 Next x Index: CXMLConfigLoader.vb =================================================================== RCS file: /cvsroot/jcframework/dotnet/CXMLConfigLoader.vb,v retrieving revision 1.25 retrieving revision 1.26 diff -u -d -r1.25 -r1.26 --- CXMLConfigLoader.vb 19 Oct 2004 01:59:57 -0000 1.25 +++ CXMLConfigLoader.vb 25 Oct 2004 07:12:32 -0000 1.26 @@ -619,8 +619,7 @@ Loop fromClassMap.addAssociationMap(udaAm) Else - Throw New XMLMappingException("Error in association definition: Missing FromClass, ToClass or Target attributes") - End If - + Throw New XMLMappingException([String].Format("Error in association definition: Missing FromClass({0}), ToClass({1}) or Target({2}) attributes", attrFromClass, attrToClass, attrTarget)) + End If End Sub End Class \ No newline at end of file Index: CJoin.vb =================================================================== RCS file: /cvsroot/jcframework/dotnet/CJoin.vb,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- CJoin.vb 19 Oct 2004 03:32:08 -0000 1.8 +++ CJoin.vb 25 Oct 2004 07:12:31 -0000 1.9 @@ -269,14 +269,14 @@ Dim s As String Dim tm As CTableMap Dim cm As CClassMap - Dim i, j As Integer + Dim i, j As Short Dim udaEntry As CUDAMapEntry - Dim db As CRelationalDatabase + Dim db As _CRelationalDatabase Dim leftBracket As String = "(" Dim rightBracket As String = ")" If LeftSide Is Nothing Then - tm = RightSide.Tables.Item(1) + tm = CType(RightSide.Tables.Item(1), CTableMap) s = RightSide.RelationalDatabase.getClauseStringTableAlias(tm.Name, tm.TableOwner, TableAlias) Else If IsSuperClass Then @@ -286,7 +286,7 @@ leftBracket = "" rightBracket = "" End If - tm = RightSide.Tables.Item(1) + tm = CType(RightSide.Tables.Item(1), CTableMap) s = leftBracket & LeftSide.GetSQLString & " " & db.getClauseStringLeftJoin _ & " " & db.getClauseStringTableAlias(tm.Name, tm.TableOwner, TableAlias) & " " & db.getClauseStringOn & " " For i = 1 To cm.getReferenceSize @@ -307,7 +307,7 @@ leftBracket = "" rightBracket = "" End If - tm = RightSide.Tables.Item(1) + tm = CType(RightSide.Tables.Item(1), CTableMap) s = leftBracket & LeftSide.GetSQLString & " " & db.getClauseStringLeftJoin & " " & db.getClauseStringTableAlias(tm.Name, tm.TableOwner, TableAlias) & " " & db.getClauseStringOn & " " For i = 1 To cm.getReferenceSize If i > 1 Then @@ -324,10 +324,10 @@ leftBracket = "" rightBracket = "" End If - tm = cm.Tables.Item(1) + tm = CType(cm.Tables.Item(1), CTableMap) s = leftBracket & LeftSide.GetSQLString & " " & db.getClauseStringLeftJoin _ & " " & db.getClauseStringTableAlias(tm.Name, tm.TableOwner, TableAlias) & " " & db.getClauseStringOn & " " - For i = 1 To Association.Entries.Count + For i = 1 To CType(Association.Entries.Count, Short) If i > 1 Then s = s & " " & db.getClauseStringAnd & " " End If Index: COID.vb =================================================================== RCS file: /cvsroot/jcframework/dotnet/COID.vb,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- COID.vb 21 Jul 2004 02:55:38 -0000 1.4 +++ COID.vb 25 Oct 2004 07:12:31 -0000 1.5 @@ -89,7 +89,7 @@ m_aValueString = Value.Substring(0, 8) m_bValueString = Value.Substring(8) m_aValue = CInt("&H" & m_aValueString) - m_bValue = CInt("&H" & m_bValueString) + m_bValue = CShort("&H" & m_bValueString) End Set End Property End Class Index: COIDFactory.vb =================================================================== RCS file: /cvsroot/jcframework/dotnet/COIDFactory.vb,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- COIDFactory.vb 21 Jul 2004 02:55:38 -0000 1.3 +++ COIDFactory.vb 25 Oct 2004 07:12:31 -0000 1.4 @@ -35,7 +35,7 @@ Dim oid As New COID oid.AValue = fetchAValue() Try - m_nextBValue += 1 + m_nextBValue += 1S Catch m_fetchedAValue = False oid.AValue = fetchAValue() ' get a new A value @@ -65,7 +65,7 @@ If m_fetchedAValue = False Then persistenceBroker = getPersistenceBrokerInstance() For Each de In persistenceBroker.Databases - reldb = de.Value + reldb = CType(de.Value, _CRelationalDatabase) 'Just use the first database with an OID setting to get the AValue If reldb.OIDTable.Length > 0 Then m_nextAValue = reldb.getNextOIDAValue Index: CInjectedObject.vb =================================================================== RCS file: /cvsroot/jcframework/dotnet/CInjectedObject.vb,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- CInjectedObject.vb 20 Oct 2004 06:44:23 -0000 1.4 +++ CInjectedObject.vb 25 Oct 2004 07:12:31 -0000 1.5 @@ -61,7 +61,7 @@ End If Dim injObj As CInjectedObject If TypeOf (obj) Is CInjectedObject Then - injObj = obj + injObj = CType(obj, CInjectedObject) ReplaceValues(injObj.m_object, m_object) Else ReplaceValues(obj, m_object) @@ -363,7 +363,7 @@ dotPos = pName.IndexOf(".") Try If dotPos = -1 Then - Return CallByName(m_object, pName, CallType.Get) + Return CType(CallByName(m_object, pName, CallType.Get), IList) Else Dim o As Object Dim objName As String @@ -371,7 +371,7 @@ objName = pName.Substring(0, dotPos) propertyName = pName.Substring(dotPos + 1) o = CallByName(m_object, objName, CallType.Get) - Return CallByName(o, propertyName, CallType.Get) + Return CType(CallByName(o, propertyName, CallType.Get), IList) End If Catch err As Exception Throw New Exception("getCollectionByAttribute failed", err) @@ -398,7 +398,7 @@ End If If obj Is Nothing Then Return Nothing If obj.GetType.IsSubclassOf(GetType(IPersistableObject)) Then - injobj = obj + injobj = CType(obj, CInjectedObject) Else pbroker = getPersistenceBrokerInstance() injobj = pbroker.getInjectedObject(obj) @@ -470,7 +470,7 @@ Public Function Copy() As IPersistableObject Implements IPersistableObject.Copy 'Dim m_object2 As Object Dim injobj As CInjectedObject - injobj = Me.MemberwiseClone + injobj = CType(Me.MemberwiseClone, CInjectedObject) 'm_object2 = Activator.CreateInstance(m_object.GetType) 'ReplaceValues(m_object, m_object2) 'injobj = New CInjectedObject(m_object2) @@ -484,7 +484,7 @@ Function getObjectByClassMap(ByVal classMap As CClassMap) As IPersistableObject Implements IPersistableObject.getObjectByClassMap Dim obj, Value As IPersistableObject Dim col As IList - Dim i, k As Integer + Dim i, k As Short Dim cm As CClassMap Dim de As DictionaryEntry Dim udamap As CUDAMap @@ -509,7 +509,7 @@ Next i 'set object's attributes - For i = 1 To classMap.AttributeMaps.Count + For i = 1 To CType(classMap.AttributeMaps.Count, Short) obj.SetAttributeValue(classMap.getAttributeMap(i).Name, Me.getValueByAttribute(classMap.getAttributeMap(i).Name)) Next @@ -529,7 +529,7 @@ Next i 'set superclass's attributes - For i = 1 To cm.AttributeMaps.Count + For i = 1 To CType(cm.AttributeMaps.Count, Short) obj.SetAttributeValue(cm.getAttributeMap(i).Name, Me.getValueByAttribute(cm.getAttributeMap(i).Name)) Next cm = cm.SuperClass @@ -555,7 +555,7 @@ Public Overrides Function ToString() As String Dim s As String - Dim i As Integer + Dim i As Short Dim indent As Integer Dim formatString As String Index: CPersistentObject.vb =================================================================== RCS file: /cvsroot/jcframework/dotnet/CPersistentObject.vb,v retrieving revision 1.46 retrieving revision 1.47 diff -u -d -r1.46 -r1.47 --- CPersistentObject.vb 21 Oct 2004 23:35:23 -0000 1.46 +++ CPersistentObject.vb 25 Oct 2004 07:12:32 -0000 1.47 @@ -871,6 +871,8 @@ Dim persistentBroker As CPersistenceBroker Dim value As IPersistableObject Dim queue As Queue + Dim savedKeys As New ArrayList + Dim ckey As CCacheKey persistentBroker = getPersistenceBrokerInstance() queue = persistentBroker.getObjectsToSave(obj, True, checkAssociationsRecursivly) @@ -881,7 +883,14 @@ Do While queue.Count > 0 value = queue.Dequeue() Try - persistentBroker.saveObject(value) + ckey = New CCacheKey(value) + If savedKeys.Contains(ckey) Then + 'object was already saved (could be new object referenced by multiple other new objects) + Debug.WriteLine("The object with key " & ckey.ToString & " was already saved once") + Else + persistentBroker.saveObject(value) + savedKeys.Add(ckey) + End If Catch ex As Exception 'After an error remove the cached object so that the next retrieve ' will refresh the cache with the item from the database |
From: Richard B. <rb...@us...> - 2004-10-22 05:33:27
|
Update of /cvsroot/jcframework/dotnet In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13090 Modified Files: CPersistenceBroker.vb Log Message: Fixed small problem in Reflect() with association names and AFAssociation attribute processing Index: CPersistenceBroker.vb =================================================================== RCS file: /cvsroot/jcframework/dotnet/CPersistenceBroker.vb,v retrieving revision 1.71 retrieving revision 1.72 diff -u -d -r1.71 -r1.72 --- CPersistenceBroker.vb 21 Oct 2004 23:35:23 -0000 1.71 +++ CPersistenceBroker.vb 22 Oct 2004 05:33:17 -0000 1.72 @@ -1694,7 +1694,7 @@ Dim propAtt, propAttributes() As Object Dim afTable As AFTableAttribute Dim afColumn As AFColumnAttribute - Dim afAssocation As AFAssociationAttribute + Dim afAssociation As AFAssociationAttribute Dim afAssocEntry As AFAssociationEntryAttribute Dim ClassMap As CClassMap Dim dbMap As CDatabaseMap @@ -1930,18 +1930,22 @@ Dim amFromAttribute As CAttributeMap Dim amToAttribute As CAttributeMap - For Each afAssocation In attributes + For Each afAssociation In attributes fromClassMap = m_classMaps.Item(types(i).Name) - toClassMap = m_classMaps.Item(afAssocation.TargetClass.Name) + toClassMap = m_classMaps.Item(afAssociation.TargetClass.Name) udaAm = New CUDAMap udaAm.ForClass = toClassMap - udaAm.Target = afAssocation.TargetProperty - udaAm.DeleteAutomatic = afAssocation.Delete - udaAm.SaveAutomatic = afAssocation.Save - udaAm.RetrieveAutomatic = afAssocation.Retrieve - udaAm.Name = afAssocation.Name + udaAm.Target = afAssociation.TargetProperty + udaAm.DeleteAutomatic = afAssociation.Delete + udaAm.SaveAutomatic = afAssociation.Save + udaAm.RetrieveAutomatic = afAssociation.Retrieve + If afAssociation.Name Is Nothing OrElse afAssociation.Name = [String].Empty Then + udaAm.Name = udaAm.Target + Else + udaAm.Name = afAssociation.Name + End If udaAm.Inverse = False - udaAm.Cardinality = afAssocation.Cardinality + udaAm.Cardinality = afAssociation.Cardinality att = types(i).GetCustomAttributes(GetType(AFAssociationEntryAttribute), False) If att.Length > 0 Then For Each afAssocEntry In att |
From: Richard B. <rb...@us...> - 2004-10-21 23:36:57
|
Update of /cvsroot/jcframework/Nunit In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5970 Modified Files: AtomsFramework.xml original db1.mdb Log Message: Extra tests for duplicates in collections, and deleting non-inherited objects Index: original db1.mdb =================================================================== RCS file: /cvsroot/jcframework/Nunit/original db1.mdb,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 Binary files /tmp/cvsEoJIyf and /tmp/cvsxkTHzM differ Index: AtomsFramework.xml =================================================================== RCS file: /cvsroot/jcframework/Nunit/AtomsFramework.xml,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- AtomsFramework.xml 20 Oct 2004 06:43:40 -0000 1.8 +++ AtomsFramework.xml 21 Oct 2004 23:36:45 -0000 1.9 @@ -114,6 +114,7 @@ <attribute name="Id" column="id" key="primary"/> <attribute name="field1" column="field1" /> <attribute name="TableBCollection" /> + <attribute name="TableCCollection" /> </class> <class name="TableB" table="TableB" database="MSA" namespace="NunitTests.InheritedClasses"> <attribute name="Id" column="id" key="primary"/> @@ -121,10 +122,20 @@ <attribute name="AId" column="a_id" /> <attrbute name="TableA" /> </class> +<class name="TableC" table="TableC" database="MSA" namespace="NunitTests.InheritedClasses"> + <attribute name="Id" column="id" key="primary"/> + <attribute name="field1" column="field1" /> + <attribute name="AId" column="a_id" /> + <attrbute name="TableA" /> +</class> <association fromClass="NunitTests.InheritedClasses.TableA" toClass="NunitTests.InheritedClasses.TableB" target="TableBCollection" cardinality="OneToMany" retrieveAutomatic="true" saveAutomatic="true" deleteAutomatic="true" inverse="false" name="AtoB"> <entry fromAttribute="Id" toAttribute="AId"/> </association> +<association fromClass="NunitTests.InheritedClasses.TableA" toClass="NunitTests.InheritedClasses.TableC" target="TableCCollection" cardinality="OneToMany" + retrieveAutomatic="true" saveAutomatic="true" deleteAutomatic="true" inverse="false" name="AtoC"> + <entry fromAttribute="Id" toAttribute="AId"/> +</association> <class name="A" table="tblA" database="MSA" namespace="NunitTests.InheritedClasses"> <attribute name="OIDValue" column="oid" key="primary"/> |
From: Richard B. <rb...@us...> - 2004-10-21 23:36:57
|
Update of /cvsroot/jcframework/Nunit/StandardClasses In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5970/StandardClasses Modified Files: NonInheritedTests.vb Log Message: Extra tests for duplicates in collections, and deleting non-inherited objects Index: NonInheritedTests.vb =================================================================== RCS file: /cvsroot/jcframework/Nunit/StandardClasses/NonInheritedTests.vb,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- NonInheritedTests.vb 19 Oct 2004 00:13:38 -0000 1.1 +++ NonInheritedTests.vb 21 Oct 2004 23:36:46 -0000 1.2 @@ -69,8 +69,8 @@ pbroker.PersistChanges(job) pbroker.MarkForDeletion(job) pbroker.PersistChanges(job) - Assert.IsTrue(pbroker.ObjectIsTracked(job)) - Assert.IsFalse(pbroker.getInjectedObject(job).Persistent) + Assert.IsFalse(pbroker.ObjectIsTracked(job)) + Assert.IsNull(pbroker.getInjectedObject(job)) End Sub <Test()> Public Sub CheckInjectionCache() @@ -160,7 +160,7 @@ Assert.AreEqual(emp.Name, "new") pbroker.MarkForDeletion(emp) pbroker.PersistChanges(emp) - Assert.IsFalse(pbroker.getInjectedObject(emp).Persistent) + Assert.IsNull(pbroker.getInjectedObject(emp)) emp = New NPEmployee emp.Name = "new" pbroker.FindObject(emp) @@ -188,7 +188,7 @@ Assert.IsTrue(pbroker.getInjectedObject(emp).Persistent) pbroker.MarkForDeletion(emp) pbroker.PersistChanges(emp) - Assert.IsFalse(pbroker.getInjectedObject(emp).Persistent) + Assert.IsNull(pbroker.getInjectedObject(emp)) emp = New NPEmployee emp.Name = "Changed" pbroker.FindObject(emp) |
From: Richard B. <rb...@us...> - 2004-10-21 23:36:57
|
Update of /cvsroot/jcframework/Nunit/InheritedClasses In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5970/InheritedClasses Modified Files: AtomsFrameworkTests.vb TableA_B.vb Log Message: Extra tests for duplicates in collections, and deleting non-inherited objects Index: TableA_B.vb =================================================================== RCS file: /cvsroot/jcframework/Nunit/InheritedClasses/TableA_B.vb,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- TableA_B.vb 19 Oct 2004 03:30:42 -0000 1.1 +++ TableA_B.vb 21 Oct 2004 23:36:46 -0000 1.2 @@ -36,6 +36,16 @@ End Set End Property + Private _tableCCol As New CPersistentCollection + Public Property TableCCollection() As CPersistentCollection + Get + Return _tableCCol + End Get + Set(ByVal Value As CPersistentCollection) + _tableCCol = Value + End Set + End Property + Public Overrides Function getNewObject() As AToMSFramework.CPersistentObject Return New TableA End Function @@ -95,7 +105,65 @@ End Property Public Overrides Function getNewObject() As AToMSFramework.CPersistentObject - Return New TableA + Return New TableB + End Function + + Public Overrides Function IsValid() As Boolean + Return True + End Function + End Class + + Public Class TableC + Inherits CPersistentObject + + Private _id As String + Public Property Id() As String + Get + Return _id + End Get + Set(ByVal Value As String) + _id = Value + SetDirtyFlag() + End Set + End Property + + Private _field1 As String + Public Property field1() As String + Get + Return _field1 + End Get + Set(ByVal Value As String) + _field1 = Value + SetDirtyFlag() + End Set + End Property + + Private _a As TableA + Private _a_id As String + Public Property TableA() As TableA + Get + Return _a + End Get + Set(ByVal Value As TableA) + _a = Value + SetDirtyFlag() + End Set + End Property + + Public Property AId() As String + Get + If _a Is Nothing Then + Return _a_id + End If + Return _a.Id + End Get + Set(ByVal Value As String) + _a_id = Value + End Set + End Property + + Public Overrides Function getNewObject() As AToMSFramework.CPersistentObject + Return New TableC End Function Public Overrides Function IsValid() As Boolean Index: AtomsFrameworkTests.vb =================================================================== RCS file: /cvsroot/jcframework/Nunit/InheritedClasses/AtomsFrameworkTests.vb,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- AtomsFrameworkTests.vb 19 Oct 2004 03:30:42 -0000 1.2 +++ AtomsFrameworkTests.vb 21 Oct 2004 23:36:46 -0000 1.3 @@ -115,6 +115,14 @@ emp.Name = "DeleteMe1" emp.Find() Assert.IsFalse(emp.Persistent) + emp = New CEmployee + emp.Name = "DeleteMe2" + emp.Find() + Assert.IsFalse(emp.Persistent) + emp = New CEmployee + emp.Name = "DeleteMe3" + emp.Find() + Assert.IsFalse(emp.Persistent) End Sub <Test()> Public Sub LoadEmployee_ac() @@ -218,5 +226,45 @@ Assert.AreEqual(1, cc.TotalRows) Assert.IsTrue(cc.hasElements) End Sub + + <Test()> Public Sub CheckForDuplicates() + 'Tests is multiple one-to-many associations in an object causes + 'duplicates in a collection. + Dim a As New TableA + Dim b As New TableB + Dim c As New TableC + a.Id = "aa" + b.Id = "bb1" + b.TableA = a + a.TableBCollection.Add(b) + b = New TableB + b.Id = "bb2" + b.TableA = a + a.TableBCollection.Add(b) + c = New TableC + c.Id = "cc1" + c.TableA = a + a.TableCCollection.Add(c) + c = New TableC + c.Id = "cc2" + c.TableA = a + a.TableCCollection.Add(c) + c = New TableC + c.Id = "cc3" + c.TableA = a + a.TableCCollection.Add(c) + c = New TableC + c.Id = "cc4" + c.TableA = a + a.TableCCollection.Add(c) + a.Save() + pbroker.ClearCache() + a = New TableA + a.Id = "aa" + a.Retrieve() + Assert.AreEqual(2, a.TableBCollection.Count) + Assert.AreEqual(4, a.TableCCollection.Count) + End Sub + End Class End Namespace \ No newline at end of file |
From: Richard B. <rb...@us...> - 2004-10-21 23:35:34
|
Update of /cvsroot/jcframework/dotnet In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5715 Modified Files: CPersistenceBroker.vb CPersistentObject.vb Log Message: Fixed bug in deleting non-inherited objects. Fixed problem with duplicates in multiple collections. Made some attributes of CPersistentObject advanced using EditorBrowsable attribute (for IDE) Index: CPersistenceBroker.vb =================================================================== RCS file: /cvsroot/jcframework/dotnet/CPersistenceBroker.vb,v retrieving revision 1.70 retrieving revision 1.71 diff -u -d -r1.70 -r1.71 --- CPersistenceBroker.vb 20 Oct 2004 06:44:23 -0000 1.70 +++ CPersistenceBroker.vb 21 Oct 2004 23:35:23 -0000 1.71 @@ -40,6 +40,7 @@ Public Event LoginDetailsNeeded(ByVal sender As Object, ByRef User As String, ByRef Password As String) Private m_disposed As Boolean + Private m_inPersistChangesLoop As Boolean '''----------------------------------------------------------------------------- ''' <summary> @@ -476,10 +477,10 @@ '(prevents duplicates when multiple one-to-many associations exist) gotValue = False For Each tmpColObj As Object In col - If Not tmpColObj.GetType.IsSubclassOf(GetType(IPersistableObject)) Then - tmpObj = LocateOrCreateInjObject(tmpColObj) - Else + If tmpColObj.GetType.IsSubclassOf(GetType(CPersistentObject)) Then tmpObj = tmpColObj + Else + tmpObj = LocateOrCreateInjObject(tmpColObj) End If If tmpObj.Equals(targetobj) Then gotValue = True @@ -495,8 +496,6 @@ End If If targetobj.AssociationsLoaded Then col.Add(targetobj.GetSourceObject) - 'the object is found and added to the collection - ' Exit For End If End If End If @@ -517,10 +516,10 @@ '(prevents duplicates when multiple one-to-many associations exist) gotValue = False For Each tmpColObj As Object In col - If Not tmpColObj.GetType.IsSubclassOf(GetType(IPersistableObject)) Then - tmpObj = LocateOrCreateInjObject(tmpColObj) - Else + If tmpColObj.GetType.IsSubclassOf(GetType(CPersistentObject)) Then tmpObj = tmpColObj + Else + tmpObj = LocateOrCreateInjObject(tmpColObj) End If If tmpObj.Equals(targetobj) Then gotValue = True @@ -773,6 +772,7 @@ obj.ResetOriginalDates() obj.Persistent = True obj.IsDirty = False + obj.IsQueued = False 'Update cache key in-case primary key fields have changed value obj.OriginalCacheKey = New CCacheKey(obj) If m_useCache Then @@ -2451,12 +2451,15 @@ Me.startTransaction() Try Dim injObj As CInjectedObject + m_inPersistChangesLoop = True For Each de As DictionaryEntry In m_injectedObjects injObj = de.Value PersistChanges(injObj.ReferencedObject) Next + m_inPersistChangesLoop = False Me.commit() Catch ex As Exception + m_inPersistChangesLoop = False Me.rollback() Throw ex End Try @@ -2478,6 +2481,9 @@ If injObj.MarkedForDeletion Then deleteObject(injObj, injObj.WillDeleteParents) + If Not m_inPersistChangesLoop Then + m_injectedObjects.Remove(obj) + End If Else queue = getObjectsToSave(injObj, True, checkAssociationsRecursively) 'All objects to be saved must be saved in a single transaction. Index: CPersistentObject.vb =================================================================== RCS file: /cvsroot/jcframework/dotnet/CPersistentObject.vb,v retrieving revision 1.45 retrieving revision 1.46 diff -u -d -r1.45 -r1.46 --- CPersistentObject.vb 20 Oct 2004 06:44:23 -0000 1.45 +++ CPersistentObject.vb 21 Oct 2004 23:35:23 -0000 1.46 @@ -487,6 +487,7 @@ ''' [rbanks] 25/11/2003 Created ''' </history> '''----------------------------------------------------------------------------- + <EditorBrowsable(EditorBrowsableState.Advanced)> _ Public Sub setAttributeValue(ByVal pName As String, ByRef Value As Object) Implements IPersistentObject.setAttributeValue If TypeOf (Value) Is System.DBNull Then @@ -536,6 +537,7 @@ ''' [rbanks] 25/11/2003 Created ''' </history> '''----------------------------------------------------------------------------- + <EditorBrowsable(EditorBrowsableState.Advanced)> _ Public Function getValueByAttribute(ByVal pName As String) As Object Implements IPersistentObject.getValueByAttribute Dim dotPos As Integer dotPos = pName.IndexOf(".") @@ -565,6 +567,7 @@ ''' [rbanks] 25/11/2003 Created ''' </history> '''----------------------------------------------------------------------------- + <EditorBrowsable(EditorBrowsableState.Advanced)> _ Public Function getObjectByAttribute(ByVal pName As String) As IPersistableObject Implements IPersistableObject.getObjectByAttribute Dim dotPos As Integer dotPos = pName.IndexOf(".") @@ -596,6 +599,7 @@ ''' [rbanks] 26/11/2003 Created ''' </history> '''----------------------------------------------------------------------------- + <EditorBrowsable(EditorBrowsableState.Advanced)> _ Public MustOverride Function getNewObject() As CPersistentObject Implements IPersistentObject.getNewObject '''----------------------------------------------------------------------------- @@ -616,6 +620,7 @@ ''' [rbanks] 26/11/2003 Created ''' </history> '''----------------------------------------------------------------------------- + <EditorBrowsable(EditorBrowsableState.Advanced)> _ Public Overridable Function hasValidKey() As Boolean If m_oid Is Nothing Then Return False @@ -635,6 +640,7 @@ ''' [rbanks] 26/11/2003 Created ''' </history> '''----------------------------------------------------------------------------- + <EditorBrowsable(EditorBrowsableState.Advanced)> _ Public Overloads Function getCollectionByAttribute(ByVal pName As String) As IList Implements IPersistentObject.getCollectionByAttribute Dim dotPos As Integer dotPos = pName.IndexOf(".") @@ -668,6 +674,7 @@ ''' [rbanks] 26/11/2003 Created ''' </history> '''----------------------------------------------------------------------------- + <EditorBrowsable(EditorBrowsableState.Advanced)> _ Private Function getObjectFromCollectionByAttribute(ByVal pName As String) As CPersistentObject Dim colAux As Collection Dim dotPos As Integer @@ -1558,6 +1565,7 @@ ''' [danymayer] 19/07/2004 Created ''' </history> '''----------------------------------------------------------------------------- + <EditorBrowsable(EditorBrowsableState.Advanced)> _ Function getObjectByClassMap(ByVal classMap As CClassMap) As IPersistableObject Implements IPersistentObject.getObjectByClassMap Dim obj, Value As CPersistentObject Dim col As CPersistentCollection @@ -1621,6 +1629,7 @@ Return obj End Function + <EditorBrowsable(EditorBrowsableState.Advanced)> _ Public Overridable Function GetBaseCopy() As CPersistentObject 'Use reflection to copy all of the fields from Obj to me (by value) If Me.getClassMap.SuperClass Is Nothing Then @@ -1668,6 +1677,7 @@ ''' [rbanks] 16/08/2004 Created ''' </history> ''' ----------------------------------------------------------------------------- + <EditorBrowsable(EditorBrowsableState.Advanced)> _ Public Overridable Sub BeginEdit() Implements System.ComponentModel.IEditableObject.BeginEdit If Not m_editing Then m_preEditCopy = Me.getNewObject @@ -1688,6 +1698,7 @@ ''' [rbanks] 16/08/2004 Created ''' </history> ''' ----------------------------------------------------------------------------- + <EditorBrowsable(EditorBrowsableState.Advanced)> _ Public Overridable Sub CancelEdit() Implements System.ComponentModel.IEditableObject.CancelEdit m_editing = False Me.ReplaceWith(m_preEditCopy) @@ -1708,6 +1719,7 @@ ''' [rbanks] 16/08/2004 Created ''' </history> ''' ----------------------------------------------------------------------------- + <EditorBrowsable(EditorBrowsableState.Advanced)> _ Public Overridable Sub EndEdit() Implements System.ComponentModel.IEditableObject.EndEdit m_editing = False m_isNew = False @@ -1728,7 +1740,8 @@ ''' [rbanks] 16/08/2004 Created ''' </history> ''' ----------------------------------------------------------------------------- - <Browsable(False)> Public Overridable ReadOnly Property [Error]() As String Implements System.ComponentModel.IDataErrorInfo.Error + <Browsable(False), EditorBrowsable(EditorBrowsableState.Advanced)> _ + Public Overridable ReadOnly Property [Error]() As String Implements System.ComponentModel.IDataErrorInfo.Error Get If Me.IsValid Then Return "" @@ -1750,7 +1763,8 @@ ''' [rbanks] 16/08/2004 Created ''' </history> ''' ----------------------------------------------------------------------------- - <Browsable(False)> Default Public Overridable ReadOnly Property Item(ByVal columnName As String) As String Implements System.ComponentModel.IDataErrorInfo.Item + <Browsable(False), EditorBrowsable(EditorBrowsableState.Advanced)> _ + Default Public Overridable ReadOnly Property Item(ByVal columnName As String) As String Implements System.ComponentModel.IDataErrorInfo.Item Get Return "" End Get @@ -1761,7 +1775,8 @@ Public Event Disposed(ByVal sender As Object, ByVal e As System.EventArgs) Implements System.ComponentModel.IComponent.Disposed Private m_curCPSite As ISite - <Browsable(False)> Public Property Site() As System.ComponentModel.ISite Implements System.ComponentModel.IComponent.Site + <Browsable(False), EditorBrowsable(EditorBrowsableState.Advanced)> _ + Public Property Site() As System.ComponentModel.ISite Implements System.ComponentModel.IComponent.Site Get Return m_curCPSite End Get @@ -1775,10 +1790,12 @@ End Sub #End Region + <EditorBrowsable(EditorBrowsableState.Advanced)> _ Public Function GetObjectType() As System.Type Implements IPersistableObject.GetObjectType Return Me.GetType End Function + <EditorBrowsable(EditorBrowsableState.Advanced)> _ Public Function GetSourceObject() As Object Implements IPersistableObject.GetSourceObject Return Me End Function |
From: Richard B. <rb...@us...> - 2004-10-20 22:29:09
|
Update of /cvsroot/jcframework/dotnet In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28527 Modified Files: AFCustomAttributes.vb Log Message: Fixed default for proxy flag in AFColumnAttribute Index: AFCustomAttributes.vb =================================================================== RCS file: /cvsroot/jcframework/dotnet/AFCustomAttributes.vb,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- AFCustomAttributes.vb 16 Aug 2004 04:16:54 -0000 1.6 +++ AFCustomAttributes.vb 20 Oct 2004 22:29:00 -0000 1.7 @@ -413,6 +413,7 @@ ''' ----------------------------------------------------------------------------- Public Sub New(ByVal Column As String) attrColumn = Column + attrProxy = True End Sub ''' ----------------------------------------------------------------------------- |