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...> - 2005-02-02 05:08:49
|
Update of /cvsroot/jcframework/dotnet In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22365 Modified Files: CCacheEntry.vb CConnection.vb CPersistenceBroker.vb readme.html Log Message: Fixes to restore state of cached objects and collections after transaction rollback Index: readme.html =================================================================== RCS file: /cvsroot/jcframework/dotnet/readme.html,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- readme.html 31 Jan 2005 06:17:39 -0000 1.6 +++ readme.html 2 Feb 2005 05:08:38 -0000 1.7 @@ -179,6 +179,11 @@ <td class="col1">Problem saving with 3 or more levels of interface inheritance</td> <td>Only the lowest and highest mapped interfaces were being saved when an object with 3+ levels of interface inheritances was persisted.<td> </tr> + <tr valign="top"> + <td>1113504</td> + <td class="col1">Collections not restored after transaction rollback</td> + <td>Collections are now cloned or copied at the start of a transaction. If the transaction aborts the copied collections are restored to the object.<td> + </tr> <tr class="tableCaption" valign="bottom"> <td colspan=3><br/>Modifications</td> </tr> Index: CConnection.vb =================================================================== RCS file: /cvsroot/jcframework/dotnet/CConnection.vb,v retrieving revision 1.31 retrieving revision 1.32 diff -u -d -r1.31 -r1.32 --- CConnection.vb 31 Jan 2005 06:17:39 -0000 1.31 +++ CConnection.vb 2 Feb 2005 05:08:37 -0000 1.32 @@ -386,6 +386,7 @@ If Me.ManageTransactions Then If Not Me.Started Then m_transaction = m_connection.BeginTransaction + getPersistenceBrokerInstance().startCacheTransaction(Me.Database) End If m_transactioncalls += 1 Me.Started = True @@ -616,6 +617,7 @@ If Me.ManageTransactions Then If Not Me.Started Then m_transaction = m_connection.BeginTransaction(isolationLevel) + getPersistenceBrokerInstance().startCacheTransaction(Me.Database) End If m_transactioncalls += 1 Me.Started = True @@ -845,6 +847,7 @@ If Me.ManageTransactions Then If Not Me.Started Then m_transaction = m_connection.BeginTransaction + getPersistenceBrokerInstance().startCacheTransaction(Me.Database) End If m_transactioncalls += 1 Me.Started = True @@ -1096,6 +1099,7 @@ If Me.ManageTransactions Then If Not Me.Started Then m_transaction = m_connection.BeginTransaction(isolationLevel) + getPersistenceBrokerInstance().startCacheTransaction(Me.Database) End If m_transactioncalls += 1 Me.Started = True @@ -1325,6 +1329,7 @@ If Me.ManageTransactions Then If Not Me.Started Then m_transaction = m_connection.BeginTransaction + getPersistenceBrokerInstance().startCacheTransaction(Me.Database) End If m_transactioncalls += 1 Me.Started = True @@ -1352,6 +1357,7 @@ If Me.ManageTransactions Then If Not Me.Started Then m_transaction = m_connection.BeginTransaction(isolationLevel) + getPersistenceBrokerInstance().startCacheTransaction(Me.Database) End If m_transactioncalls += 1 Me.Started = True @@ -1782,6 +1788,7 @@ If Me.ManageTransactions Then If Not Me.Started Then m_transaction = m_connection.BeginTransaction + getPersistenceBrokerInstance().startCacheTransaction(Me.Database) End If m_transactioncalls += 1 Me.Started = True @@ -2010,6 +2017,7 @@ If Me.ManageTransactions Then If Not Me.Started Then m_transaction = m_connection.BeginTransaction(isolationLevel) + getPersistenceBrokerInstance().startCacheTransaction(Me.Database) End If m_transactioncalls += 1 Me.Started = True @@ -2229,6 +2237,7 @@ If Me.ManageTransactions Then If Not Me.Started Then m_transaction = m_connection.BeginTransaction + getPersistenceBrokerInstance().startCacheTransaction(Me.Database) End If m_transactioncalls += 1 Me.Started = True @@ -2461,6 +2470,7 @@ If Me.ManageTransactions Then If Not Me.Started Then m_transaction = m_connection.BeginTransaction(isolationLevel) + getPersistenceBrokerInstance().startCacheTransaction(Me.Database) End If m_transactioncalls += 1 Me.Started = True Index: CPersistenceBroker.vb =================================================================== RCS file: /cvsroot/jcframework/dotnet/CPersistenceBroker.vb,v retrieving revision 1.88 retrieving revision 1.89 diff -u -d -r1.88 -r1.89 --- CPersistenceBroker.vb 2 Jan 2005 09:41:10 -0000 1.88 +++ CPersistenceBroker.vb 2 Feb 2005 05:08:37 -0000 1.89 @@ -201,7 +201,7 @@ If Not x Is Nothing Then Throw x End If - End Try + End Try End SyncLock End Function @@ -701,8 +701,6 @@ Dim found As Boolean Dim col As IList Dim myKeys(cm.AssociationMaps.Count) As String - Dim tmpObj As IPersistableObject - cm.AssociationMaps.Keys.CopyTo(myKeys, 0) Dim anObjPers As IPersistableObject For i = 0 To cm.AssociationMaps.Count - 1 @@ -753,12 +751,12 @@ End Try End If If found Then - Value.IsDirty = False 'After populating a new object - Value.OriginalCacheKey = New CCacheKey(Value) - obj.SetAttributeValue(udaMap.Target, Value.GetSourceObject) - End If + Value.IsDirty = False 'After populating a new object + Value.OriginalCacheKey = New CCacheKey(Value) + obj.SetAttributeValue(udaMap.Target, Value.GetSourceObject) End If 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)) @@ -781,26 +779,14 @@ cursor.loadObject(anObjPers.GetSourceObject) retrieveAssociations(anObjPers, conn, anObjPers.GetClassMap, useCache) End If - 'Need to determine if new object is already in the collection - '(prevents duplicates when multiple one-to-many associations exist) - gotValue = False - For Each tmpColObj As Object In col - If tmpColObj.GetType.IsSubclassOf(GetType(CPersistentObject)) Then - tmpObj = tmpColObj - Else - tmpObj = LocateOrCreateInjObject(tmpColObj) - End If - If tmpObj.Equals(anObjPers) Then - gotValue = True - End If - Next - - If Not gotValue Then - anObjPers.IsDirty = False 'After populating a new object - anObjPers.OriginalCacheKey = New CCacheKey(anObjPers) - col.Add(anObjPers.GetSourceObject) - m_cache.Add(anObjPers) 'Add retrieved objects to the cache - End If + anObjPers.IsDirty = False 'After populating a new object + anObjPers.OriginalCacheKey = New CCacheKey(anObjPers) + col.Add(anObjPers.GetSourceObject) + m_cache.Add(anObjPers) 'Add retrieved objects to the cache + Try + PCCacheSize.RawValue = m_cache.Count + Catch + End Try cursor.nextCursor() End While End If @@ -990,7 +976,7 @@ Try deletePrivateObject(obj, conn, deleteSuperClass) conn.commit() - Catch ex As Exception + Catch ex As Exception x = New DeleteException(ex.Message, ex) conn.rollback() Finally @@ -1005,7 +991,7 @@ If Not x Is Nothing Then Throw x End If - End Try + End Try End SyncLock End Sub @@ -1836,9 +1822,9 @@ Return cursor Catch - firstClassMap.RelationalDatabase.freeConnection(conn) - Return Nothing - End Try + firstClassMap.RelationalDatabase.freeConnection(conn) + Return Nothing + End Try End Function @@ -2605,6 +2591,10 @@ RaiseEvent LoginDetailsNeeded(sender, User, Password) End Sub + Friend Sub startCacheTransaction(ByVal reldb As _CRelationalDatabase) + m_cache.StartTransaction(reldb) + End Sub + Friend Sub commitCache(ByVal reldb As _CRelationalDatabase) m_cache.CommitChanges(reldb) End Sub Index: CCacheEntry.vb =================================================================== RCS file: /cvsroot/jcframework/dotnet/CCacheEntry.vb,v retrieving revision 1.24 retrieving revision 1.25 diff -u -d -r1.24 -r1.25 --- CCacheEntry.vb 31 Jan 2005 22:29:06 -0000 1.24 +++ CCacheEntry.vb 2 Feb 2005 05:08:37 -0000 1.25 @@ -33,7 +33,7 @@ Private m_transactionType As CCacheEntry.CacheTransaction Private m_expiryTime As Date Private m_originalObject As IPersistableObject - Private m_collectionCollection As System.Collections.Specialized.StringDictionary + Private m_collectionCollection As Specialized.HybridDictionary '''----------------------------------------------------------------------------- ''' <summary> @@ -123,119 +123,139 @@ End Sub Public Sub CopyCollections() - Dim t, t_coll As Type - Dim prop, props() As PropertyInfo - - m_collectionCollection = New Specialized.StringDictionary - t_coll = GetType(CollectionBase) - t = m_object.GetObjectType - props = t.GetProperties - For Each prop In props - If prop.PropertyType Is t_coll OrElse prop.PropertyType.IsSubclassOf(t_coll) Then - 'We must precopy this collection into the collection copy - m_collectionCollection.Add(prop.Name, m_object.GetValueByAttribute(prop.Name)) - End If - Next - End Sub + Dim t, iEnumerableType, iListType, iDicType As Type Dim coll, obj As Object + Dim il As IList + Dim id As IDictionary + Dim f, fields() As FieldInfo + Dim value As Object - Public Sub RestoreCollections() - Dim t, t_coll As Type - Dim prop, props() As PropertyInfo - - t_coll = GetType(CollectionBase) - t = m_object.GetObjectType - props = t.GetProperties - For Each prop In props - If prop.PropertyType Is t_coll OrElse prop.PropertyType.IsSubclassOf(t_coll) Then - 'We must restore this collection from the collection copy - m_object.SetAttributeValue(prop.Name, m_collectionCollection.Item(prop.Name)) - End If - Next - End Sub + 'We must precopy this collection into the collection copy 'A simple assignment would just copy a reference to the colletion, while 'we need to copy the collection itself, so that adding/removing elements 'of the original won't effect the copy + m_collectionCollection = New Specialized.HybridDictionary t = m_object.GetObjectType + fields = t.GetFields(BindingFlags.Instance Or BindingFlags.NonPublic Or BindingFlags.Public) + For Each f In fields + iListType = f.FieldType.GetInterface("IList", True) + iDicType = f.FieldType.GetInterface("IDictionary", True) + 'iEnumerableType = f.FieldType.GetInterface("IEnumerable", True) + If Not iListType Is Nothing OrElse Not iDicType Is Nothing Then + Dim ICloneType As Type = f.FieldType.GetInterface("ICloneable", True) + If Not ICloneType Is Nothing Then + 'Getting the ICloneable interface from the object. + Dim IClone As ICloneable = CType(f.GetValue(m_object), ICloneable) + 'We use the clone method to set the new value to the field. + coll = IClone.Clone() + Else + 'If the field doesn't support the ICloneable interface then just set it. + coll = Activator.CreateInstance(f.FieldType) 'need to copy references one-by-one + If Not iListType Is Nothing Then + il = CType(coll, IList) + For Each obj In f.GetValue(m_object) + il.Add(obj) + Next + Else + id = CType(coll, IDictionary) + For Each de As DictionaryEntry In f.GetValue(m_object) + id.Add(de.Key, de.Value) + Next + End If + End If + m_collectionCollection.Add(f.Name, coll) End If Next + End Sub - Public Sub New(ByVal lifetime As Double) - m_expiryTime = DateAdd(DateInterval.Minute, lifetime, Now) - End Sub + Public Sub RestoreCollections() + Dim t, iEnumerableType, iListType, iDicType As Type Dim f, fields() As FieldInfo + t = m_object.GetObjectType + fields = t.GetFields(BindingFlags.Instance Or BindingFlags.NonPublic Or BindingFlags.Public) + For Each f In fields + iListType = f.FieldType.GetInterface("IList", True) + iDicType = f.FieldType.GetInterface("IDictionary", True) + 'iEnumerableType = f.FieldType.GetInterface("IEnumerable", True) + If Not iListType Is Nothing OrElse Not iDicType Is Nothing Then + 'We must restore this collection from the collection copy 'Just use a straight value assignment - no need to worry about cloning f.SetValue(m_object, m_collectionCollection.Item(f.Name)) End If Next + End Sub - Friend Sub resetExpiry(ByVal lifetime As Double) - m_expiryTime = DateAdd(DateInterval.Minute, lifetime, Now) - End Sub + Public Sub New(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 + Friend Sub resetExpiry(ByVal lifetime As Double) + m_expiryTime = DateAdd(DateInterval.Minute, lifetime, Now) + End Sub - Dim cm As CClassMap - Dim am As CAttributeMap - Dim x As Object - Dim y As Object - Dim xstring As String - Dim ystring As String + Public Overrides Function ToString() As String + Dim s As String + Dim i As Short + Dim indent As Integer + Dim formatString As String - If m_object Is Nothing Then - Return "No persistent object" - End If + Dim cm As CClassMap + Dim am As CAttributeMap + Dim x As Object + Dim y As Object + Dim xstring As String + Dim ystring As String - 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 + 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 '''----------------------------------------------------------------------------- @@ -862,10 +882,12 @@ 'Lets cancel deletes first - just means resetting transaction to None If ce.TransactionType = CCacheEntry.CacheTransaction.Deleted AndAlso ce.PersistentObject.GetClassMap.RelationalDatabase Is reldb Then ce.TransactionType = CCacheEntry.CacheTransaction.None + ce.RestoreCollections() 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 ce.RestoreObject() + ce.RestoreCollections() ce.TransactionType = CCacheEntry.CacheTransaction.None End If Next @@ -882,6 +904,19 @@ Next End Sub + Friend Sub StartTransaction(ByVal reldb As _CRelationalDatabase) + Dim x As DictionaryEntry + Dim ce As CCacheEntry + + 'precopy collection objects + For Each x In Me + ce = x.Value + If ce.PersistentObject.GetClassMap.RelationalDatabase Is reldb Then + ce.CopyCollections() + End If + Next + End Sub + Public Property ObjectsAreLoading() As Boolean Get Return m_objectsLoading @@ -941,7 +976,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...> - 2005-01-31 22:29:17
|
Update of /cvsroot/jcframework/dotnet In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15167 Modified Files: CCacheEntry.vb Log Message: -- incomplete -- Code for precopying collections referenced by cached objects, and for restoring those collections. The precopy/restore code will be called on transaction start/rollback. Index: CCacheEntry.vb =================================================================== RCS file: /cvsroot/jcframework/dotnet/CCacheEntry.vb,v retrieving revision 1.23 retrieving revision 1.24 diff -u -d -r1.23 -r1.24 --- CCacheEntry.vb 16 Nov 2004 21:39:34 -0000 1.23 +++ CCacheEntry.vb 31 Jan 2005 22:29:06 -0000 1.24 @@ -1,6 +1,8 @@ Option Strict Off Option Explicit On +Imports System.Reflection + '''----------------------------------------------------------------------------- ''' Project : AToMSFramework ''' Class : CCacheEntry @@ -30,7 +32,8 @@ Private m_objectCopy As IPersistableObject Private m_transactionType As CCacheEntry.CacheTransaction Private m_expiryTime As Date - Private m_originalObject As IPersistableObject + Private m_originalObject As IPersistableObject + Private m_collectionCollection As System.Collections.Specialized.StringDictionary '''----------------------------------------------------------------------------- ''' <summary> @@ -117,91 +120,122 @@ Public Sub RestoreObject() m_object = m_objectCopy - End Sub + End Sub - Public Sub New(ByVal lifetime As Double) - m_expiryTime = DateAdd(DateInterval.Minute, lifetime, Now) - End Sub + Public Sub CopyCollections() + Dim t, t_coll As Type + Dim prop, props() As PropertyInfo + + m_collectionCollection = New Specialized.StringDictionary + t_coll = GetType(CollectionBase) + t = m_object.GetObjectType + props = t.GetProperties + For Each prop In props + If prop.PropertyType Is t_coll OrElse prop.PropertyType.IsSubclassOf(t_coll) Then + 'We must precopy this collection into the collection copy + m_collectionCollection.Add(prop.Name, m_object.GetValueByAttribute(prop.Name)) + End If + Next + End Sub - Friend Sub resetExpiry(ByVal lifetime As Double) - m_expiryTime = DateAdd(DateInterval.Minute, lifetime, Now) - End Sub + Public Sub RestoreCollections() + Dim t, t_coll As Type + Dim prop, props() As PropertyInfo + + t_coll = GetType(CollectionBase) + t = m_object.GetObjectType + props = t.GetProperties + For Each prop In props + If prop.PropertyType Is t_coll OrElse prop.PropertyType.IsSubclassOf(t_coll) Then + 'We must restore this collection from the collection copy + m_object.SetAttributeValue(prop.Name, m_collectionCollection.Item(prop.Name)) + End If + Next + End Sub - Public Overrides Function ToString() As String - Dim s As String - Dim i As Short - Dim indent As Integer - Dim formatString As String + Public Sub New(ByVal lifetime As Double) + m_expiryTime = DateAdd(DateInterval.Minute, lifetime, Now) + End Sub - Dim cm As CClassMap - Dim am As CAttributeMap - Dim x As Object - Dim y As Object - Dim xstring As String - Dim ystring As String + Friend Sub resetExpiry(ByVal lifetime As Double) + m_expiryTime = DateAdd(DateInterval.Minute, lifetime, Now) + End Sub - If m_object Is Nothing Then - Return "No persistent object" - End If + Public Overrides Function ToString() As String + Dim s As String + Dim i As Short + Dim indent As Integer + Dim formatString As String - 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 + 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 '''----------------------------------------------------------------------------- |
From: Richard B. <rb...@us...> - 2005-01-31 22:27:31
|
Update of /cvsroot/jcframework/Nunit/InheritedClasses In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14782/InheritedClasses Modified Files: AtomsFrameworkTests.vb TableA_B.vb Log Message: Unit test for restoring collections after transaction rollback Index: TableA_B.vb =================================================================== RCS file: /cvsroot/jcframework/Nunit/InheritedClasses/TableA_B.vb,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- TableA_B.vb 1 Nov 2004 21:27:10 -0000 1.3 +++ TableA_B.vb 31 Jan 2005 22:27:19 -0000 1.4 @@ -57,121 +57,126 @@ 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 - Inherits CPersistentObject + Public Sub New() + _tableBCol.ContainerObject = Me + _tableCCol.ContainerObject = Me + End Sub + End Class - 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 + Public Class TableB + Inherits CPersistentObject - 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 _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 _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 + 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 - 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 + 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 Overrides Function getNewObject() As AToMSFramework.CPersistentObject - Return New TableB - End Function + 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 IsValid() As Boolean - Return True - End Function - End Class + Public Overrides Function getNewObject() As AToMSFramework.CPersistentObject + Return New TableB + End Function - Public Class TableC - Inherits CPersistentObject + Public Overrides Function IsValid() As Boolean + Return True + End Function + End Class - 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 + Public Class TableC + Inherits CPersistentObject - 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 _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 _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 + 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 - 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 + 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 Overrides Function getNewObject() As AToMSFramework.CPersistentObject - Return New TableC - End Function + 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 IsValid() As Boolean - Return True - End Function - End Class + Public Overrides Function getNewObject() As AToMSFramework.CPersistentObject + Return New TableC + End Function + + Public Overrides Function IsValid() As Boolean + Return True + End Function + End Class End Namespace \ No newline at end of file Index: AtomsFrameworkTests.vb =================================================================== RCS file: /cvsroot/jcframework/Nunit/InheritedClasses/AtomsFrameworkTests.vb,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- AtomsFrameworkTests.vb 31 Jan 2005 06:18:10 -0000 1.9 +++ AtomsFrameworkTests.vb 31 Jan 2005 22:27:17 -0000 1.10 @@ -396,5 +396,55 @@ Assert.AreEqual("me", e2.Name) End Sub - End Class + <Test()> Public Sub CheckCacheAfterRollback2() + 'Check that items are put back into collections and that deleted items are restored + Dim a As New TableA + Dim b As New TableB + Dim a1 As New TableA + a.Id = "1a" + b.Id = "1b" + b.TableA = a + a.TableBCollection.Add(b) + b = New TableB + b.Id = "2b" + b.TableA = a + a.TableBCollection.Add(b) + b = New TableB + b.Id = "3b" + b.TableA = a + a.TableBCollection.Add(b) + a.Save() + Assert.AreEqual(3, a.TableBCollection.Count) + pbroker.startTransaction() + a1.Id = "1a" + a1.Retrieve() + Assert.AreEqual(3, a1.TableBCollection.Count) + b = a.TableBCollection.Item(1) + Assert.AreEqual("2b", b.Id) + a.TableBCollection.Remove(1) + b.Delete() + Assert.AreEqual(2, a.TableBCollection.Count) + a.Save() + a1 = New TableA + a1.Id = "1a" + a1.Retrieve() + b = New TableB + b.Id = "2b" + b.Retrieve() + Assert.IsFalse(b.Persistent) + Assert.AreEqual(2, a1.TableBCollection.Count) + 'Now abort the transaction + pbroker.rollback() + a1 = New TableA + a1.Id = "1a" + a1.Retrieve() + b = New TableB + b.Id = "2b" + b.Retrieve() + Assert.IsTrue(b.Persistent) + Assert.AreEqual(3, a1.TableBCollection.Count) + Assert.AreEqual("2b", a1.TableBCollection.Item(1)) + End Sub + + End Class End Namespace \ No newline at end of file |
From: Richard B. <rb...@us...> - 2005-01-31 06:18:22
|
Update of /cvsroot/jcframework/Nunit/InheritedClasses In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9768/InheritedClasses Modified Files: AtomsFrameworkTests.vb Log Message: Test for cache state before and after transaction rollback Index: AtomsFrameworkTests.vb =================================================================== RCS file: /cvsroot/jcframework/Nunit/InheritedClasses/AtomsFrameworkTests.vb,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- AtomsFrameworkTests.vb 21 Dec 2004 22:00:01 -0000 1.8 +++ AtomsFrameworkTests.vb 31 Jan 2005 06:18:10 -0000 1.9 @@ -375,5 +375,26 @@ Assert.AreEqual("somename", CType(value, CEmployee).Name) End If End Sub + + <Test()> Public Sub CheckCacheAfterRollback() + Dim oid As String + Dim e2 As CEmployee + emp.Name = "me" + emp.Save() + oid = emp.OIDValue + pbroker.startTransaction() + emp.Name = "you" + emp.Save() + e2 = New CEmployee + e2.OIDValue = oid + e2.Retrieve() + Assert.AreEqual("you", e2.Name) + pbroker.rollback() + e2 = New CEmployee + e2.OIDValue = oid + e2.Retrieve() + Assert.AreEqual("me", e2.Name) + End Sub + End Class End Namespace \ No newline at end of file |
From: Richard B. <rb...@us...> - 2005-01-31 06:17:51
|
Update of /cvsroot/jcframework/dotnet In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9637 Modified Files: CConnection.vb CInjectedObject.vb readme.html Log Message: Fixed problem saving objects with 3+ levels of interface inheritance. Fixed problem with cache not being correctly restored after transaction rollback. Index: readme.html =================================================================== RCS file: /cvsroot/jcframework/dotnet/readme.html,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- readme.html 19 Dec 2004 22:43:17 -0000 1.5 +++ readme.html 31 Jan 2005 06:17:39 -0000 1.6 @@ -169,6 +169,16 @@ <td class="col1">Missing parameters</td> <td>Update statements were being generated with missing parameters. This only occurred when parameters for the where clause had NULL values and when ANSI null handling was on.<td> </tr> + <tr valign="top"> + <td>N/A</td> + <td class="col1">Rollback on transaction did not restore cache</td> + <td>Cache entries were not being correctly restored when a transaction was rolled back.<td> + </tr> + <tr valign="top"> + <td>N/A</td> + <td class="col1">Problem saving with 3 or more levels of interface inheritance</td> + <td>Only the lowest and highest mapped interfaces were being saved when an object with 3+ levels of interface inheritances was persisted.<td> + </tr> <tr class="tableCaption" valign="bottom"> <td colspan=3><br/>Modifications</td> </tr> Index: CConnection.vb =================================================================== RCS file: /cvsroot/jcframework/dotnet/CConnection.vb,v retrieving revision 1.30 retrieving revision 1.31 diff -u -d -r1.30 -r1.31 --- CConnection.vb 23 Dec 2004 01:14:44 -0000 1.30 +++ CConnection.vb 31 Jan 2005 06:17:39 -0000 1.31 @@ -506,9 +506,9 @@ If m_transactioncalls = 1 Then Try m_transaction.Rollback() - getPersistenceBrokerInstance().rollbackCache(Me) Catch ex As Exception End Try + getPersistenceBrokerInstance().rollbackCache(Me.Database) Me.Started = False m_transaction = Nothing End If @@ -986,9 +986,9 @@ If m_transactioncalls = 1 Then Try m_transaction.Rollback() - getPersistenceBrokerInstance().rollbackCache(Me) Catch ex As Exception End Try + getPersistenceBrokerInstance().rollbackCache(Me.Database) Me.Started = False m_transaction = Nothing End If @@ -1475,9 +1475,9 @@ If m_transactioncalls = 1 Then Try m_transaction.Rollback() - getPersistenceBrokerInstance().rollbackCache(Me) Catch ex As Exception End Try + getPersistenceBrokerInstance().rollbackCache(Me.Database) Me.Started = False m_transaction = Nothing End If @@ -1900,9 +1900,9 @@ If m_transactioncalls = 1 Then Try m_transaction.Rollback() - getPersistenceBrokerInstance().rollbackCache(Me) Catch ex As Exception End Try + getPersistenceBrokerInstance().rollbackCache(Me.Database) Me.Started = False m_transaction = Nothing End If @@ -2351,9 +2351,9 @@ If m_transactioncalls = 1 Then Try m_transaction.Rollback() - getPersistenceBrokerInstance().rollbackCache(Me) Catch ex As Exception End Try + getPersistenceBrokerInstance().rollbackCache(Me.Database) Me.Started = False m_transaction = Nothing End If Index: CInjectedObject.vb =================================================================== RCS file: /cvsroot/jcframework/dotnet/CInjectedObject.vb,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- CInjectedObject.vb 16 Nov 2004 21:39:34 -0000 1.8 +++ CInjectedObject.vb 31 Jan 2005 06:17:39 -0000 1.9 @@ -103,21 +103,68 @@ 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 + Dim intType, tmpType, interfaces() As Type 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 + + '----------------------------------------- + Dim n, m As Integer + Dim super As CClassMap + + ' get the super class map if the object has multi-level inheritance + For n = 0 To interfaces.Length - 1 + ClassMap = getClassMap(interfaces(n).Name, interfaces(n).FullName) + If (Not ClassMap Is Nothing) AndAlso ClassMap.SuperClass Is Nothing Then + super = ClassMap + For m = n To interfaces.Length - 2 + interfaces(m) = interfaces(m + 1) + Next + If interfaces.Length > 1 Then + interfaces(m) = Nothing End If + Exit For End If Next + + 'get actual interface which is the bottom level of inheritance + n = 0 + While n < interfaces.Length - 1 + If Not interfaces(n) Is Nothing Then + tmpCMap = getClassMap(interfaces(n).Name, interfaces(n).FullName) + If (Not tmpCMap Is Nothing) AndAlso tmpCMap.SuperClass Is super Then + super = tmpCMap + ClassMap = super + For m = n To interfaces.Length - 2 + interfaces(m) = interfaces(m + 1) + Next + interfaces(m) = Nothing + + If interfaces(0) Is Nothing Then + ClassMap = tmpCMap + Exit While + End If + n = 0 + Else + n = n + 1 + End If + Else + n = n + 1 + End If + End While + '----------------------------------------- + + '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 If (ClassMap Is Nothing) Then Throw New NoClassMapException("No class map for " & m_object.GetType.FullName) |
From: Dan M. <dan...@us...> - 2005-01-02 09:41:27
|
Update of /cvsroot/jcframework/Nunit In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1805/Nunit Modified Files: AtomsFramework.xml original db1.mdb Log Message: Add test to check if multiple retrive creteria of oneToMany collections does not duplicate records. Fix the problem in retriveAssociation() in CPersistentBroker.vb. Checks whether the object exist in the collection before adding it. Index: original db1.mdb =================================================================== RCS file: /cvsroot/jcframework/Nunit/original db1.mdb,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -r1.11 -r1.12 Binary files /tmp/cvsl4QWVc and /tmp/cvsJ9scnq differ Index: AtomsFramework.xml =================================================================== RCS file: /cvsroot/jcframework/Nunit/AtomsFramework.xml,v retrieving revision 1.14 retrieving revision 1.15 diff -u -d -r1.14 -r1.15 --- AtomsFramework.xml 21 Dec 2004 08:52:44 -0000 1.14 +++ AtomsFramework.xml 2 Jan 2005 09:41:09 -0000 1.15 @@ -118,13 +118,14 @@ <attribute name="Id" column="id" key="primary"/> <attribute name="field1" column="field1" /> <attribute name="AId" column="a_id" /> - <attrbute name="TableA" /> + <attribute name="TableA" /> + <attribute name="TableDCollection" /> </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" /> + <attribute 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"> @@ -139,6 +140,7 @@ <attribute name="OIDValue" column="oid" key="primary"/> <attribute name="CreatedDate" column="CreatedDate" timestamp="true"/> <attribute name="ModifiedDate" column="ModifiedDate" timestamp="true"/> + <attribute name="Id" column="id" find="true"/> <attribute name="BCol" /> <attribute name="C" /> <attribute name="COID" column="cOID"/> @@ -151,6 +153,7 @@ <attribute name="Text" column="textCol"/> <attribute name="A" /> <attribute name="AOID" column="aOID"/> + <attribute name="NCol" /> </class> <class name="C" table="tblC" database="MSA" namespace="NunitTests.InheritedClasses"> <attribute name="OIDValue" column="oid" key="primary"/> @@ -219,11 +222,19 @@ <attribute name="M"/> <attribute name="MOID" column="mOID"/> </class> - <class name="M" table="tblK" database="MSA" namespace="NunitTests.InheritedClasses"> + <class name="M" table="tblM" database="MSA" namespace="NunitTests.InheritedClasses"> + <attribute name="OIDValue" column="oid" key="primary" reference="OIDValue"/> + <attribute name="CreatedDate" column="CreatedDate" timestamp="true"/> + <attribute name="ModifiedDate" column="ModifiedDate" timestamp="true"/> + <attribute name="I" column="i"/> + </class> + <class name="N" table="tblN" database="MSA" namespace="NunitTests.InheritedClasses"> <attribute name="OIDValue" column="oid" key="primary" reference="OIDValue"/> <attribute name="CreatedDate" column="CreatedDate" timestamp="true"/> <attribute name="ModifiedDate" column="ModifiedDate" timestamp="true"/> <attribute name="I" column="i"/> + <attribute name="B" /> + <attribute name="BOID" column="bOID"/> </class> <association fromClass="NunitTests.InheritedClasses.A" toClass="NunitTests.InheritedClasses.B" @@ -275,7 +286,27 @@ inverse="false"> <entry fromAttribute="COID" toAttribute="OIDValue"/> </association> - + <association fromClass="NunitTests.InheritedClasses.B" + toClass="NunitTests.InheritedClasses.N" + cardinality="oneToMany" + target="NCol" + retrieveAutomatic="true" + deleteAutomatic="true" + saveAutomatic="true" + inverse="false"> + <entry fromAttribute="OIDValue" toAttribute="BOID"/> + </association> + <association fromClass="NunitTests.InheritedClasses.N" + toClass="NunitTests.InheritedClasses.B" + cardinality="oneToOne" + target="B" + retrieveAutomatic="true" + deleteAutomatic="false" + saveAutomatic="false" + inverse="false"> + <entry fromAttribute="BOID" 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" /> |
From: Dan M. <dan...@us...> - 2005-01-02 09:41:24
|
Update of /cvsroot/jcframework/dotnet In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1805/dotnet Modified Files: CPersistenceBroker.vb Log Message: Add test to check if multiple retrive creteria of oneToMany collections does not duplicate records. Fix the problem in retriveAssociation() in CPersistentBroker.vb. Checks whether the object exist in the collection before adding it. Index: CPersistenceBroker.vb =================================================================== RCS file: /cvsroot/jcframework/dotnet/CPersistenceBroker.vb,v retrieving revision 1.87 retrieving revision 1.88 diff -u -d -r1.87 -r1.88 --- CPersistenceBroker.vb 22 Dec 2004 04:15:39 -0000 1.87 +++ CPersistenceBroker.vb 2 Jan 2005 09:41:10 -0000 1.88 @@ -201,7 +201,7 @@ If Not x Is Nothing Then Throw x End If - End Try + End Try End SyncLock End Function @@ -701,6 +701,8 @@ Dim found As Boolean Dim col As IList Dim myKeys(cm.AssociationMaps.Count) As String + Dim tmpObj As IPersistableObject + cm.AssociationMaps.Keys.CopyTo(myKeys, 0) Dim anObjPers As IPersistableObject For i = 0 To cm.AssociationMaps.Count - 1 @@ -751,12 +753,12 @@ End Try End If If found Then - Value.IsDirty = False 'After populating a new object - Value.OriginalCacheKey = New CCacheKey(Value) - obj.SetAttributeValue(udaMap.Target, Value.GetSourceObject) + Value.IsDirty = False 'After populating a new object + Value.OriginalCacheKey = New CCacheKey(Value) + obj.SetAttributeValue(udaMap.Target, Value.GetSourceObject) + End If End If 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)) @@ -779,14 +781,26 @@ 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.GetSourceObject) - m_cache.Add(anObjPers) 'Add retrieved objects to the cache - Try - PCCacheSize.RawValue = m_cache.Count - Catch - End Try + 'Need to determine if new object is already in the collection + '(prevents duplicates when multiple one-to-many associations exist) + gotValue = False + For Each tmpColObj As Object In col + If tmpColObj.GetType.IsSubclassOf(GetType(CPersistentObject)) Then + tmpObj = tmpColObj + Else + tmpObj = LocateOrCreateInjObject(tmpColObj) + End If + If tmpObj.Equals(anObjPers) Then + gotValue = True + End If + Next + + If Not gotValue Then + anObjPers.IsDirty = False 'After populating a new object + anObjPers.OriginalCacheKey = New CCacheKey(anObjPers) + col.Add(anObjPers.GetSourceObject) + m_cache.Add(anObjPers) 'Add retrieved objects to the cache + End If cursor.nextCursor() End While End If @@ -976,7 +990,7 @@ Try deletePrivateObject(obj, conn, deleteSuperClass) conn.commit() - Catch ex As Exception + Catch ex As Exception x = New DeleteException(ex.Message, ex) conn.rollback() Finally @@ -991,7 +1005,7 @@ If Not x Is Nothing Then Throw x End If - End Try + End Try End SyncLock End Sub @@ -1822,9 +1836,9 @@ Return cursor Catch - firstClassMap.RelationalDatabase.freeConnection(conn) - Return Nothing - End Try + firstClassMap.RelationalDatabase.freeConnection(conn) + Return Nothing + End Try End Function |
From: Dan M. <dan...@us...> - 2005-01-02 09:41:22
|
Update of /cvsroot/jcframework/Nunit/InheritedClasses In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1805/Nunit/InheritedClasses Modified Files: SuperClassTests.vb tblAtoKClasses.vb Log Message: Add test to check if multiple retrive creteria of oneToMany collections does not duplicate records. Fix the problem in retriveAssociation() in CPersistentBroker.vb. Checks whether the object exist in the collection before adding it. Index: tblAtoKClasses.vb =================================================================== RCS file: /cvsroot/jcframework/Nunit/InheritedClasses/tblAtoKClasses.vb,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- tblAtoKClasses.vb 21 Dec 2004 22:00:01 -0000 1.4 +++ tblAtoKClasses.vb 2 Jan 2005 09:41:10 -0000 1.5 @@ -112,12 +112,16 @@ Inherits CPersistentObject Public Sub New() + _nCol = New CPersistentCollection + _nCol.ContainerObject = Me + Me.SetDirtyFlag() End Sub Public _id As Integer = 0 Public _text As String = String.Empty Public _a As A = Nothing Public _aOID As String = Nothing + Public _nCol As CPersistentCollection Public Property Id() As Integer Get @@ -185,6 +189,21 @@ End Set End Property + Public Property NCol() As CPersistentCollection + Get + Return Me._nCol + End Get + Set(ByVal Value As CPersistentCollection) + If Me._nCol.Equals(Value) Then + Me._nCol = Value + For Each _n As N In Me._nCol + _n.B = Me + Next + SetDirtyFlag() + End If + End Set + End Property + Public Overloads Overrides Function getNewObject() As CPersistentObject Return New B End Function @@ -663,4 +682,75 @@ End Function End Class + Public Class N + Inherits CPersistentObject + + Public Sub New() + End Sub + Private _i As Integer = 0 + Private _b As B = Nothing + Private _bOID As String = Nothing + + Public Property I() As Integer + Get + Return Me._i + End Get + Set(ByVal Value As Integer) + If Not (Me._i = Value) Then + Me._i = Value + Me.SetDirtyFlag() + End If + End Set + End Property + + Public Property B() As B + Get + Return Me._b + End Get + Set(ByVal Value As B) + If Me._b Is Nothing AndAlso Not (Value Is Nothing) Then + Me._b = Value + Me._bOID = Value.OIDValue + Else + If Value Is Nothing Then + Me._b = Nothing + Me._bOID = Nothing + Else + If Not Me._b.Equals(Value) Then + Me._b = Value + Me._bOID = Value.OIDValue + End If + End If + End If + Me.SetDirtyFlag() + End Set + End Property + + Public Property BOID() As String + Get + If Not (Me._b Is Nothing) Then + Return Me._b.OIDValue + Else + Return Me._bOID + End If + End Get + Set(ByVal Value As String) + If Not (Me._b Is Nothing) Then + If Not (Me._b.OIDValue = Value) Then + Me._b.OIDValue = Value + Me.SetDirtyFlag() + End If + End If + Me._bOID = Value + End Set + End Property + + Public Overloads Overrides Function getNewObject() As CPersistentObject + Return New N + End Function + + Public Overloads Overrides Function IsValid() As Boolean + Return True + End Function + End Class End Namespace \ No newline at end of file Index: SuperClassTests.vb =================================================================== RCS file: /cvsroot/jcframework/Nunit/InheritedClasses/SuperClassTests.vb,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- SuperClassTests.vb 21 Dec 2004 22:00:01 -0000 1.4 +++ SuperClassTests.vb 2 Jan 2005 09:41:10 -0000 1.5 @@ -175,5 +175,49 @@ Assert.AreEqual(124, j.Id) End Sub + <Test()> Public Sub MultiRetreiveCreteria() + Dim a As A + Dim b As B + Dim n As N + + a = New A + a.Id = 5 + a.Text = "Instance of class A" + + b = New B + b.Id = 1 + b.Text = "Instance of class B" + b.A = a + a.BCol.Add(b) + + n = New N + n.I = 7 + n.B = b + b.NCol.Add(n) + + a.Save() + + pbroker.ClearCache() + + Dim mrc As New CMultiRetrieveCriteria + Dim a1 As New A + Dim cpo As CPersistentObject + Dim c As CCursor + + cpo = CType(a1, A) + mrc.addObjectToJoin(a1, Nothing, "") + mrc.ClassMap = cpo.getClassMap + mrc.ReturnFullObjects = True + mrc.WhereCondition.ClassMap = cpo.getClassMap + mrc.WhereCondition.addSelectEqualTo("Id", 5) + c = mrc.perform + c.loadObject(cpo, pbroker) + cpo.Retrieve(cpo) + + a1 = CType(cpo, A) + + Assert.AreEqual(1, a1.BCol.Count, "Number of objects in collection is grater then 1") + + End Sub End Class End Namespace \ No newline at end of file |
From: Richard B. <rb...@us...> - 2004-12-23 01:14:54
|
Update of /cvsroot/jcframework/dotnet In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4258 Modified Files: AToMSFramework.vbproj AssemblyInfo.vb CConnection.vb Added Files: COracleDatabase.vb Log Message: Added specific support for Oracle databases - needs testing Changed version number to 2.1.0.0 Index: AToMSFramework.vbproj =================================================================== RCS file: /cvsroot/jcframework/dotnet/AToMSFramework.vbproj,v retrieving revision 1.20 retrieving revision 1.21 diff -u -d -r1.20 -r1.21 --- AToMSFramework.vbproj 15 Dec 2004 23:46:04 -0000 1.20 +++ AToMSFramework.vbproj 23 Dec 2004 01:14:44 -0000 1.21 @@ -82,6 +82,11 @@ AssemblyName = "ByteFX.MySqlClient" HintPath = "..\ByteFX.MySqlClient.76.NI\ByteFX.MySqlClient.dll" /> + <Reference + Name = "System.Data.OracleClient" + AssemblyName = "System.Data.OracleClient" + HintPath = "..\..\..\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.Data.OracleClient.dll" + /> </References> <Imports> <Import Namespace = "Microsoft.VisualBasic" /> @@ -269,6 +274,11 @@ BuildAction = "Compile" /> <File + RelPath = "COracleDatabase.vb" + SubType = "Code" + BuildAction = "Compile" + /> + <File RelPath = "COrderEntry.vb" SubType = "Code" BuildAction = "Compile" Index: CConnection.vb =================================================================== RCS file: /cvsroot/jcframework/dotnet/CConnection.vb,v retrieving revision 1.29 retrieving revision 1.30 diff -u -d -r1.29 -r1.30 --- CConnection.vb 16 Nov 2004 21:39:34 -0000 1.29 +++ CConnection.vb 23 Dec 2004 01:14:44 -0000 1.30 @@ -5,6 +5,7 @@ Imports System.Data.SqlClient Imports ByteFX.Data.MySqlClient Imports System.Data.Odbc +Imports System.Data.OracleClient '''----------------------------------------------------------------------------- ''' <summary> @@ -2051,3 +2052,455 @@ Dispose(False) End Sub End Class + +'''----------------------------------------------------------------------------- +''' Project : AToMSFramework +''' Class : COracleConnection +''' +'''----------------------------------------------------------------------------- +''' <summary> +''' Connection class for Oracle data sources +''' </summary> +''' <remarks><para>This class implements the <see cref="T:AToMSFramework._CConnection"/> interface and is used +''' to manage connections to Oracle datasources.</para> +''' <para>The following should be taken into consideration when using this +''' class:</para> +''' <para>1. Only one physical transaction runs on a database connection at any one time</para> +''' <para>2. Only one physical connection to the database exists. Multiple connection +''' objects will share a connection where possible</para> +''' <para>3. If nested transactions are started, the commit or rollback only occurs on the +''' first transaction created. A rollback on any nested transaction will cause all +''' outside transactions to also roll back.</para> +''' </remarks> +''' <seealso cref="T:AToMSFramework._CConnection"/> +''' <history> +''' [rbanks] 23/12/2004 Created +''' </history> +'''----------------------------------------------------------------------------- +Public Class COracleConnection + Implements _CConnection + Implements IDisposable + + Private m_connection As OracleConnection + Private m_autoCommit As Boolean + Private m_started As Boolean + Private m_manageTransactions As Boolean + Private m_transaction As OracleTransaction + Private m_transactioncalls As Integer + Private m_references As Integer + Private m_db As _CRelationalDatabase + Private Const DEBUG_MODE As Boolean = True + Private m_disposed As Boolean + + '''----------------------------------------------------------------------------- + ''' <summary> + ''' The actual Oracle connection for the object. + ''' </summary> + ''' <value></value> + ''' <remarks></remarks> + ''' <history> + ''' [rbanks] 23/12/2004 Created + ''' </history> + '''----------------------------------------------------------------------------- + Public Property Connection() As OracleConnection + Get + Connection = m_connection + End Get + Set(ByVal Value As OracleConnection) + m_connection = Value + End Set + End Property + + '''----------------------------------------------------------------------------- + ''' <summary> + ''' See <see cref="P:AToMSFramework._CConnection.AutoCommit">_CConnection</see>. + ''' </summary> + ''' <value></value> + ''' <remarks></remarks> + ''' <history> + ''' [rbanks] 23/12/2004 Created + ''' </history> + '''----------------------------------------------------------------------------- + Public Property AutoCommit() As Boolean Implements _CConnection.AutoCommit + Get + AutoCommit = m_autoCommit + End Get + Set(ByVal Value As Boolean) + m_autoCommit = Value + End Set + End Property + + '''----------------------------------------------------------------------------- + ''' <summary> + ''' See <see cref="P:AToMSFramework._CConnection.Started">_CConnection</see>. + ''' </summary> + ''' <value></value> + ''' <remarks></remarks> + ''' <history> + ''' [rbanks] 23/12/2004 Created + ''' </history> + '''----------------------------------------------------------------------------- + Public Property Started() As Boolean Implements _CConnection.Started + Get + Started = m_started + End Get + Set(ByVal Value As Boolean) + m_started = Value + End Set + End Property + + '''----------------------------------------------------------------------------- + ''' <summary> + ''' See <see cref="P:AToMSFramework._CConnection.ManageTransactions">_CConnection</see>. + ''' </summary> + ''' <value></value> + ''' <remarks></remarks> + ''' <history> + ''' [rbanks] 23/12/2004 Created + ''' </history> + '''----------------------------------------------------------------------------- + Public Property ManageTransactions() As Boolean Implements _CConnection.ManageTransactions + Get + ManageTransactions = m_manageTransactions + End Get + Set(ByVal Value As Boolean) + m_manageTransactions = Value + End Set + End Property + + '''----------------------------------------------------------------------------- + ''' <summary> + ''' See <see cref="M:AToMSFramework._CConnection.commit">_CConnection</see>. + ''' </summary> + ''' <remarks></remarks> + ''' <history> + ''' [rbanks] 23/12/2004 Created + ''' </history> + '''----------------------------------------------------------------------------- + Public Sub commit() Implements _CConnection.commit + If DEBUG_MODE Then + If m_transactioncalls = 1 Then + System.Diagnostics.Debug.WriteLine("COMMIT TRANSACTION") + Else + System.Diagnostics.Debug.WriteLine("Nested COMMIT TRANSACTION - not actually called") + End If + End If + If Me.ManageTransactions Then + If m_transactioncalls = 1 Then + m_transaction.Commit() + getPersistenceBrokerInstance().commitCache(Me.Database) + Me.Started = False + m_transaction = Nothing + End If + m_transactioncalls -= 1 + End If + End Sub + + '''----------------------------------------------------------------------------- + ''' <summary> + ''' The current transaction for the connection. + ''' </summary> + ''' <history> + ''' [rbanks] 23/12/2004 Created + ''' </history> + '''----------------------------------------------------------------------------- + Public ReadOnly Property Transaction() As OracleTransaction + Get + Transaction = m_transaction + End Get + End Property + + '''----------------------------------------------------------------------------- + ''' <summary> + ''' See <see cref="M:AToMSFramework._CConnection.startTransaction">_CConnection</see>. + ''' </summary> + ''' <history> + ''' [rbanks] 23/12/2004 Created + ''' </history> + '''----------------------------------------------------------------------------- + Public Overloads Sub startTransaction() Implements _CConnection.startTransaction + If DEBUG_MODE Then + If m_transactioncalls = 0 Then + System.Diagnostics.Debug.WriteLine("BEGIN TRANSACTION") + Else + System.Diagnostics.Debug.WriteLine("Nested BEGIN TRANSACTION - not actually called") + End If + End If + If Me.ManageTransactions Then + If Not Me.Started Then + m_transaction = m_connection.BeginTransaction + End If + m_transactioncalls += 1 + Me.Started = True + End If + End Sub + + '''----------------------------------------------------------------------------- + ''' <summary> + ''' See <see cref="M:AToMSFramework._CConnection.processStatement">_CConnection</see>. + ''' </summary> + ''' <param name="statement"></param> + ''' <remarks></remarks> + ''' <history> + ''' [rbanks] 23/12/2004 Created + ''' </history> + '''----------------------------------------------------------------------------- + Public Sub processStatement(ByVal statement As CSqlStatement) Implements _CConnection.processStatement + Dim m_command As New OracleCommand + Dim m_recordcount As Integer + Dim cp As CSQLParameter + Dim param As OracleParameter + Dim dd As Date + + Try + m_command.Connection = m_connection + m_command.CommandText = statement.SqlString + For Each cp In statement.Parameters + If Not cp.Ignore Then + param = New OracleParameter + param.ParameterName = cp.Name + param.OracleType = CType(cp.Column.ProviderType, OracleType) + param.Value = cp.Value + m_command.Parameters.Add(param) + End If + Next + m_command.Transaction = m_transaction + Debug.WriteLine(m_command.CommandText) + m_recordcount = m_command.ExecuteNonQuery() + If m_recordcount = 0 Then + Throw New NothingUpdatedException("No records were affected by the update") + End If + Catch err As OracleException + Throw err + Catch err As Exception + Throw err + End Try + End Sub + + '''----------------------------------------------------------------------------- + ''' <summary> + ''' See <see cref="M:AToMSFramework._CConnection.processSelectStatement">_CConnection</see>. + ''' </summary> + ''' <param name="statement"></param> + ''' <returns></returns> + ''' <remarks></remarks> + ''' <history> + ''' [rbanks] 23/12/2004 Created + ''' </history> + '''----------------------------------------------------------------------------- + Public Function processSelectStatement(ByVal statement As CSqlStatement) As CResultset Implements _CConnection.processSelectStatement + SyncLock GetType(COracleConnection) + Dim x As RetrieveException + Dim rs As New CResultset + Dim param As OracleParameter + Dim dd As Date + Dim m_command As New OracleCommand + + If DEBUG_MODE Then + System.Diagnostics.Debug.WriteLine(statement.SqlString) + End If + + m_command.Connection = m_connection + m_command.CommandText = statement.SqlString + For Each cp As CSQLParameter In statement.Parameters + If Not cp.Ignore Then + param = New OracleParameter + param.ParameterName = cp.Name + param.OracleType = CType(cp.Column.ProviderType, OracleType) + param.Value = cp.Value + m_command.Parameters.Add(param) + End If + Next + + Try + Dim m_adapter As New OracleDataAdapter(m_command) + If m_transactioncalls > 0 Then m_adapter.SelectCommand.Transaction = m_transaction + m_adapter.Fill(rs.ResultSet, "ole") + m_adapter.Dispose() + Catch err As OracleException + x = New RetrieveException("Oracle Error: " & err.Message, err) + Catch err As Exception + x = New RetrieveException(err.Message, err) + End Try + If Not x Is Nothing Then + Throw x + End If + processSelectStatement = rs + End SyncLock + End Function + + '''----------------------------------------------------------------------------- + ''' <summary> + ''' See <see cref="M:AToMSFramework._CConnection.rollback">_CConnection</see>. + ''' </summary> + ''' <remarks></remarks> + ''' <history> + ''' [rbanks] 23/12/2004 Created + ''' </history> + '''----------------------------------------------------------------------------- + Public Sub rollback() Implements _CConnection.rollback + Dim pb As CPersistenceBroker + If DEBUG_MODE Then + If m_transactioncalls = 1 Then + System.Diagnostics.Debug.WriteLine("ROLLBACK TRANSACTION") + Else + System.Diagnostics.Debug.WriteLine("Nested ROLLBACK TRANSACTION - not actually performed") + End If + End If + If Me.ManageTransactions Then + If m_transactioncalls = 1 Then + Try + m_transaction.Rollback() + getPersistenceBrokerInstance().rollbackCache(Me) + Catch ex As Exception + End Try + Me.Started = False + m_transaction = Nothing + End If + m_transactioncalls -= 1 + End If + End Sub + + Public Sub New() + MyBase.New() + 'By default we manage tranactions + 'For DB's that do not manage transactions we should + 'set this attribute to false + m_manageTransactions = True + m_references = 0 + End Sub + + '''----------------------------------------------------------------------------- + ''' <summary> + ''' See <see cref="M:AToMSFramework._CConnection.CloseConnection">_CConnection</see>. + ''' </summary> + ''' <remarks></remarks> + ''' <history> + ''' [rbanks] 23/12/2004 Created + ''' </history> + '''----------------------------------------------------------------------------- + Public Sub CloseConnection() Implements _CConnection.CloseConnection + m_references -= 1 + If m_references = 0 Then + m_connection.Close() + End If + End Sub + + '''----------------------------------------------------------------------------- + ''' <summary> + ''' See <see cref="P:AToMSFramework._CConnection.IsClosed">_CConnection</see>. + ''' </summary> + ''' <value></value> + ''' <remarks></remarks> + ''' <history> + ''' [rbanks] 23/12/2004 Created + ''' </history> + '''----------------------------------------------------------------------------- + Public ReadOnly Property IsClosed() As Boolean Implements _CConnection.IsClosed + Get + Return m_connection.State = ConnectionState.Closed + End Get + End Property + + '''----------------------------------------------------------------------------- + ''' <summary> + ''' See <see cref="P:AToMSFramework._CConnection.ReferenceCount">_CConnection</see>. + ''' </summary> + ''' <value></value> + ''' <remarks></remarks> + ''' <history> + ''' [rbanks] 23/12/2004 Created + ''' </history> + '''----------------------------------------------------------------------------- + Public Property ReferenceCount() As Integer Implements _CConnection.ReferenceCount + Get + Return m_references + End Get + Set(ByVal Value As Integer) + m_references = Value + End Set + End Property + + '''----------------------------------------------------------------------------- + ''' <summary> + ''' See <see cref="P:AToMSFramework._CConnection.getTableSchema">_CConnection</see>. + ''' </summary> + ''' <param name="tName"></param> + ''' <returns></returns> + ''' <remarks></remarks> + ''' <history> + ''' [rbanks] 23/12/2004 Created + ''' </history> + '''----------------------------------------------------------------------------- + Public Function getTableSchema(ByVal tName As String) As System.Data.DataTable Implements _CConnection.getTableSchema + Dim statement As String + Dim cmd As OracleCommand + Dim dr As OracleDataReader + Dim dt As DataTable + + statement = "select * from " & tName + Try + cmd = New OracleCommand(statement, Me.Connection) + dr = cmd.ExecuteReader(CommandBehavior.SchemaOnly) + dt = dr.GetSchemaTable + Catch ex As Exception + dt = Nothing + Throw ex + End Try + Return dt + End Function + + Public Overloads Sub startTransaction(ByVal isolationLevel As System.Data.IsolationLevel) Implements _CConnection.startTransaction + If DEBUG_MODE Then + If m_transactioncalls = 0 Then + System.Diagnostics.Debug.WriteLine("BEGIN TRANSACTION") + Else + System.Diagnostics.Debug.WriteLine("Nested BEGIN TRANSACTION - not actually called") + End If + End If + If Me.ManageTransactions Then + If Not Me.Started Then + m_transaction = m_connection.BeginTransaction(isolationLevel) + End If + m_transactioncalls += 1 + Me.Started = True + End If + End Sub + + Public Property Database() As _CRelationalDatabase Implements _CConnection.Database + Get + Return m_db + End Get + Set(ByVal Value As _CRelationalDatabase) + m_db = Value + End Set + End Property + + Public Overloads Sub Dispose() Implements System.IDisposable.Dispose + Dispose(True) + GC.SuppressFinalize(Me) + End Sub + + Protected Overridable Overloads Sub Dispose(ByVal disposing As Boolean) + If Not m_disposed Then + If disposing Then + If Me.Started AndAlso Not m_transaction Is Nothing Then + m_transaction.Rollback() + m_transaction = Nothing + End If + If Not m_connection Is Nothing Then + m_connection.Close() + m_connection.Dispose() + m_connection = Nothing + End If + m_db = Nothing + m_disposed = True + End If + End If + End Sub + + Protected Overrides Sub Finalize() + ' Simply call Dispose(False). + Dispose(False) + End Sub +End Class --- NEW FILE: COracleDatabase.vb --- Option Strict Off Option Explicit On Imports System.Data.OracleClient '''----------------------------------------------------------------------------- ''' Project : AToMSFramework ''' Class : COracleDatabase ''' '''----------------------------------------------------------------------------- ''' <summary> ''' Implementation of CRelationalDatabase for Oracle Database Servers. ''' </summary> ''' <remarks>This class contains the specific functionality required for the ''' framework to interact with oracle databases.</remarks> ''' <history> ''' [rbanks] 11/12/2003 Created ''' </history> '''----------------------------------------------------------------------------- Public Class COracleDatabase Inherits CRelationalDatabase Private m_user As String Private m_password As String Private m_serverName As String '''----------------------------------------------------------------------------- ''' <summary> ''' Establishes a new database connection. ''' </summary> ''' <returns>A COracleConnection containing the newly established connection.</returns> ''' <remarks>The COracleConnection class implements the _CConnection interface which ''' is required by this method. ''' <para>If the connection cannot be established an exception will be thrown.</para> ''' <history> ''' [rbanks] 23/12/2004 Created ''' </history> '''----------------------------------------------------------------------------- Public Overrides Function getNewConnection() As _CConnection Dim conn As New COracleConnection conn.Connection = New OracleConnection conn.ManageTransactions = True Try If m_user Is Nothing OrElse m_user.Length = 0 Then m_user = "" m_password = "" Dim pbroker As CPersistenceBroker pbroker = getOrSetPBInstance(pbroker) pbroker.GetLoginDetails(Me, m_user, m_password) End If If m_user = "SSPI" Then conn.Connection.ConnectionString = _ "Data Source=" & m_serverName & ";" & _ "Integrated Security=true;" & _ "Persist Security Info=False;" Else conn.Connection.ConnectionString = _ "Data Source=" & m_serverName & ";" & _ "Integrated Security=false;" & _ "Persist Security Info=False;" & _ "User Id=" & m_user & ";" & _ "Password=" & m_password End If conn.Connection.Open() Catch ex As OracleClient.OracleException Throw New DatabaseConnectionException(ex.Message, ex) Catch ex As Exception Throw New DatabaseConnectionException(ex.Message, ex) End Try getNewConnection = conn End Function '''----------------------------------------------------------------------------- ''' <summary> ''' Sets the initial properties of the database. ''' </summary> ''' <param name="properties">The property information supplied in the XML mapping file.</param> ''' <remarks>In order to initialise the database object properly the following must be supplied ''' <list type="bullet"> ''' <item><description>ServerName: The name of the database server</description></item> ''' <item><description>User: The user name for secured databases. Use SSPI to suppply a user at runtime</description></item> ''' <item><description>Password: The password for secured databases.</description></item> ''' <item><description>OIDTable: The table name containing the OID A-value. Can be ignored if OIDs are not used.</description></item> ''' </list> ''' <para>If the database is used without having been properly initialised you are likely ''' to get exceptions thrown in your application.</para> ''' </remarks> ''' <history> ''' [rbanks] 23/12/2004 Created ''' </history> '''----------------------------------------------------------------------------- Public Overrides Sub init(ByVal properties As System.Collections.Specialized.HybridDictionary) m_serverName = properties.Item("serverName") m_user = properties.Item("user") m_password = properties.Item("password") If properties.Item("ansinulls") Is Nothing Then UseANSINulls = False Else UseANSINulls = properties.Item("ansinulls") End If MyBase.OIDTable = properties.Item("OIDTable") End Sub '''----------------------------------------------------------------------------- ''' <summary> ''' Gets the value of an object in a format the database can understand. ''' </summary> ''' <param name="tempValue">The object being evaluated.</param> ''' <returns>A string containing the SQL compatible value for the object</returns> ''' <remarks>The following rules are applied when converting object values into ''' database compatible strings ''' <para>Any value that is a Null Alias <see cref="M:AToMSFramework.ModAliasNull.IsNullAlias"/> ''' will be returned as NULL.</para> ''' <para>Strings are enclosed in single quotes. If the string is already enclosed in single quotes then ''' nothing is changed. Also, any single quotes within the string are converted to a pair of single quotes.</para> ''' <para>Dates are converted to yyyy-MM-dd HH:mm:ss format and enclosed in single quotes. If a datetime field ''' only has a time value, then a time-only string is returned instead.</para> ''' <para>Booleans are converted to 1 or 0</para> ''' <para>Numbers are converted to strings directly.</para> ''' <para>Objects that are nothing return a NULL and all other objects are directly converted to strings using their ''' inbuilt ToString methods.</para></remarks> ''' <history> ''' [rbanks] 11/12/2003 Created ''' </history> '''----------------------------------------------------------------------------- Public Overrides Function getValueFor(ByVal tempValue As Object) As String Dim tempRetorno As String Dim dd As DateTime Dim OriginalCulture As System.Globalization.CultureInfo Dim TempCulture As System.Globalization.CultureInfo If IsNullAlias(tempValue) Then Return "NULL" Else Select Case VarType(tempValue) Case VariantType.String If Left(tempValue, 1) = "'" And Right(tempValue, 1) = "'" And CStr(tempValue).Length > 2 Then 'string already enclosed in quotes so ignore tempRetorno = tempValue Else 'replace single quote with double quote, and enclose entire string in quotes tempRetorno = "'" & Replace(tempValue, "'", "''") & "'" End If Case VariantType.Date TempCulture = New System.Globalization.CultureInfo("en-US") OriginalCulture = System.Threading.Thread.CurrentThread.CurrentCulture System.Threading.Thread.CurrentThread.CurrentCulture = TempCulture System.Threading.Thread.CurrentThread.CurrentUICulture = TempCulture dd = CType(tempValue, DateTime) If dd = Date.MinValue Then tempRetorno = "NULL" Else If dd.Date.Ticks = 0 Then 'MSSQL doesn't support dates with years less than 1753, so time only 'values that format to "0001-01-01 11:23:00" for example produce errors. 'If it's just a time we will only return time portion. tempRetorno = "'" & dd.ToString("HH:mm:ss") & "'" Else tempRetorno = "'" & dd.ToString("yyyy-MM-dd HH:mm:ss") & "'" End If End If System.Threading.Thread.CurrentThread.CurrentCulture = OriginalCulture System.Threading.Thread.CurrentThread.CurrentUICulture = OriginalCulture Case VariantType.Boolean tempRetorno = IIf(tempValue, "1", "0") Case VariantType.Single, VariantType.Double, VariantType.Decimal, VariantType.Decimal tempRetorno = tempValue.ToString Case Else tempRetorno = tempValue End Select End If getValueFor = tempRetorno End Function '''----------------------------------------------------------------------------- ''' <summary> ''' Gets the next OID A-Value from the database. ''' </summary> ''' <returns>A integer containing the A-Value.</returns> ''' <remarks>A connection is established to the database and the OIDTable (specified in ''' the XML mapping) is queried and updated. The obtained A-Value is returned. ''' <para>Should an error occur a value of 0 will be returned.</para></remarks> ''' <history> ''' [rbanks] 11/12/2003 Created ''' </history> '''----------------------------------------------------------------------------- Public Overrides Function getNextOIDAvalue() As Integer Dim rs As New DataSet Dim da As New OracleDataAdapter Dim cb As OracleCommandBuilder Dim aValue As Integer Dim row As System.Data.DataRow Dim p As OracleParameter Dim initvals() As Object = {1} Dim x As OIDException Dim conn As COracleConnection conn = Me.getConnection(Nothing) conn.AutoCommit = False conn.startTransaction() Try da.SelectCommand = New OracleCommand("select oidAValue from " & Me.OIDTable, conn.Connection, conn.Transaction) cb = New OracleCommandBuilder(da) da.Fill(rs, "oid") If rs.Tables(0).Rows.Count = 0 Then 'Seed with value = 1 row = rs.Tables(0).Rows.Add(initvals) aValue = 1 Else rs.Tables(0).Rows(0).Item(0) += 1 aValue = rs.Tables(0).Rows(0).Item(0) End If da.Update(rs, "oid") da.Dispose() conn.commit() Catch err As OracleException conn.rollback() x = New OIDException(err.Message, err) Catch err As Exception conn.rollback() x = New OIDException(err.Message, err) Finally Me.freeConnection(conn) If Not x Is Nothing Then Throw x End If End Try Return aValue End Function '''----------------------------------------------------------------------------- ''' <summary> ''' Method to get the last Identity value for the connection. ''' </summary> ''' <param name="conn">The connection to use.</param> ''' <returns>An integer containing the value of the last updated identity column</returns> ''' <remarks>If multiple identity columns were updated the return value will only contain ''' the value of the last identity column updated. ''' <para>Identity values are retrieved by querying the @@IDENTITY value.</para> ''' <para>Should an error occur an exception will be thrown.</para></remarks> ''' <history> ''' [rbanks] 11/12/2003 Created ''' </history> '''----------------------------------------------------------------------------- Public Overrides Function getIdentityValue(ByVal conn As _CConnection) As Integer Dim rs As New DataSet Dim da As New OracleDataAdapter Dim cb As OracleCommandBuilder Dim aValue As Integer Dim connection As COracleConnection connection = conn connection.AutoCommit = False Try da.SelectCommand = New OracleCommand("select @@IDENTITY", connection.Connection, connection.Transaction) cb = New OracleCommandBuilder(da) da.Fill(rs, "identity") If rs.Tables(0).Rows.Count = 0 Then Throw New IdentityValueException("Could not retrieve identity value") Else If IsDBNull(rs.Tables(0).Rows(0).Item(0)) Then aValue = 0 Else aValue = rs.Tables(0).Rows(0).Item(0) End If Debug.WriteLine("Returned Identity value: " & aValue.ToString) End If da.Dispose() Catch err As OracleException Throw New IdentityValueException(err.Message, err) End Try Return aValue End Function '''----------------------------------------------------------------------------- ''' <summary> ''' Returns the SQL syntax placeholder for a parameter ''' </summary> ''' <param name="i">The number of the parameter being added</param> ''' <returns>A string containing the oracle parameter placeholder</returns> ''' <remarks>Since the parameter is for an Oracle connection only a the returned ''' string is in the format of :pxxx where xxx is the value of the input integer (i).</remarks> ''' <history> ''' [rbanks] 23/01/2004 Created ''' </history> '''----------------------------------------------------------------------------- Public Overrides Function getParamHolder(ByVal i As Integer) As String Return ":p" & CStr(i) End Function Public Overrides Function limitClauseAtStart() As Boolean Return True End Function Public Overrides Function getClauseStringLimit() As String Return "TOP" End Function Public Overrides Function getClauseStringTableAlias(ByVal table As String, ByVal owner As String, ByVal pAlias As String) As String Return owner & "." & table & " as " & pAlias End Function Public Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If Not m_disposed Then If disposing Then Dim conn As COracleConnection While ConnectionPool.Count > 0 conn = ConnectionPool.Pop conn.Dispose() End While m_disposed = True End If End If End Sub End Class Index: AssemblyInfo.vb =================================================================== RCS file: /cvsroot/jcframework/dotnet/AssemblyInfo.vb,v retrieving revision 1.13 retrieving revision 1.14 diff -u -d -r1.13 -r1.14 --- AssemblyInfo.vb 19 Oct 2004 03:32:08 -0000 1.13 +++ AssemblyInfo.vb 23 Dec 2004 01:14:44 -0000 1.14 @@ -25,7 +25,7 @@ ' by using the '*' as shown below -<Assembly: AssemblyVersion("2.0.0.0")> +<Assembly: AssemblyVersion("2.1.0.0")> ''' ----------------------------------------------------------------------------- ''' Project : AToMSFramework |
From: Richard B. <rb...@us...> - 2004-12-22 04:15:52
|
Update of /cvsroot/jcframework/dotnet In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7487 Modified Files: CPersistenceBroker.vb Log Message: fix in retrieveassociation when getting collections in one-to-many associations. Wasn't generating a new object for each iteration through the cursor. Index: CPersistenceBroker.vb =================================================================== RCS file: /cvsroot/jcframework/dotnet/CPersistenceBroker.vb,v retrieving revision 1.86 retrieving revision 1.87 diff -u -d -r1.86 -r1.87 --- CPersistenceBroker.vb 21 Dec 2004 21:57:11 -0000 1.86 +++ CPersistenceBroker.vb 22 Dec 2004 04:15:39 -0000 1.87 @@ -769,8 +769,9 @@ 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 + Value = udaMap.ForClass.CreateObjectInstance anObjPers = Value If udaMap.LazyLoad Then cursor.loadProxy(anObjPers.GetSourceObject) @@ -2567,6 +2568,21 @@ Return getObjectsToSave(obj, True, False) End Function + ''' ----------------------------------------------------------------------------- + ''' <summary> + ''' Function to get all objects to save. Includes checks of associated objects. + ''' </summary> + ''' <param name="obj">The object to checl</param> + ''' <param name="checkAssociationsRecursivly">Boolean indicating whether associations + ''' should be checked.</param> + ''' <returns>Queue. The all the objects that need to be saved.</returns> + ''' <remarks>The function traverses all associated objects and checks whether they need saving. + ''' It will also traverse all superclass associations if required. + ''' </remarks> + ''' <history> + ''' [rbanks] 22/12/2004 Created + ''' </history> + ''' ----------------------------------------------------------------------------- Function getObjectsToSave(ByVal obj As CPersistentObject, ByVal checkAssociationsRecursivly As Boolean) As Queue Return getObjectsToSave(obj, True, checkAssociationsRecursivly) End Function |
From: Richard B. <rb...@us...> - 2004-12-21 22:00:12
|
Update of /cvsroot/jcframework/Nunit/InheritedClasses In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29305/InheritedClasses Modified Files: AtomsFrameworkTests.vb AutoIdTests.vb ManyToManyTests.vb MultiRetrieveTests.vb RetrieveCriteriaTests.vb SharedTests.vb SuperClassTests.vb tblAtoKClasses.vb Log Message: New tests for collection events and validation for interface based persistence Index: tblAtoKClasses.vb =================================================================== RCS file: /cvsroot/jcframework/Nunit/InheritedClasses/tblAtoKClasses.vb,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- tblAtoKClasses.vb 21 Dec 2004 08:52:46 -0000 1.3 +++ tblAtoKClasses.vb 21 Dec 2004 22:00:01 -0000 1.4 @@ -43,10 +43,12 @@ Public Property C() As C Get - 'If _c Is Nothing Then - '_c = New C - '_c.OIDValue = _cOID - '_c.Retrieve() + 'Retrieving manually when we have an association set to autoretrieve can produce + 'unpredictable results. + 'If _c Is Nothing AndAlso _cOID <> String.Empty Then + ' _c = New C + ' _c.OIDValue = _cOID + ' _c.Retrieve() 'End If Return _c End Get Index: SharedTests.vb =================================================================== RCS file: /cvsroot/jcframework/Nunit/InheritedClasses/SharedTests.vb,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- SharedTests.vb 1 Nov 2004 21:27:10 -0000 1.4 +++ SharedTests.vb 21 Dec 2004 22:00:01 -0000 1.5 @@ -9,7 +9,7 @@ Dim sp As SharedParent <TestFixtureSetUp()> Public Sub Init() - Environment.CurrentDirectory = "C:\Projects\MMM\Nunit_AtomsFramework" + Environment.CurrentDirectory = System.AppDomain.CurrentDomain.BaseDirectory Dim retry As Boolean = True While retry = True Try Index: ManyToManyTests.vb =================================================================== RCS file: /cvsroot/jcframework/Nunit/InheritedClasses/ManyToManyTests.vb,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- ManyToManyTests.vb 25 Oct 2004 07:14:15 -0000 1.1 +++ ManyToManyTests.vb 21 Dec 2004 22:00:01 -0000 1.2 @@ -12,7 +12,7 @@ Private c As CCursor <TestFixtureSetUp()> Public Sub Init() - Environment.CurrentDirectory = "C:\Projects\MMM\Nunit_AtomsFramework" + Environment.CurrentDirectory = System.AppDomain.CurrentDomain.BaseDirectory Dim retry As Boolean = True While retry = True Try Index: AutoIdTests.vb =================================================================== RCS file: /cvsroot/jcframework/Nunit/InheritedClasses/AutoIdTests.vb,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- AutoIdTests.vb 17 Dec 2004 03:27:49 -0000 1.1 +++ AutoIdTests.vb 21 Dec 2004 22:00:01 -0000 1.2 @@ -11,7 +11,7 @@ Private c As CCursor <TestFixtureSetUp()> Public Sub Init() - Environment.CurrentDirectory = "C:\Projects\MMM\Nunit_AtomsFramework" + Environment.CurrentDirectory = System.AppDomain.CurrentDomain.BaseDirectory Dim retry As Boolean = True While retry = True Try Index: RetrieveCriteriaTests.vb =================================================================== RCS file: /cvsroot/jcframework/Nunit/InheritedClasses/RetrieveCriteriaTests.vb,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- RetrieveCriteriaTests.vb 28 Oct 2004 00:17:28 -0000 1.3 +++ RetrieveCriteriaTests.vb 21 Dec 2004 22:00:01 -0000 1.4 @@ -11,7 +11,7 @@ Private c As CCursor <TestFixtureSetUp()> Public Sub Init() - Environment.CurrentDirectory = "C:\Projects\MMM\Nunit_AtomsFramework" + Environment.CurrentDirectory = System.AppDomain.CurrentDomain.BaseDirectory Dim retry As Boolean = True While retry = True Try Index: MultiRetrieveTests.vb =================================================================== RCS file: /cvsroot/jcframework/Nunit/InheritedClasses/MultiRetrieveTests.vb,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- MultiRetrieveTests.vb 19 Dec 2004 22:44:46 -0000 1.2 +++ MultiRetrieveTests.vb 21 Dec 2004 22:00:01 -0000 1.3 @@ -10,7 +10,7 @@ Private c As CCursor <TestFixtureSetUp()> Public Sub Init() - Environment.CurrentDirectory = "C:\Projects\MMM\Nunit_AtomsFramework" + Environment.CurrentDirectory = System.AppDomain.CurrentDomain.BaseDirectory Dim retry As Boolean = True While retry = True Try Index: SuperClassTests.vb =================================================================== RCS file: /cvsroot/jcframework/Nunit/InheritedClasses/SuperClassTests.vb,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- SuperClassTests.vb 21 Dec 2004 08:52:46 -0000 1.3 +++ SuperClassTests.vb 21 Dec 2004 22:00:01 -0000 1.4 @@ -8,7 +8,7 @@ Private pbroker As CPersistenceBroker <TestFixtureSetUp()> Public Sub Init() - Environment.CurrentDirectory = "C:\My Programs\JCFramework\Nunit" + Environment.CurrentDirectory = System.AppDomain.CurrentDomain.BaseDirectory Dim retry As Boolean = True While retry = True Try Index: AtomsFrameworkTests.vb =================================================================== RCS file: /cvsroot/jcframework/Nunit/InheritedClasses/AtomsFrameworkTests.vb,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- AtomsFrameworkTests.vb 6 Dec 2004 01:01:11 -0000 1.7 +++ AtomsFrameworkTests.vb 21 Dec 2004 22:00:01 -0000 1.8 @@ -8,9 +8,11 @@ Private emp As CEmployee Private job As CJob Private team As CTeam + Dim WithEvents coll As CPersistentCollection + Private eventcount As Integer <TestFixtureSetUp()> Public Sub Init() - Environment.CurrentDirectory = "C:\Projects\MMM\Nunit_AtomsFramework" + Environment.CurrentDirectory = System.AppDomain.CurrentDomain.BaseDirectory Dim retry As Boolean = True While retry = True Try @@ -339,5 +341,39 @@ Assert.AreEqual(2, a.TableCCollection.Count) End Sub + <Test()> Public Sub CheckCollectionEvents() + coll = New CPersistentCollection + eventcount = 0 + emp = New CEmployee + emp.Name = "somename" + coll.Add(emp) + emp = New CEmployee + emp.Name = "someOtherName" + coll.Add(emp) + coll.Remove(0) + Assert.AreEqual(1, coll.Count) + Assert.AreEqual("someOtherName", CType(coll.Item(0), CEmployee).Name) + Assert.AreEqual(3, eventcount) + End Sub + + Private Sub coll_ObjectAdded(ByVal index As Integer, ByRef value As Object) Handles coll.ObjectAdded + eventcount += 1 + If eventcount = 1 Then + Assert.AreEqual(0, index) + Assert.AreEqual("somename", CType(value, CEmployee).Name) + End If + If eventcount = 2 Then + Assert.AreEqual(1, index) + Assert.AreEqual("someOtherName", CType(value, CEmployee).Name) + End If + End Sub + + Private Sub coll_ObjectRemoved(ByVal index As Integer, ByRef value As Object) Handles coll.ObjectRemoved + eventcount += 1 + If eventcount = 3 Then + Assert.AreEqual(0, index) + Assert.AreEqual("somename", CType(value, CEmployee).Name) + End If + End Sub End Class End Namespace \ No newline at end of file |
From: Richard B. <rb...@us...> - 2004-12-21 22:00:11
|
Update of /cvsroot/jcframework/Nunit/StandardClasses In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29305/StandardClasses Modified Files: NonInheritedRetreiveCriteria.vb NonInheritedTests.vb Log Message: New tests for collection events and validation for interface based persistence Index: NonInheritedTests.vb =================================================================== RCS file: /cvsroot/jcframework/Nunit/StandardClasses/NonInheritedTests.vb,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- NonInheritedTests.vb 31 Oct 2004 23:08:36 -0000 1.4 +++ NonInheritedTests.vb 21 Dec 2004 22:00:02 -0000 1.5 @@ -9,7 +9,7 @@ Private emp As NPEmployee <TestFixtureSetUp()> Public Sub Init() - Environment.CurrentDirectory = "C:\Projects\MMM\Nunit_AtomsFramework" + Environment.CurrentDirectory = System.AppDomain.CurrentDomain.BaseDirectory Dim retry As Boolean = True While retry = True Try Index: NonInheritedRetreiveCriteria.vb =================================================================== RCS file: /cvsroot/jcframework/Nunit/StandardClasses/NonInheritedRetreiveCriteria.vb,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- NonInheritedRetreiveCriteria.vb 19 Oct 2004 00:13:38 -0000 1.1 +++ NonInheritedRetreiveCriteria.vb 21 Dec 2004 22:00:02 -0000 1.2 @@ -12,7 +12,7 @@ Private injObj As CInjectedObject <TestFixtureSetUp()> Public Sub Init() - Environment.CurrentDirectory = "C:\Projects\MMM\Nunit_AtomsFramework" + Environment.CurrentDirectory = System.AppDomain.CurrentDomain.BaseDirectory Dim retry As Boolean = True While retry = True Try |
From: Richard B. <rb...@us...> - 2004-12-21 22:00:11
|
Update of /cvsroot/jcframework/Nunit/Interfaces In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29305/Interfaces Modified Files: EmployeeInterfaceTests.vb Log Message: New tests for collection events and validation for interface based persistence Index: EmployeeInterfaceTests.vb =================================================================== RCS file: /cvsroot/jcframework/Nunit/Interfaces/EmployeeInterfaceTests.vb,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- EmployeeInterfaceTests.vb 25 Oct 2004 07:14:15 -0000 1.2 +++ EmployeeInterfaceTests.vb 21 Dec 2004 22:00:01 -0000 1.3 @@ -8,7 +8,7 @@ Private emp As IEmployee <TestFixtureSetUp()> Public Sub Init() - Environment.CurrentDirectory = "C:\Projects\MMM\Nunit_AtomsFramework" + Environment.CurrentDirectory = System.AppDomain.CurrentDomain.BaseDirectory Dim retry As Boolean = True While retry = True Try @@ -65,5 +65,31 @@ Assert.IsTrue(pbroker.getInjectedObject(emp).getFieldTypeByName("Name") Is GetType([String])) End Sub + <Test()> Public Sub SaveInvalidEmployee() + Dim emp2 As ValidatedEmployee + emp2 = New ValidatedEmployee + emp2.AllowValidation = False + emp = emp2 + emp.Name = "invalid" + pbroker.FindObject(emp) + Assert.IsFalse(pbroker.getInjectedObject(emp).Persistent) + pbroker.PersistChanges(emp) + Assert.IsFalse(pbroker.getInjectedObject(emp).Persistent) + Assert.IsTrue(emp.ReportsTo Is Nothing) + End Sub + + <Test()> Public Sub SaveValidEmployee() + Dim emp2 As ValidatedEmployee + emp2 = New ValidatedEmployee + emp2.AllowValidation = True + emp = emp2 + emp.Name = "valid" + pbroker.FindObject(emp) + Assert.IsFalse(pbroker.getInjectedObject(emp).Persistent) + pbroker.PersistChanges(emp) + Assert.IsTrue(pbroker.getInjectedObject(emp).Persistent) + Assert.IsTrue(emp.ReportsTo Is Nothing) + End Sub + End Class End Namespace \ No newline at end of file |
From: Richard B. <rb...@us...> - 2004-12-21 21:57:21
|
Update of /cvsroot/jcframework/dotnet In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28770 Modified Files: CPersistenceBroker.vb CPersistentCollection.vb Log Message: Added new events to CPersistentCollection when an object is inserted or removed Index: CPersistenceBroker.vb =================================================================== RCS file: /cvsroot/jcframework/dotnet/CPersistenceBroker.vb,v retrieving revision 1.85 retrieving revision 1.86 diff -u -d -r1.85 -r1.86 --- CPersistenceBroker.vb 21 Dec 2004 08:52:46 -0000 1.85 +++ CPersistenceBroker.vb 21 Dec 2004 21:57:11 -0000 1.86 @@ -751,12 +751,12 @@ End Try End If If found Then - Value.IsDirty = False 'After populating a new object - Value.OriginalCacheKey = New CCacheKey(Value) - obj.SetAttributeValue(udaMap.Target, Value.GetSourceObject) - End If + Value.IsDirty = False 'After populating a new object + Value.OriginalCacheKey = New CCacheKey(Value) + obj.SetAttributeValue(udaMap.Target, Value.GetSourceObject) End If 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)) @@ -2922,7 +2922,7 @@ PCAverageTimeBase.RawValue = 0 Catch ex As Exception Trace.WriteLine("Could not create performance counters. If using ASP.NET please see http://objectsharp.com/Blogs/bruce/archive/2003/12/05/222.aspx" & _ - vbCrLf & ex.Message) + vbCrLf & ex.Message) End Try End Sub End Class \ No newline at end of file Index: CPersistentCollection.vb =================================================================== RCS file: /cvsroot/jcframework/dotnet/CPersistentCollection.vb,v retrieving revision 1.14 retrieving revision 1.15 diff -u -d -r1.14 -r1.15 --- CPersistentCollection.vb 27 Oct 2004 07:38:48 -0000 1.14 +++ CPersistentCollection.vb 21 Dec 2004 21:57:12 -0000 1.15 @@ -25,6 +25,9 @@ Private m_container As CPersistentObject Public Event ItemDirtied As EventHandler + Public Event ObjectRemoved(ByVal index As Integer, ByRef value As Object) + Public Event ObjectAdded(ByVal index As Integer, ByRef value As Object) + #Region "Collection Properties and Methods" '''----------------------------------------------------------------------------- @@ -287,6 +290,7 @@ AddHandler CType(value, CPersistentObject).RemoveMe, AddressOf Remove AddHandler CType(value, CPersistentObject).MarkedAsDirty, AddressOf ItemDirtiedHandler RaiseEvent ListChanged(Me, New ListChangedEventArgs(ListChangedType.ItemAdded, index)) + RaiseEvent ObjectAdded(index, value) If Not (m_container Is Nothing) Then m_container.SetDirtyFlag() End If @@ -302,6 +306,7 @@ ' RemoveHandler CType(value, CPersistentObject).MarkedAsDirty, AddressOf ItemDirtiedHandler ' RemoveHandler CType(value, CPersistentObject).RemoveMe, AddressOf Remove RaiseEvent ListChanged(Me, New ListChangedEventArgs(ListChangedType.ItemDeleted, index)) + RaiseEvent ObjectRemoved(index, value) If Not (m_container Is Nothing) Then m_container.SetDirtyFlag() End If |
From: Dan M. <dan...@us...> - 2004-12-21 08:52:57
|
Update of /cvsroot/jcframework/dotnet In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4418/dotnet Modified Files: CPersistenceBroker.vb Log Message: Add a test case to check that for an inherited child class that has an association defined in the XML mapping file, and does not have an instance of the association in the database, the framework does not create the object in the association. Index: CPersistenceBroker.vb =================================================================== RCS file: /cvsroot/jcframework/dotnet/CPersistenceBroker.vb,v retrieving revision 1.84 retrieving revision 1.85 diff -u -d -r1.84 -r1.85 --- CPersistenceBroker.vb 19 Dec 2004 23:04:56 -0000 1.84 +++ CPersistenceBroker.vb 21 Dec 2004 08:52:46 -0000 1.85 @@ -698,6 +698,7 @@ Dim ValueVar As String Dim tmpOIDValue As String Dim gotValue As Boolean + Dim found As Boolean Dim col As IList Dim myKeys(cm.AssociationMaps.Count) As String cm.AssociationMaps.Keys.CopyTo(myKeys, 0) @@ -740,17 +741,20 @@ Next j anObjPers = m_cache.Item(Value) If anObjPers Is Nothing Then - retrieveObject(Value, False, False) + found = retrieveObject(Value, False, False) Else Value = anObjPers + found = True Try PCCacheHits.Increment() Catch End Try End If - Value.IsDirty = False 'After populating a new object - Value.OriginalCacheKey = New CCacheKey(Value) - obj.SetAttributeValue(udaMap.Target, Value.GetSourceObject) + If found Then + Value.IsDirty = False 'After populating a new object + Value.OriginalCacheKey = New CCacheKey(Value) + obj.SetAttributeValue(udaMap.Target, Value.GetSourceObject) + End If End If End If ElseIf udaMap.Cardinality = CUDAMap.CardinalityEnum.ONE_TO_MANY Then @@ -2335,7 +2339,7 @@ 'retrieveAssociations(obj, conn, classMap, True) 'obj.IsLoading = False If obj.Persistent Then - obj.AssociationsLoaded = True + 'obj.AssociationsLoaded = True obj.IsDirty = False obj.OriginalCacheKey = New CCacheKey(obj) End If @@ -2425,7 +2429,7 @@ Return queue End If If includeBaseObject Then - obj.IsDirty = False 'Added to queue so clear dirty flag + 'obj.IsDirty = False 'Added to queue so clear dirty flag queue.Enqueue(obj) End If Else @@ -2436,11 +2440,11 @@ If GetType(IValidation).IsInstanceOfType(obj.GetSourceObject) Then 'If obj.GetObjectType.IsSubclassOf(GetType(CPersistentObject)) Then If CType(obj.GetSourceObject, IValidation).IsValid Then 'Do not save if object is not valid - obj.IsDirty = False 'Added to queue so clear dirty flag + 'obj.IsDirty = False 'Added to queue so clear dirty flag queue.Enqueue(obj) End If Else - obj.IsDirty = False + 'obj.IsDirty = False queue.Enqueue(obj) End If End If |
From: Dan M. <dan...@us...> - 2004-12-21 08:52:56
|
Update of /cvsroot/jcframework/Nunit In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4418/Nunit Modified Files: AtomsFramework.xml original db1.mdb Log Message: Add a test case to check that for an inherited child class that has an association defined in the XML mapping file, and does not have an instance of the association in the database, the framework does not create the object in the association. Index: original db1.mdb =================================================================== RCS file: /cvsroot/jcframework/Nunit/original db1.mdb,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 Binary files /tmp/cvs5A0nHQ and /tmp/cvshmfu1q differ Index: AtomsFramework.xml =================================================================== RCS file: /cvsroot/jcframework/Nunit/AtomsFramework.xml,v retrieving revision 1.13 retrieving revision 1.14 diff -u -d -r1.13 -r1.14 --- AtomsFramework.xml 19 Dec 2004 22:44:46 -0000 1.13 +++ AtomsFramework.xml 21 Dec 2004 08:52:44 -0000 1.14 @@ -186,6 +186,8 @@ <attribute name="ModifiedDate" column="ModifiedDate" timestamp="true"/> <attribute name="Id" column="id" find="true" /> <attribute name="I" column="i"/> + <attribute name="M" /> + <attribute name="MOID" column="mOID" /> </class> <class name="H" table="tblH" database="MSA" superclass="C" namespace="NunitTests.InheritedClasses"> <attribute name="OIDValue" column="oid" key="primary" reference="OIDValue"/> @@ -214,6 +216,14 @@ <attribute name="ModifiedDate" column="ModifiedDate" timestamp="true"/> <attribute name="Id" column="id" find="true" /> <attribute name="I" column="i"/> + <attribute name="M"/> + <attribute name="MOID" column="mOID"/> + </class> + <class name="M" table="tblK" database="MSA" namespace="NunitTests.InheritedClasses"> + <attribute name="OIDValue" column="oid" key="primary" reference="OIDValue"/> + <attribute name="CreatedDate" column="CreatedDate" timestamp="true"/> + <attribute name="ModifiedDate" column="ModifiedDate" timestamp="true"/> + <attribute name="I" column="i"/> </class> <association fromClass="NunitTests.InheritedClasses.A" toClass="NunitTests.InheritedClasses.B" @@ -235,6 +245,26 @@ inverse="false"> <entry fromAttribute="AOID" toAttribute="OIDValue"/> </association> + <association fromClass="NunitTests.InheritedClasses.G" + toClass="NunitTests.InheritedClasses.M" + cardinality="oneToOne" + target="M" + retrieveAutomatic="true" + saveAutomatic="true" + deleteAutomatic="true" + inverse="false"> + <entry fromAttribute="MOID" toAttribute="OIDValue"/> + </association> + <association fromClass="NunitTests.InheritedClasses.K" + toClass="NunitTests.InheritedClasses.M" + cardinality="oneToOne" + target="M" + retrieveAutomatic="true" + saveAutomatic="true" + deleteAutomatic="true" + inverse="false"> + <entry fromAttribute="MOID" toAttribute="OIDValue"/> + </association> <association fromClass="NunitTests.InheritedClasses.A" toClass="NunitTests.InheritedClasses.C" cardinality="oneToOne" @@ -246,7 +276,6 @@ <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" /> |
From: Dan M. <dan...@us...> - 2004-12-21 08:52:56
|
Update of /cvsroot/jcframework/Nunit/InheritedClasses In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4418/Nunit/InheritedClasses Modified Files: SuperClassTests.vb tblAtoKClasses.vb Log Message: Add a test case to check that for an inherited child class that has an association defined in the XML mapping file, and does not have an instance of the association in the database, the framework does not create the object in the association. Index: tblAtoKClasses.vb =================================================================== RCS file: /cvsroot/jcframework/Nunit/InheritedClasses/tblAtoKClasses.vb,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- tblAtoKClasses.vb 21 Dec 2004 00:10:31 -0000 1.2 +++ tblAtoKClasses.vb 21 Dec 2004 08:52:46 -0000 1.3 @@ -43,25 +43,29 @@ Public Property C() As C Get - 'Retrieving manually when we have an association set to autoretrieve can produce - 'unpredictable results. - 'If _c Is Nothing AndAlso _cOID <> String.Empty Then - ' _c = New C - ' _c.OIDValue = _cOID - ' _c.Retrieve() + 'If _c Is Nothing Then + '_c = New C + '_c.OIDValue = _cOID + '_c.Retrieve() 'End If Return _c End Get Set(ByVal Value As C) - If Not CPersistentObject.Equals(_c, Value) Then - _c = Value + If Me._c Is Nothing AndAlso Not (Value Is Nothing) Then + Me._c = Value + Me._cOID = Value.OIDValue + Else If Value Is Nothing Then - _cOID = "" + Me._c = Nothing + Me._cOID = Nothing Else - _cOID = Value.OIDValue + If Not Me._c.Equals(Value) Then + Me._c = Value + Me._cOID = Value.OIDValue + End If End If - SetDirtyFlag() End If + Me.SetDirtyFlag() End Set End Property @@ -263,6 +267,8 @@ Public Sub New() End Sub Private _str As String = String.Empty + Private _m As M = Nothing + Private _mOID As String Public Property Str() As String Get @@ -276,6 +282,48 @@ End Set End Property + Public Property M1() + Get + Return Me._m + End Get + Set(ByVal Value) + If Me._m Is Nothing AndAlso Not (Value Is Nothing) Then + Me._m = Value + Me._mOID = Value.OIDValue + Else + If Value Is Nothing Then + Me._m = Nothing + Me._mOID = Nothing + Else + If Not Me._m.Equals(Value) Then + Me._m = Value + Me._mOID = Value.OIDValue + End If + End If + End If + Me.SetDirtyFlag() + End Set + End Property + + Public Property M1OID() + Get + If Not Me._m Is Nothing Then + Return Me._m.OIDValue + Else + Return Me._mOID + End If + End Get + Set(ByVal Value) + If Not Me._m Is Nothing Then + If Not Me._m.OIDValue.Equals(Value) Then + Me._m.OIDValue = Value + Me.SetDirtyFlag() + End If + End If + Me._mOID = Value + End Set + End Property + Public Overloads Overrides Function getNewObject() As CPersistentObject Return New E End Function @@ -319,6 +367,8 @@ Public Sub New() End Sub Private _i As Integer = 0 + Private _m As M = Nothing + Private _mOID As String = Nothing Public Property I() As Integer Get @@ -332,6 +382,48 @@ End Set End Property + Public Property M() + Get + Return Me._m + End Get + Set(ByVal Value) + If Me._m Is Nothing AndAlso Not (Value Is Nothing) Then + Me._m = Value + Me._mOID = Value.OIDValue + Else + If Value Is Nothing Then + Me._m = Nothing + Me._mOID = Nothing + Else + If Not Me._m.Equals(Value) Then + Me._m = Value + Me._mOID = Value.OIDValue + End If + End If + End If + Me.SetDirtyFlag() + End Set + End Property + + Public Property MOID() + Get + If Not Me._m Is Nothing Then + Return Me._m.OIDValue + Else + Return Me._mOID + End If + End Get + Set(ByVal Value) + If Not Me._m Is Nothing Then + If Not Me._m.OIDValue.Equals(Value) Then + Me._m.OIDValue = Value + Me.SetDirtyFlag() + End If + End If + Me._mOID = Value + End Set + End Property + Public Overloads Overrides Function getNewObject() As CPersistentObject Return New G End Function @@ -347,6 +439,8 @@ Public Sub New() End Sub Private _str As String = String.Empty + Private _m As M = Nothing + Private _mOID As String Public Property Str() As String Get @@ -360,6 +454,48 @@ End Set End Property + Public Property M1() + Get + Return Me._m + End Get + Set(ByVal Value) + If Me._m Is Nothing AndAlso Not (Value Is Nothing) Then + Me._m = Value + Me._mOID = Value.OIDValue + Else + If Value Is Nothing Then + Me._m = Nothing + Me._mOID = Nothing + Else + If Not Me._m.Equals(Value) Then + Me._m = Value + Me._mOID = Value.OIDValue + End If + End If + End If + Me.SetDirtyFlag() + End Set + End Property + + Public Property M1OID() + Get + If Not Me._m Is Nothing Then + Return Me._m.OIDValue + Else + Return Me._mOID + End If + End Get + Set(ByVal Value) + If Not Me._m Is Nothing Then + If Not Me._m.OIDValue.Equals(Value) Then + Me._m.OIDValue = Value + Me.SetDirtyFlag() + End If + End If + Me._mOID = Value + End Set + End Property + Public Overloads Overrides Function getNewObject() As CPersistentObject Return New H End Function @@ -431,6 +567,8 @@ Public Sub New() End Sub Private _i As Integer = 0 + Private _m As M = Nothing + Private _mOID As String Public Property I() As Integer Get @@ -444,6 +582,48 @@ End Set End Property + Public Property M() + Get + Return Me._m + End Get + Set(ByVal Value) + If Me._m Is Nothing AndAlso Not (Value Is Nothing) Then + Me._m = Value + Me._mOID = Value.OIDValue + Else + If Value Is Nothing Then + Me._m = Nothing + Me._mOID = Nothing + Else + If Not Me._m.Equals(Value) Then + Me._m = Value + Me._mOID = Value.OIDValue + End If + End If + End If + Me.SetDirtyFlag() + End Set + End Property + + Public Property MOID() + Get + If Not Me._m Is Nothing Then + Return Me._m.OIDValue + Else + Return Me._mOID + End If + End Get + Set(ByVal Value) + If Not Me._m Is Nothing Then + If Not Me._m.OIDValue.Equals(Value) Then + Me._m.OIDValue = Value + Me.SetDirtyFlag() + End If + End If + Me._mOID = Value + End Set + End Property + Public Overloads Overrides Function getNewObject() As CPersistentObject Return New K End Function @@ -452,4 +632,33 @@ Return True End Function End Class + + Public Class M + Inherits CPersistentObject + + Public Sub New() + End Sub + Private _i As Integer = 0 + + Public Property I() As Integer + Get + Return Me._i + End Get + Set(ByVal Value As Integer) + If Not (Me._i = Value) Then + Me._i = Value + Me.SetDirtyFlag() + End If + End Set + End Property + + Public Overloads Overrides Function getNewObject() As CPersistentObject + Return New M + End Function + + Public Overloads Overrides Function IsValid() As Boolean + Return True + End Function + End Class + End Namespace \ No newline at end of file Index: SuperClassTests.vb =================================================================== RCS file: /cvsroot/jcframework/Nunit/InheritedClasses/SuperClassTests.vb,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- SuperClassTests.vb 21 Dec 2004 00:10:31 -0000 1.2 +++ SuperClassTests.vb 21 Dec 2004 08:52:46 -0000 1.3 @@ -8,7 +8,7 @@ Private pbroker As CPersistenceBroker <TestFixtureSetUp()> Public Sub Init() - Environment.CurrentDirectory = "C:\Projects\MMM\Nunit_AtomsFramework" + Environment.CurrentDirectory = "C:\My Programs\JCFramework\Nunit" Dim retry As Boolean = True While retry = True Try @@ -35,6 +35,18 @@ <SetUp()> Public Sub TestInit() End Sub + <TearDown()> Public Sub TestEnd() + pbroker.ClearCache() + Dim col As CPersistentCollection + Dim cpo As CPersistentObject = New A + col = cpo.getAll(True) + + For Each a As A In col + a.Delete(True) + Next + pbroker.ClearCache() + End Sub + <Test()> Public Sub CheckMultiInheritance1() Dim root As New A root.Id = 1 @@ -76,6 +88,47 @@ Next End Sub + <Test()> Public Sub CheckMultiInheritance2() + Dim root As New A + root.Id = 1 + root.Text = "Root object" + root.BCol = New CPersistentCollection + ' create G and add it to the collection + Dim g As New G + g.Id = 5 + g.Text = "Child class of E" + g.Str = "Added to collection" + g.I = 555 + g.A = root + root.BCol.Add(g) + + ' create oneToOne object (K) and add it to root + Dim k As New K + k.Id = 6 + k.Text = "Child of class H" + k.Str = "Added to oneToOne association" + k.I = 666 + root.C = k + + 'save root (class A) + root.Save(True) + 'Now check that A, G and K are in the database + 'Console.WriteLine("\nIf you'll check the data in the tables,\nyou'll find that tblA is populated and tables tblG and tbl K are populated.\nBut tables tblE, tblC, tblH are not populated at all.\n"); + pbroker.ClearCache() + Dim col As CPersistentCollection + Dim cpo As CPersistentObject = New A + col = cpo.getAll(True) + + Assert.IsTrue(col.Count > 0) + For Each a As A In col + Assert.IsNull(CType(CType(a.C, K).M, M), "Object is not NULL") + For Each b As B In a.BCol + Assert.IsTrue(b.GetType Is GetType(G)) + Assert.IsNull(CType(CType(b, G).M1, M), "Object is not NULL") + Next + Next + End Sub + <Test()> Public Sub RetrievalViaParentAttributes() Dim j As New J j.I = 1 @@ -98,7 +151,7 @@ cursor.loadObject(j) Assert.AreEqual("Class C Text", j.Text) Assert.AreEqual("Class H Str", j.Str) - assert.AreEqual(123,j.Id) + Assert.AreEqual(123, j.Id) End Sub <Test()> Public Sub RetrievalViaParentAttributes2() |
From: Richard B. <rb...@us...> - 2004-12-21 00:10:41
|
Update of /cvsroot/jcframework/Nunit/InheritedClasses In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3312/InheritedClasses Modified Files: SuperClassTests.vb tblAtoKClasses.vb Log Message: Fixed broken unit test for MultiInheritance Index: tblAtoKClasses.vb =================================================================== RCS file: /cvsroot/jcframework/Nunit/InheritedClasses/tblAtoKClasses.vb,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- tblAtoKClasses.vb 20 Oct 2004 06:43:41 -0000 1.1 +++ tblAtoKClasses.vb 21 Dec 2004 00:10:31 -0000 1.2 @@ -43,11 +43,13 @@ Public Property C() As C Get - If _c Is Nothing Then - _c = New C - _c.OIDValue = _cOID - _c.Retrieve() - End If + 'Retrieving manually when we have an association set to autoretrieve can produce + 'unpredictable results. + 'If _c Is Nothing AndAlso _cOID <> String.Empty Then + ' _c = New C + ' _c.OIDValue = _cOID + ' _c.Retrieve() + 'End If Return _c End Get Set(ByVal Value As C) Index: SuperClassTests.vb =================================================================== RCS file: /cvsroot/jcframework/Nunit/InheritedClasses/SuperClassTests.vb,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- SuperClassTests.vb 20 Oct 2004 06:43:41 -0000 1.1 +++ SuperClassTests.vb 21 Dec 2004 00:10:31 -0000 1.2 @@ -62,6 +62,7 @@ 'Now check that A, G and K are in the database 'Console.WriteLine("\nIf you'll check the data in the tables,\nyou'll find that tblA is populated and tables tblG and tbl K are populated.\nBut tables tblE, tblC, tblH are not populated at all.\n"); + pbroker.ClearCache() Dim col As CPersistentCollection Dim cpo As CPersistentObject = New A col = cpo.getAll(True) |
From: Richard B. <rb...@us...> - 2004-12-19 23:05:20
|
Update of /cvsroot/jcframework/dotnet In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12577 Modified Files: CPersistenceBroker.vb Log Message: Fix for saving objects with identity columns - now handles interface based persistence as well. Index: CPersistenceBroker.vb =================================================================== RCS file: /cvsroot/jcframework/dotnet/CPersistenceBroker.vb,v retrieving revision 1.83 retrieving revision 1.84 diff -u -d -r1.83 -r1.84 --- CPersistenceBroker.vb 17 Dec 2004 00:28:37 -0000 1.83 +++ CPersistenceBroker.vb 19 Dec 2004 23:04:56 -0000 1.84 @@ -2794,6 +2794,8 @@ Debug.WriteLine("The object with key " & ckey.ToString & " was already saved once") Else saveObject(value) + 'Recalculate key value - required when identity columns are used + ckey = New CCacheKey(value) savedKeys.Add(ckey) End If Catch ex As Exception |
From: Richard B. <rb...@us...> - 2004-12-19 22:44:58
|
Update of /cvsroot/jcframework/Nunit/InheritedClasses In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8203/InheritedClasses Modified Files: MultiRetrieveTestClasses.vb MultiRetrieveTests.vb Log Message: Extra test for autosave and for update parameter checks Index: MultiRetrieveTestClasses.vb =================================================================== RCS file: /cvsroot/jcframework/Nunit/InheritedClasses/MultiRetrieveTestClasses.vb,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- MultiRetrieveTestClasses.vb 25 Oct 2004 07:14:14 -0000 1.2 +++ MultiRetrieveTestClasses.vb 19 Dec 2004 22:44:46 -0000 1.3 @@ -50,6 +50,7 @@ End Get Set(ByVal Value As String) _field1 = Value + SetDirtyFlag() End Set End Property @@ -59,6 +60,7 @@ End Get Set(ByVal Value As Integer) _field2 = Value + SetDirtyFlag() End Set End Property @@ -92,6 +94,7 @@ End Get Set(ByVal Value As String) _field1 = Value + SetDirtyFlag() End Set End Property @@ -102,6 +105,7 @@ End Get Set(ByVal Value As Integer) _field2 = Value + SetDirtyFlag() End Set End Property @@ -162,6 +166,7 @@ End Get Set(ByVal Value As String) _field1 = Value + SetDirtyFlag() End Set End Property @@ -172,6 +177,7 @@ End Get Set(ByVal Value As Integer) _field2 = Value + SetDirtyFlag() End Set End Property Index: MultiRetrieveTests.vb =================================================================== RCS file: /cvsroot/jcframework/Nunit/InheritedClasses/MultiRetrieveTests.vb,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- MultiRetrieveTests.vb 19 Oct 2004 03:30:42 -0000 1.1 +++ MultiRetrieveTests.vb 19 Dec 2004 22:44:46 -0000 1.2 @@ -67,5 +67,24 @@ Assert.AreEqual(3, c.TotalRows) End Sub + <Test()> Public Sub SaveMRClasses() + Dim mr1 As New mr1 + mr1.id = "id1" + mr1.field1 = "_a" + mr1.field2 = 1 + Dim mr2 As New mr2 + mr2.id = "id2" + mr2.field1 = "_aa" + mr2.field2 = 2 + mr1.mr2 = mr2 + Dim mr3 As New mr3 + mr3.id = "id3" + mr3.field1 = "zz" + mr3.field2 = 3 + mr2.mr3 = mr3 + mr1.Save() + mr2.field2 = 22 + mr2.Save() + End Sub End Class End Namespace \ No newline at end of file |
From: Richard B. <rb...@us...> - 2004-12-19 22:44:58
|
Update of /cvsroot/jcframework/Nunit In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8203 Modified Files: AtomsFramework.xml Log Message: Extra test for autosave and for update parameter checks Index: AtomsFramework.xml =================================================================== RCS file: /cvsroot/jcframework/Nunit/AtomsFramework.xml,v retrieving revision 1.12 retrieving revision 1.13 diff -u -d -r1.12 -r1.13 --- AtomsFramework.xml 1 Nov 2004 21:27:08 -0000 1.12 +++ AtomsFramework.xml 19 Dec 2004 22:44:46 -0000 1.13 @@ -99,11 +99,11 @@ <attribute name="field2" column="field2" /> </class> <association fromClass="NunitTests.InheritedClasses.mr1" toClass="NunitTests.InheritedClasses.mr2" target="mr2" cardinality="OneToOne" - retrieveAutomatic="false" saveAutomatic="false" deleteAutomatic="false" inverse="false" name="mr1tomr2"> + retrieveAutomatic="false" saveAutomatic="true" deleteAutomatic="false" inverse="false" name="mr1tomr2"> <entry fromAttribute="mr2_id" toAttribute="id"/> </association> <association fromClass="NunitTests.InheritedClasses.mr2" toClass="NunitTests.InheritedClasses.mr3" target="mr3" cardinality="OneToOne" - retrieveAutomatic="false" saveAutomatic="false" deleteAutomatic="false" inverse="false" name="mr2tomr3"> + retrieveAutomatic="false" saveAutomatic="true" deleteAutomatic="false" inverse="false" name="mr2tomr3"> <entry fromAttribute="mr3_id" toAttribute="id"/> </association> |
From: Richard B. <rb...@us...> - 2004-12-19 22:43:28
|
Update of /cvsroot/jcframework/dotnet In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7711 Modified Files: CClassMap.vb readme.html Log Message: Fix for udpate statements where parameters contain NULL and where ANSI null handling is on. Index: readme.html =================================================================== RCS file: /cvsroot/jcframework/dotnet/readme.html,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- readme.html 15 Dec 2004 23:46:12 -0000 1.4 +++ readme.html 19 Dec 2004 22:43:17 -0000 1.5 @@ -164,6 +164,11 @@ <td class="col1">Incorrect SQL Generation</td> <td>SQL generated for associations to classes with children using shared tables was broken. For now the child objects are not retrieved.<td> </tr> + <tr valign="top"> + <td>1064420</td> + <td class="col1">Missing parameters</td> + <td>Update statements were being generated with missing parameters. This only occurred when parameters for the where clause had NULL values and when ANSI null handling was on.<td> + </tr> <tr class="tableCaption" valign="bottom"> <td colspan=3><br/>Modifications</td> </tr> Index: CClassMap.vb =================================================================== RCS file: /cvsroot/jcframework/dotnet/CClassMap.vb,v retrieving revision 1.47 retrieving revision 1.48 diff -u -d -r1.47 -r1.48 --- CClassMap.vb 17 Dec 2004 03:29:01 -0000 1.47 +++ CClassMap.vb 19 Dec 2004 22:43:17 -0000 1.48 @@ -1281,10 +1281,14 @@ Next m_sqlUpdateStub = m_updateStatement.SqlString End If - m_updateWhereParamPosition = Me.getSize + m_updateWhereParamPosition = Me.getSize + 1 For Each AttrMap In Me.AttributeMaps - If AttrMap.ColumnMap.IsIdentity OrElse (Not Me.SharedTableValue Is Nothing AndAlso Not AttrMap.AttributeMap Is Nothing) Then + If AttrMap.ColumnMap Is Nothing Then m_updateWhereParamPosition -= 1 + Else + If AttrMap.ColumnMap.IsIdentity OrElse (Not Me.SharedTableValue Is Nothing AndAlso Not AttrMap.AttributeMap Is Nothing) Then + m_updateWhereParamPosition -= 1 + End If End If Next |
From: Richard B. <rb...@us...> - 2004-12-17 03:29:12
|
Update of /cvsroot/jcframework/dotnet In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24404 Modified Files: CClassMap.vb CPersistentObject.vb Log Message: Fix for saving objects with identity columns Index: CPersistentObject.vb =================================================================== RCS file: /cvsroot/jcframework/dotnet/CPersistentObject.vb,v retrieving revision 1.51 retrieving revision 1.52 diff -u -d -r1.51 -r1.52 --- CPersistentObject.vb 6 Dec 2004 00:57:05 -0000 1.51 +++ CPersistentObject.vb 17 Dec 2004 03:29:01 -0000 1.52 @@ -907,6 +907,8 @@ Debug.WriteLine("The object with key " & ckey.ToString & " was already saved once") Else persistentBroker.saveObject(value) + 'Need to recalculate the key here to handle objects using identity (autonumber) keys + ckey = New CCacheKey(value) savedKeys.Add(ckey) End If Catch ex As Exception Index: CClassMap.vb =================================================================== RCS file: /cvsroot/jcframework/dotnet/CClassMap.vb,v retrieving revision 1.46 retrieving revision 1.47 diff -u -d -r1.46 -r1.47 --- CClassMap.vb 15 Dec 2004 23:46:05 -0000 1.46 +++ CClassMap.vb 17 Dec 2004 03:29:01 -0000 1.47 @@ -1165,7 +1165,7 @@ isFirst = True For i = 1 To Me.getSize AttrMap = Me.getAttributeMap(i) - If Not AttrMap.ColumnMap.IsIdentity Then + If Not AttrMap.ColumnMap.IsIdentity Or includeIdentity 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. @@ -1193,7 +1193,7 @@ isFirst = True For i = 1 To Me.getSize AttrMap = Me.getAttributeMap(i) - If Not AttrMap.ColumnMap.IsIdentity Then + If Not AttrMap.ColumnMap.IsIdentity Or includeIdentity Then If Me.SharedTableValue Is Nothing OrElse AttrMap.AttributeMap Is Nothing Then If isFirst Then m_insertStatement.addSqlClause(RelationalDatabase.getParamHolder(i)) @@ -1219,7 +1219,7 @@ 'Add parameter values For i = 1 To Me.getSize AttrMap = Me.getAttributeMap(i) - If Not AttrMap.ColumnMap.IsIdentity Then + If Not AttrMap.ColumnMap.IsIdentity Or includeIdentity Then If Me.SharedTableValue Is Nothing OrElse AttrMap.AttributeMap Is Nothing Then m_insertStatement.addSqlParameter(i, obj.GetValueByAttribute(AttrMap.Name), AttrMap.ColumnMap) End If |
From: Richard B. <rb...@us...> - 2004-12-17 03:28:00
|
Update of /cvsroot/jcframework/Nunit In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24066 Modified Files: Nunit_AtomsFramework.vbproj original db1.mdb Log Message: Unit test for identity columns Index: Nunit_AtomsFramework.vbproj =================================================================== RCS file: /cvsroot/jcframework/Nunit/Nunit_AtomsFramework.vbproj,v retrieving revision 1.14 retrieving revision 1.15 diff -u -d -r1.14 -r1.15 --- Nunit_AtomsFramework.vbproj 6 Dec 2004 01:01:12 -0000 1.14 +++ Nunit_AtomsFramework.vbproj 17 Dec 2004 03:27:47 -0000 1.15 @@ -120,6 +120,16 @@ BuildAction = "Compile" /> <File + RelPath = "InheritedClasses\AutoIdClasses.vb" + SubType = "Code" + BuildAction = "Compile" + /> + <File + RelPath = "InheritedClasses\AutoIdTests.vb" + SubType = "Code" + BuildAction = "Compile" + /> + <File RelPath = "InheritedClasses\CEmployee.vb" SubType = "Code" BuildAction = "Compile" Index: original db1.mdb =================================================================== RCS file: /cvsroot/jcframework/Nunit/original db1.mdb,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 Binary files /tmp/cvsj8Jwhd and /tmp/cvsSLQNqM differ |
From: Richard B. <rb...@us...> - 2004-12-17 03:28:00
|
Update of /cvsroot/jcframework/Nunit/InheritedClasses In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24066/InheritedClasses Added Files: AutoIdClasses.vb AutoIdTests.vb Log Message: Unit test for identity columns --- NEW FILE: AutoIdClasses.vb --- Imports AToMSFramework Namespace InheritedClasses <AFTable("AutoIdParent", "MSA", AFTableAttribute.KeyType.usePrimary), _ AFAssociation(GetType(AutoIdChild), "Children", CUDAMap.CardinalityEnum.ONE_TO_MANY, Retrieve:=True, Save:=True), _ AFAssociationEntry("Children", "Id", "ParentId")> _ Public Class AutoIdParent Inherits CPersistentObject Private _Id As Integer <AFColumn("autoId", Identity:=True, iskey:=True)> _ Public Property Id() As Integer Get Return _Id End Get Set(ByVal Value As Integer) _Id = Value SetDirtyFlag() End Set End Property Private _Children As New CPersistentCollection Public Property Children() As CPersistentCollection Get Return _Children End Get Set(ByVal Value As CPersistentCollection) _Children = Value End Set End Property Private _Description As String <AFColumn("description")> _ Public Property Description() As String Get Return _Description End Get Set(ByVal Value As String) _Description = Value SetDirtyFlag() End Set End Property Public Overrides Function getNewObject() As AToMSFramework.CPersistentObject Return New AutoIdParent End Function Public Overrides Function IsValid() As Boolean Return True End Function End Class <AFTable("AutoIdChild", "MSA", AFTableAttribute.KeyType.usePrimary)> _ Public Class AutoIdChild Inherits CPersistentObject Private _Id As Integer <AFColumn("autoId", Identity:=True, iskey:=True)> _ Public Property Id() As Integer Get Return _Id End Get Set(ByVal Value As Integer) _Id = Value SetDirtyFlag() End Set End Property Private _Description As String <AFColumn("description")> _ Public Property Description() As String Get Return _Description End Get Set(ByVal Value As String) _Description = Value SetDirtyFlag() End Set End Property Private _Parent As AutoIdParent Public Property Parent() As AutoIdParent Get Return _Parent End Get Set(ByVal Value As AutoIdParent) _Parent = Value SetDirtyFlag() End Set End Property Private _ParentId As Integer <AFColumn("ParentId")> _ Public Property ParentId() As Integer Get If _Parent Is Nothing Then Return _ParentId Else Return _Parent.Id End If End Get Set(ByVal Value As Integer) _ParentId = Value End Set End Property Public Overrides Function getNewObject() As AToMSFramework.CPersistentObject Return New AutoIdChild End Function Public Overrides Function IsValid() As Boolean Return True End Function End Class End Namespace --- NEW FILE: AutoIdTests.vb --- Imports AToMSFramework Imports NUnit.Framework Namespace InheritedClasses <TestFixture()> Public Class AutoIdTests Private pbroker As CPersistenceBroker Private parent As AutoIdParent Private child As AutoIdChild 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 SaveNewObjectTree() parent = New AutoIdParent parent.Description = "AutoParent" child = New AutoIdChild child.Description = "Child1" child.Parent = parent parent.Children.Add(child) child = New AutoIdChild child.Description = "Child2" child.Parent = parent parent.Children.Add(child) parent.Save() Assert.IsTrue(parent.Id > 0) Assert.IsTrue(CType(parent.Children.Item(0), AutoIdChild).Id > 0) Assert.IsTrue(CType(parent.Children.Item(1), AutoIdChild).Id > 0) End Sub End Class End Namespace |