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-04-01 00:05:27
|
Update of /cvsroot/jcframework/dotnet In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18014 Modified Files: CCacheEntry.vb CClassMap.vb CCriteriaCondition.vb CInjectedObject.vb CInjectedObjects.vb CMultiSummaryCriteria.vb CPersistenceBroker.vb CPersistentCollection.vb CPersistentObject.vb CRetrieveCriteria.vb IPersistentObject.vb Log Message: Fixes for a number of issues with injected objects. Fixes for transactions when errors occur during the rollback, etc Fixes for removing event listeners from objects added to the cache to prevent multiple event firing. Index: CPersistenceBroker.vb =================================================================== RCS file: /cvsroot/jcframework/dotnet/CPersistenceBroker.vb,v retrieving revision 1.102 retrieving revision 1.103 diff -u -d -r1.102 -r1.103 --- CPersistenceBroker.vb 22 Mar 2005 06:09:11 -0000 1.102 +++ CPersistenceBroker.vb 1 Apr 2005 00:04:08 -0000 1.103 @@ -343,11 +343,11 @@ Do If useFind Then If Not skipClass Then - For i = 1 To cm2.getFindSize - am = cm2.FindAttributeMaps(i) + For i = 1 To cm2.getFindSize + am = cm2.FindAttributeMaps(i) paramCount += 1 statement.addSqlParameter(paramCount, obj.GetValueByAttribute(am.Name), am.ColumnMap) - Next i + Next i [...1130 lines suppressed...] + 'Called recursively so that objects with superclasses are queued from the + 'top most object down. + Dim cm As CClassMap + Dim tmpobj As Object + cm = obj.GetClassMap() + If Not cm.SuperClass Is Nothing Then + tmpobj = obj.GetObjectByClassMap(cm.SuperClass) + If cm.SharedTableField Is Nothing Then + AddToQueue(tmpobj, queue, True) + Else + AddToQueue(tmpobj, queue, False) + End If + End If + If includeObject Then + queue.Enqueue(obj) + End If + Return + End Sub End Class \ No newline at end of file Index: IPersistentObject.vb =================================================================== RCS file: /cvsroot/jcframework/dotnet/IPersistentObject.vb,v retrieving revision 1.12 retrieving revision 1.13 diff -u -d -r1.12 -r1.13 --- IPersistentObject.vb 22 Mar 2005 06:09:11 -0000 1.12 +++ IPersistentObject.vb 1 Apr 2005 00:04:20 -0000 1.13 @@ -28,7 +28,7 @@ Function GetObjectType() As Type Function Equals(ByVal obj As IPersistableObject) As Boolean Function Copy() As IPersistableObject - Sub ReplaceWith(ByVal obj As IPersistableObject) + Sub ReplaceWith(ByVal obj As IPersistableObject, ByVal copyEventHandlers As Boolean) Function GetObjectByClassMap(ByVal classMap As CClassMap) As IPersistableObject Function GetSourceObject() As Object Function HasValidKey() As Boolean Index: CRetrieveCriteria.vb =================================================================== RCS file: /cvsroot/jcframework/dotnet/CRetrieveCriteria.vb,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -r1.11 -r1.12 --- CRetrieveCriteria.vb 28 Oct 2004 00:16:12 -0000 1.11 +++ CRetrieveCriteria.vb 1 Apr 2005 00:04:20 -0000 1.12 @@ -92,7 +92,7 @@ m_offset = -1 m_rows = -1 m_Having = Nothing - m_fullObjects = False 'default to proxy objects only + m_fullObjects = False 'default to proxy objects only End Sub Protected Overrides Sub Finalize() @@ -285,25 +285,25 @@ Return persistentBroker.Instance.processRetrieveCriteria(obj, Me, m_fullObjects) End Function - ''' ----------------------------------------------------------------------------- - ''' <summary> - ''' Starts processing of the retrieve criteria - ''' </summary> - ''' <returns>A CCursor containing the results of the criteria</returns> - ''' <remarks> - ''' </remarks> - ''' <exception>A NoClassMapException will be thrown if the class map has not been set</exception> - ''' <history> - ''' [rbanks] 16/08/2004 Created - ''' </history> - ''' ----------------------------------------------------------------------------- - Public Function perform() As CCursor - Static persistentBroker As CPersistenceBroker - persistentBroker = getPersistenceBrokerInstance() - If Me.ClassMap Is Nothing Then - Throw New NoClassMapException("No class map has been set for the retrieve criteria") - End If - Return persistentBroker.Instance.processRetrieveCriteria(Me.ClassMap, Me, m_fullObjects) - End Function + ''' ----------------------------------------------------------------------------- + ''' <summary> + ''' Starts processing of the retrieve criteria + ''' </summary> + ''' <returns>A CCursor containing the results of the criteria</returns> + ''' <remarks> + ''' </remarks> + ''' <exception>A NoClassMapException will be thrown if the class map has not been set</exception> + ''' <history> + ''' [rbanks] 16/08/2004 Created + ''' </history> + ''' ----------------------------------------------------------------------------- + Public Function perform() As CCursor + Static persistentBroker As CPersistenceBroker + persistentBroker = getPersistenceBrokerInstance() + If Me.ClassMap Is Nothing Then + Throw New NoClassMapException("No class map has been set for the retrieve criteria") + End If + Return persistentBroker.Instance.processRetrieveCriteria(Me.ClassMap, Me, m_fullObjects) + End Function End Class \ No newline at end of file Index: CCacheEntry.vb =================================================================== RCS file: /cvsroot/jcframework/dotnet/CCacheEntry.vb,v retrieving revision 1.30 retrieving revision 1.31 diff -u -d -r1.30 -r1.31 --- CCacheEntry.vb 28 Feb 2005 23:07:43 -0000 1.30 +++ CCacheEntry.vb 1 Apr 2005 00:03:51 -0000 1.31 @@ -578,7 +578,7 @@ End If Try ce.OriginalObject = obj - ce.PersistentObject.ReplaceWith(obj) + ce.PersistentObject.ReplaceWith(obj, False) Catch MyBase.Remove(ckey) MyBase.Add(ckey, ce) @@ -830,6 +830,7 @@ Dim x As DictionaryEntry Dim ce As CCacheEntry + Try 'Lets save objects first - just means resetting transaction to None For Each x In Me ce = x.Value @@ -850,6 +851,9 @@ For Each ck In al MyBase.Remove(ck) Next + Catch ex As Exception + Throw New SaveException("Failed to commit cache changes at end of transaction", ex) + End Try End Sub Friend Sub AbortChanges(ByVal reldb As _CRelationalDatabase) @@ -858,6 +862,7 @@ Dim x As DictionaryEntry Dim ce As CCacheEntry + Try For Each x In Me ce = x.Value If ce.PersistentObject.GetClassMap.RelationalDatabase Is reldb Then @@ -890,6 +895,9 @@ For Each ck In al MyBase.Remove(ck) Next + Catch ex As Exception + Throw New SaveException("Failed to rollback cache changed at end of transaction", ex) + End Try End Sub Friend Sub StartTransaction(ByVal reldb As _CRelationalDatabase) @@ -897,12 +905,18 @@ Dim ce As CCacheEntry 'precopy collection objects + Try For Each x In Me ce = x.Value + If Not ce.PersistentObject Is Nothing Then If ce.PersistentObject.GetClassMap.RelationalDatabase Is reldb Then ce.CopyObject() End If + End If Next + Catch ex As Exception + Throw New RetrieveException("Failed to initialise cache at start of transaction", ex) + End Try End Sub Public Property ObjectsAreLoading() As Boolean @@ -977,4 +991,21 @@ Return m_status End Get End Property + + Public Function GetValueArray() As ArrayList + Dim al As ArrayList + Dim valArray(Me.Values.Count) As Object + Me.Values.CopyTo(valArray, 0) + al = New ArrayList(valArray) + Return al + End Function + + Public Function GetKeyArray() As ArrayList + Dim al As ArrayList + Dim valArray(Me.Keys.Count) As Object + Me.Keys.CopyTo(valArray, 0) + al = New ArrayList(valArray) + Return al + End Function + End Class \ No newline at end of file Index: CCriteriaCondition.vb =================================================================== RCS file: /cvsroot/jcframework/dotnet/CCriteriaCondition.vb,v retrieving revision 1.18 retrieving revision 1.19 diff -u -d -r1.18 -r1.19 --- CCriteriaCondition.vb 15 Mar 2005 11:14:50 -0000 1.18 +++ CCriteriaCondition.vb 1 Apr 2005 00:04:06 -0000 1.19 @@ -177,7 +177,7 @@ m_classMap = cm End Sub - ''' ----------------------------------------------------------------------------- + ''' ----------------------------------------------------------------------------- ''' <summary> ''' Adds a subcriteria to this criteria ''' </summary> @@ -291,7 +291,7 @@ udaMap = clMap.AssociationMaps(strName) m_Associations.Add(udaMap) - clMap = udaMap.toclass + clMap = udaMap.ToClass If Not clMap Is Nothing Then For j = 1 To clMap.Tables.Count() m_Tables.Add(clMap.Tables.Item(j)) @@ -319,7 +319,7 @@ End If End Sub - '''----------------------------------------------------------------------------- + '''----------------------------------------------------------------------------- ''' <summary> ''' Creates a Greater Than selection criteria. ''' </summary> Index: CPersistentCollection.vb =================================================================== RCS file: /cvsroot/jcframework/dotnet/CPersistentCollection.vb,v retrieving revision 1.18 retrieving revision 1.19 diff -u -d -r1.18 -r1.19 --- CPersistentCollection.vb 16 Mar 2005 04:59:24 -0000 1.18 +++ CPersistentCollection.vb 1 Apr 2005 00:04:18 -0000 1.19 @@ -44,166 +44,166 @@ ''' [rbanks] 17/12/2003 Created ''' </history> '''----------------------------------------------------------------------------- - <Browsable(False)> _ - Public Property ContainerObject() As CPersistentObject - Get - Return m_container - End Get - Set(ByVal Value As CPersistentObject) - m_container = Value - End Set - End Property + <Browsable(False)> _ + Public Property ContainerObject() As CPersistentObject + Get + Return m_container + End Get + Set(ByVal Value As CPersistentObject) + m_container = Value + End Set + End Property - <Browsable(False)> Public Shadows ReadOnly Property Count() As Integer - Get - Return MyBase.Count - End Get - End Property + <Browsable(False)> Public Shadows ReadOnly Property Count() As Integer + Get + Return MyBase.Count + End Get + End Property - '''----------------------------------------------------------------------------- - ''' <summary> - ''' Adds an item to the collection. - ''' </summary> - ''' <param name="cp">A CPersistentObject to be added.</param> - ''' <remarks>The persistent object is added to the collection. If the container - ''' object reference is set then the dirty flag on the container object is set.</remarks> - ''' <history> - ''' [rbanks] 17/12/2003 Created - ''' </history> - '''----------------------------------------------------------------------------- - Public Sub Add(ByVal cp As CPersistentObject) - ' Debug.WriteLine("Coll: add method called") - list.Add(cp) - End Sub + '''----------------------------------------------------------------------------- + ''' <summary> + ''' Adds an item to the collection. + ''' </summary> + ''' <param name="cp">A CPersistentObject to be added.</param> + ''' <remarks>The persistent object is added to the collection. If the container + ''' object reference is set then the dirty flag on the container object is set.</remarks> + ''' <history> + ''' [rbanks] 17/12/2003 Created + ''' </history> + '''----------------------------------------------------------------------------- + Public Sub Add(ByVal cp As CPersistentObject) + ' Debug.WriteLine("Coll: add method called") + list.Add(cp) + End Sub - '''----------------------------------------------------------------------------- - ''' <summary> - ''' Removes an item from the collection. - ''' </summary> - ''' <param name="index">The zero-based position of the item in the collection to remove.</param> - ''' <remarks>Removes the specified item from the collection and sets the - ''' dirty flag on the container object. - ''' <para>An exception is thrown if the index is greater than the number of items in the collection or is - ''' less than zero.</para></remarks> - ''' <history> - ''' [rbanks] 17/12/2003 Created - ''' </history> - '''----------------------------------------------------------------------------- - Public Sub Remove(ByVal index As Integer) - ' Debug.WriteLine("Coll: Removing index " & index) - If index > Count - 1 Or index < 0 Then - Throw New Exception("PersistentCollection index value is outside of bounds") - End If - list.RemoveAt(index) - End Sub - '''----------------------------------------------------------------------------- - ''' <summary> - ''' Removes an object from the collection. - ''' </summary> - ''' <param name="value">The object to remove.</param> - ''' <remarks>Removes the specified object from the collection and sets the - ''' dirty flag on the container object.</remarks> - ''' <history> - ''' [rbanks] 17/12/2003 Created - ''' </history> - '''----------------------------------------------------------------------------- - Public Sub Remove(ByVal value As CPersistentObject) - ' Debug.WriteLine("Coll: Removing " & value.GetType.Name) - list.Remove(value) - End Sub - '''----------------------------------------------------------------------------- - ''' <summary> - ''' Retrieves the item at the specified position. - ''' </summary> - ''' <param name="index">The zero-based position of the item in the collection.</param> - ''' <value>The CPersistentObject from the specified position.</value> - ''' <remarks>If the index does not refer to a valid position within the collection - ''' and exception will be thrown.</remarks> - ''' <history> - ''' [rbanks] 17/12/2003 Created - ''' </history> - '''----------------------------------------------------------------------------- - Default Public ReadOnly Property Item(ByVal index As Integer) As CPersistentObject - Get - ' Debug.WriteLine("Coll: index property = " & index) - Return CType(list.Item(index), CPersistentObject) - End Get - End Property + '''----------------------------------------------------------------------------- + ''' <summary> + ''' Removes an item from the collection. + ''' </summary> + ''' <param name="index">The zero-based position of the item in the collection to remove.</param> + ''' <remarks>Removes the specified item from the collection and sets the + ''' dirty flag on the container object. + ''' <para>An exception is thrown if the index is greater than the number of items in the collection or is + ''' less than zero.</para></remarks> + ''' <history> + ''' [rbanks] 17/12/2003 Created + ''' </history> + '''----------------------------------------------------------------------------- + Public Sub Remove(ByVal index As Integer) + ' Debug.WriteLine("Coll: Removing index " & index) + If index > Count - 1 Or index < 0 Then + Throw New Exception("PersistentCollection index value is outside of bounds") + End If + list.RemoveAt(index) + End Sub + '''----------------------------------------------------------------------------- + ''' <summary> + ''' Removes an object from the collection. + ''' </summary> + ''' <param name="value">The object to remove.</param> + ''' <remarks>Removes the specified object from the collection and sets the + ''' dirty flag on the container object.</remarks> + ''' <history> + ''' [rbanks] 17/12/2003 Created + ''' </history> + '''----------------------------------------------------------------------------- + Public Sub Remove(ByVal value As CPersistentObject) + ' Debug.WriteLine("Coll: Removing " & value.GetType.Name) + list.Remove(value) + End Sub + '''----------------------------------------------------------------------------- + ''' <summary> + ''' Retrieves the item at the specified position. + ''' </summary> + ''' <param name="index">The zero-based position of the item in the collection.</param> + ''' <value>The CPersistentObject from the specified position.</value> + ''' <remarks>If the index does not refer to a valid position within the collection + ''' and exception will be thrown.</remarks> + ''' <history> + ''' [rbanks] 17/12/2003 Created + ''' </history> + '''----------------------------------------------------------------------------- + Default Public ReadOnly Property Item(ByVal index As Integer) As CPersistentObject + Get + ' Debug.WriteLine("Coll: index property = " & index) + Return CType(list.Item(index), CPersistentObject) + End Get + End Property - '''----------------------------------------------------------------------------- - ''' <summary> - ''' Attempts to save each item in the collection - ''' </summary> - ''' <value>An integer containing the number of objects that were actually saved.</value> - ''' <remarks>Each item in the collection is saved. If an error occurs during the saving - ''' of any object the process is immediately aborted and an exception is thrown. - ''' All objects are saved as part of a single transaction and the transaction is rolled back - ''' when there is an error.</remarks> - ''' <history> - ''' [rbanks] 21/05/2004 Created - ''' </history> - '''----------------------------------------------------------------------------- - Public Function Save() As Integer - Dim cp As CPersistentObject - Dim i As Integer = 0 - Dim pb As CPersistenceBroker = getPersistenceBrokerInstance() + '''----------------------------------------------------------------------------- + ''' <summary> + ''' Attempts to save each item in the collection + ''' </summary> + ''' <value>An integer containing the number of objects that were actually saved.</value> + ''' <remarks>Each item in the collection is saved. If an error occurs during the saving + ''' of any object the process is immediately aborted and an exception is thrown. + ''' All objects are saved as part of a single transaction and the transaction is rolled back + ''' when there is an error.</remarks> + ''' <history> + ''' [rbanks] 21/05/2004 Created + ''' </history> + '''----------------------------------------------------------------------------- + Public Function Save() As Integer + Dim cp As CPersistentObject + Dim i As Integer = 0 + Dim pb As CPersistenceBroker = getPersistenceBrokerInstance() - pb.startTransaction() - For Each cp In list - Try - If cp.IsDirty Then - cp.Save() - If Not cp.IsDirty Then - 'Object was saved - increment counter - i += 1 - End If - End If - Catch ex As Exception - pb.rollback() - Throw New SaveException(ex.Message, ex) - End Try - Next - pb.commit() - Return i - End Function + pb.startTransaction() + For Each cp In list + Try + If cp.IsDirty Then + cp.Save() + If Not cp.IsDirty Then + 'Object was saved - increment counter + i += 1 + End If + End If + Catch ex As Exception + pb.rollback() + Throw New SaveException(ex.Message, ex) + End Try + Next + pb.commit() + Return i + End Function - '''----------------------------------------------------------------------------- - ''' <summary> - ''' Attempts to delete each item in the collection - ''' </summary> - ''' <remarks>Each item in the collection is deleted. If an error occurs during the process - ''' an exception is thrown. All objects are deleted within a single transaction and the transaction is rolled back - ''' when there is an error.</remarks> - ''' <history> - ''' [rbanks] 21/05/2004 Created - ''' </history> - '''----------------------------------------------------------------------------- - Public Sub Delete() - Dim cp As CPersistentObject - Dim i As Integer = 0 - Dim pb As CPersistenceBroker = getPersistenceBrokerInstance() + '''----------------------------------------------------------------------------- + ''' <summary> + ''' Attempts to delete each item in the collection + ''' </summary> + ''' <remarks>Each item in the collection is deleted. If an error occurs during the process + ''' an exception is thrown. All objects are deleted within a single transaction and the transaction is rolled back + ''' when there is an error.</remarks> + ''' <history> + ''' [rbanks] 21/05/2004 Created + ''' </history> + '''----------------------------------------------------------------------------- + Public Sub Delete() + Dim cp As CPersistentObject + Dim i As Integer = 0 + Dim pb As CPersistenceBroker = getPersistenceBrokerInstance() - pb.startTransaction() - For Each cp In list - Try - cp.Delete() - Catch ex As Exception - pb.rollback() - Throw New DeleteException(ex.Message, ex) - End Try - Next - pb.commit() - Me.Clear() - End Sub + pb.startTransaction() + For Each cp In list + Try + cp.Delete() + Catch ex As Exception + pb.rollback() + Throw New DeleteException(ex.Message, ex) + End Try + Next + pb.commit() + Me.Clear() + End Sub - Private Sub ItemDirtiedHandler(ByVal sender As Object, ByVal e As EventArgs) - ' Debug.WriteLine("Collection trapped item dirtied event for " & sender.GetType.Name) - RaiseEvent ItemDirtied(Me, e) + Private Sub ItemDirtiedHandler(ByVal sender As Object, ByVal e As EventArgs) + ' Debug.WriteLine("Collection trapped item dirtied event for " & sender.GetType.Name) + RaiseEvent ItemDirtied(Me, e) If Not Me.ContainerObject Is Nothing Then 'Debug.WriteLine("item dirtied - dirtying container") ContainerObject.SetDirtyFlag() End If - End Sub + End Sub #End Region #Region "IBindlingList" Index: CClassMap.vb =================================================================== RCS file: /cvsroot/jcframework/dotnet/CClassMap.vb,v retrieving revision 1.55 retrieving revision 1.56 diff -u -d -r1.55 -r1.56 --- CClassMap.vb 22 Mar 2005 06:09:03 -0000 1.55 +++ CClassMap.vb 1 Apr 2005 00:03:53 -0000 1.56 @@ -278,7 +278,12 @@ '''----------------------------------------------------------------------------- Public Property FindAttributeMaps() As Collection Get - FindAttributeMaps = m_findAttributeMaps + If m_findAttributeMaps.Count = 0 Then + 'When no find attributes specified, find will use the primary key attributes + Return m_keyAttributeMaps + Else + Return m_findAttributeMaps + End If End Get Set(ByVal Value As Collection) m_findAttributeMaps = Value @@ -808,7 +813,7 @@ ''' </history> '''----------------------------------------------------------------------------- Public Function getKeySize() As Short - getKeySize = Me.KeyAttributeMaps.Count() + Return m_keyAttributeMaps.Count End Function '''----------------------------------------------------------------------------- @@ -822,7 +827,11 @@ ''' </history> '''----------------------------------------------------------------------------- Public Function getFindSize() As Short - Return m_findAttributeMaps.Count() + If m_findAttributeMaps.Count = 0 Then + Return m_keyAttributeMaps.Count + Else + Return m_findAttributeMaps.Count + End If End Function '''----------------------------------------------------------------------------- @@ -853,9 +862,11 @@ ''' </history> '''----------------------------------------------------------------------------- Public Function getFindAttributeMap(ByVal index As Short) As CAttributeMap - Dim AttrMap As CAttributeMap - AttrMap = m_findAttributeMaps.Item(index) - getFindAttributeMap = AttrMap + If m_findAttributeMaps.Count = 0 Then + Return m_keyAttributeMaps.Item(index) + Else + Return m_findAttributeMaps.Item(index) + End If End Function '''----------------------------------------------------------------------------- @@ -2083,9 +2094,13 @@ End Property Public Function CreateObjectInstance() As IPersistableObject + Return CreateObjectInstance(False) + End Function + + Public Function CreateObjectInstance(ByVal setStrongReference As Boolean) As IPersistableObject Dim ip As IPersistableObject If m_classFactoryName Is Nothing Then - Return CreateObjectInstanceNoFactory() + Return CreateObjectInstanceNoFactory(setStrongReference) End If 'Try to locate the object factory @@ -2128,11 +2143,11 @@ End Try m_classFactory = CType(obj, IClassFactory) End If - ip = CreateObjectInstanceViaFactory() + ip = CreateObjectInstanceViaFactory(setStrongReference) Return ip End Function - Private Function CreateObjectInstanceNoFactory() As IPersistableObject + Private Function CreateObjectInstanceNoFactory(ByVal setStrongReference As Boolean) As IPersistableObject Dim obj As Object Dim ip As IPersistableObject Dim pbroker As CPersistenceBroker @@ -2168,25 +2183,33 @@ If t Is Nothing Then Return Nothing obj = Activator.CreateInstance(t) End If - Try + If TypeOf obj Is IPersistableObject Then ip = CType(obj, IPersistableObject) - Catch ex As Exception + Else + 'If setStrongReference Then + ' ip = New CInjectedObject(obj, True) + 'Else ip = New CInjectedObject(obj) - End Try + 'End If + End If Return ip End Function - Public Function CreateObjectInstanceViaFactory() As IPersistableObject + Public Function CreateObjectInstanceViaFactory(ByVal setStrongReference As Boolean) As IPersistableObject Dim obj As Object Dim ip As IPersistableObject Dim pbroker As CPersistenceBroker obj = m_classFactory.CreateObject - Try + If TypeOf obj Is IPersistableObject Then ip = CType(obj, IPersistableObject) - Catch ex As Exception + Else + 'If setStrongReference Then + ' ip = New CInjectedObject(obj, True) + 'Else ip = New CInjectedObject(obj) - End Try + 'End If + End If Return ip End Function Index: CMultiSummaryCriteria.vb =================================================================== RCS file: /cvsroot/jcframework/dotnet/CMultiSummaryCriteria.vb,v retrieving revision 1.16 retrieving revision 1.17 diff -u -d -r1.16 -r1.17 --- CMultiSummaryCriteria.vb 21 Mar 2005 08:00:23 -0000 1.16 +++ CMultiSummaryCriteria.vb 1 Apr 2005 00:04:08 -0000 1.17 @@ -217,11 +217,11 @@ End If cm2 = fromObj.GetClassMap + cm = obj.GetClassMap am = cm2.GetAssociationMapByName(assocName) If am Is Nothing Then Throw New NoAssociationException("Invalid association " & assocName & " selected - no such association exists") End If - cm = obj.GetClassMap m_fromCMaps.Add(cm) i = m_fromCMaps.Count mapName = "t" & i.ToString @@ -267,8 +267,7 @@ strName = myArrayStrings(i) udaMap = clMap.AssociationMaps(strName) If udaMap Is Nothing Then - Throw New AToMSFramework.RetrieveException("Could not find association named " & strName & " for class " & clMap.Name) - + Throw New RetrieveException("Could not find association named " & strName & " for class " & clMap.Name) End If clMap = udaMap.ToClass If clMap Is Nothing Then Index: CInjectedObjects.vb =================================================================== RCS file: /cvsroot/jcframework/dotnet/CInjectedObjects.vb,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- CInjectedObjects.vb 16 Mar 2005 11:32:34 -0000 1.6 +++ CInjectedObjects.vb 1 Apr 2005 00:04:07 -0000 1.7 @@ -20,12 +20,12 @@ End Sub Public Property Temporary() As Boolean - Get - Return m_istemporary - End Get - Set(ByVal Value As Boolean) - m_istemporary = Value - End Set + Get + Return m_istemporary + End Get + Set(ByVal Value As Boolean) + m_istemporary = Value + End Set End Property Public Sub NewInjObj(ByVal injobj As CInjectedObject) @@ -40,30 +40,30 @@ Return m_hashCode End Function - Private Sub CalculateHashCode() - Dim i As Long - Dim count As Integer - Dim obj As Object - Dim t As Type - i = m_type.Name.GetHashCode - count = 1 - For Each obj In m_keyvalues - If Not obj Is Nothing Then - If TypeOf obj Is Integer Then - i += CInt(obj).GetHashCode - ElseIf TypeOf obj Is String Then - i += CStr(obj).GetHashCode - ElseIf TypeOf obj Is Double Then - i += CDbl(obj).GetHashCode - Else - t = obj.GetType - i += t.Name.GetHashCode - End If - count += 1 - End If - Next - m_hashCode = CInt(i / count) - End Sub + 'Private Sub CalculateHashCode() + ' Dim i As Long + ' Dim count As Integer + ' Dim obj As Object + ' Dim t As Type + ' i = m_type.Name.GetHashCode + ' count = 1 + ' For Each obj In m_keyvalues + ' If Not obj Is Nothing Then + ' If TypeOf obj Is Integer Then + ' i += CInt(obj).GetHashCode + ' ElseIf TypeOf obj Is String Then + ' i += CStr(obj).GetHashCode + ' ElseIf TypeOf obj Is Double Then + ' i += CDbl(obj).GetHashCode + ' Else + ' t = obj.GetType + ' i += t.Name.GetHashCode + ' End If + ' count += 1 + ' End If + ' Next + ' m_hashCode = CInt(i / count) + 'End Sub Protected Sub populateKey(ByVal injObj As IPersistableObject) Dim cm As CClassMap @@ -82,7 +82,8 @@ End If m_keyvalues.Add(x) Next - CalculateHashCode() + m_hashCode = injObj.GetSourceObject.GetHashCode + 'CalculateHashCode() End Sub Public Overloads Shared Function Equals(ByVal obj1 As Object, ByVal obj2 As Object) As Boolean @@ -101,11 +102,14 @@ If Not (Me.m_type Is key.m_type) Then Return False End If - For i = 1 To m_keyvalues.Count - If m_keyvalues(i) <> key.m_keyvalues(i) Then + If Me.GetHashCode <> obj1.GetHashCode Then Return False End If - Next + 'For i = 1 To m_keyvalues.Count + ' If m_keyvalues(i) <> key.m_keyvalues(i) Then + ' Return False + ' End If + 'Next Return True End Function @@ -167,7 +171,7 @@ End Sub Public Overloads Sub Add(ByVal obj As CInjectedObject) - Me.AddTemp(obj, False) + Me.AddTemp(obj, False) End Sub Public Overloads Function isTracked(ByVal obj As Object) As Boolean @@ -217,6 +221,12 @@ Dim interval As Double Dim ikey As CInjectedObjectKey + 'Before we start looking at the cache we call the garbage collector to ensure + 'that weakreferences in CInjectedObject are cleared - ie the IsAlive flag is updated. + ' This may be a big performance hit - we'll have to watch and see + 'GC.Collect() + 'GC.WaitForPendingFinalizers() + 'We cannot use the dictionary key to find an object as changes to the key attributes 'of an object will result in a different dictionary key being generated and an 'we won't be able to find the object, even though it exists. @@ -230,8 +240,13 @@ x = CType(m_Enumerator.Current, DictionaryEntry) injObj = CType(x.Value, CInjectedObject) t = injObj.GetObjectType + 'If Not injObj.IsAlive Then + ' MyBase.Remove(x.Key) + ' m_Enumerator = Me.GetEnumerator + ' m_Enumerator.Reset() 'Reset enumerator after removing item + 'Else + found = True If t Is obj.GetObjectType OrElse (CheckSubClasses AndAlso t.IsSubclassOf(obj.GetObjectType)) Then - found = True Try If useFindAttributes Then For i = 1 To cm.getFindSize @@ -260,6 +275,7 @@ Return injObj End If End If + 'End If End While Return Nothing End Function @@ -280,26 +296,45 @@ End Sub Public Sub CleanUp() - 'Clean up cache by resetting isqueued flags and also removing temp entries - Dim toRemove As New Collection - Dim obj As CInjectedObject - Dim k As CInjectedObjectKey - For Each de As DictionaryEntry In Me - k = CType(de.Key, CInjectedObjectKey) - If k.Temporary Then - toRemove.Add(k) - Else - If Not de.Value Is Nothing Then - obj = CType(de.Value, CInjectedObject) - If obj.IsQueued Then - obj.IsQueued = False - End If - End If - End If - Next - For Each k In toRemove - Remove(k) - Next + 'Clean up cache by resetting isqueued flags, removing temp entries, and clearing strong references + Dim toRemove As New Collection + Dim obj As CInjectedObject + Dim k As CInjectedObjectKey + + 'Clear any strong references first - these would only be present set + 'during object retrieval to ensure injectedobjects stayed in the collection + 'For Each de As DictionaryEntry In Me + ' If Not de.Value Is Nothing Then + ' obj = CType(de.Value, CInjectedObject) + ' If Not obj.StrongReference Is Nothing Then + ' obj.StrongReference = Nothing + ' End If + ' End If + 'Next + + 'GC.Collect() + 'GC.WaitForPendingFinalizers() + + For Each de As DictionaryEntry In Me + k = CType(de.Key, CInjectedObjectKey) + If k.Temporary Then + toRemove.Add(k) + Else + If Not de.Value Is Nothing Then + obj = CType(de.Value, CInjectedObject) + 'If Not obj.IsAlive Then + ' toRemove.Add(k) + 'Else + If obj.IsQueued Then + obj.IsQueued = False + End If + 'End If + End If + End If + Next + For Each k In toRemove + Remove(k) + Next End Sub Public Overrides Function ToString() As String @@ -323,5 +358,22 @@ outString &= ">>>> END TRACKED OBJECTS DUMP <<<<" Return outString End Function + + Public Function GetValueArray() As ArrayList + Dim al As ArrayList + Dim valArray(Me.Values.Count) As Object + Me.Values.CopyTo(valArray, 0) + al = New ArrayList(valArray) + Return al + End Function + + Public Function GetKeyArray() As ArrayList + Dim al As ArrayList + Dim valArray(Me.Keys.Count) As Object + Me.Keys.CopyTo(valArray, 0) + al = New ArrayList(valArray) + Return al + End Function + End Class Index: CInjectedObject.vb =================================================================== RCS file: /cvsroot/jcframework/dotnet/CInjectedObject.vb,v retrieving revision 1.20 retrieving revision 1.21 diff -u -d -r1.20 -r1.21 --- CInjectedObject.vb 22 Mar 2005 06:09:11 -0000 1.20 +++ CInjectedObject.vb 1 Apr 2005 00:04:07 -0000 1.21 @@ -24,9 +24,13 @@ Private m_markedForDeletion As Boolean Private m_deleteParents As Boolean Private m_oneToManyCollections As New Collection + 'Private m_strongReference As Object Public Sub New(ByVal obj As Object) MyBase.New() + If TypeOf obj Is IPersistableObject Then + obj = CType(obj, IPersistableObject).GetSourceObject + End If m_object = obj m_originalObject = Activator.CreateInstance(obj.GetType) End Sub @@ -36,7 +40,7 @@ Return m_object End Get Set(ByVal Value As Object) - m_object = New WeakReference(Value) + m_object = Value End Set End Property @@ -50,37 +54,44 @@ End Property Public Sub ResetToOriginal() - ReplaceValues(m_originalObject, m_object) + ReplaceValues(m_originalObject, m_object, False) End Sub - Sub ReplaceWith(ByVal obj As IPersistableObject) Implements IPersistableObject.ReplaceWith + Sub ReplaceWith(ByVal obj As IPersistableObject, ByVal copyEventHandlers As Boolean) Implements IPersistableObject.ReplaceWith If Not obj.GetObjectType Is Me.GetObjectType Then Throw New Exception("Objects must be of the same type") End If Dim injObj As CInjectedObject If Not obj.IsIPersistentObject Then injObj = CType(obj, CInjectedObject) - ReplaceValues(injObj.m_object, m_object) + ReplaceValues(injObj.m_object, m_object, copyEventHandlers) Else - ReplaceValues(obj, m_object) + ReplaceValues(obj, m_object, copyEventHandlers) End If End Sub - Public Sub ReplaceValues(ByVal sourceObject As Object, ByVal targetObject As Object) + Public Sub ReplaceValues(ByVal sourceObject As Object, ByVal targetObject As Object, ByVal copyEventHandlers As Boolean) 'Use reflection to copy all of the fields from sourceObj to targetobject (by value) If sourceObject Is Nothing OrElse targetObject Is Nothing Then Return - If Not sourceObject.GetType Is targetObject.GetType Then + If Not sourceObject.GetType Is targetObject.GetType And Not sourceObject.GetType.IsSubclassOf(targetObject.GetType) Then Throw New Exception("Objects must be of the same type") End If + If sourceObject Is targetObject Then + 'Same object so nothing to do + Exit Sub + End If Dim f, fields() As FieldInfo Dim value As Object Dim t, iListType, iDicType As Type Try - t = sourceObject.GetType + t = targetObject.GetType While Not t Is Nothing fields = t.GetFields(BindingFlags.Instance Or BindingFlags.NonPublic Or BindingFlags.Public) - 'Note that this will copy event handlers as well For Each f In fields + If Not copyEventHandlers AndAlso (f.FieldType.Name = f.Name & "Handler" OrElse f.FieldType Is GetType(EventHandler)) Then + 'This is an event! + 'Do Nothing + Else iListType = f.FieldType.GetInterface("IList", True) iDicType = f.FieldType.GetInterface("IDictionary", True) 'Do not copy collections yet - we'll do that at the end @@ -88,6 +99,7 @@ value = f.GetValue(sourceObject) f.SetValue(targetObject, value) End If + End If Next If Not t.BaseType Is Nothing Then t = t.BaseType @@ -264,7 +276,7 @@ 'Since we check for value differences to tell if an object is dirty, we need to 'replace the original object values with the current ones. If Value = False Then - ReplaceValues(m_object, m_originalObject) + ReplaceValues(m_object, m_originalObject, False) End If End Set End Property @@ -347,29 +359,37 @@ End Property Public Function getCollectionByAttribute(ByVal pName As String) As IList Implements IPersistableObject.getCollectionByAttribute + Return getCollectionByAttribute(m_object, pName) + End Function + + Private Function getCollectionByAttribute(ByVal srcObj As Object, ByVal pName As String) As IList Dim dotPos As Integer dotPos = pName.IndexOf(".") Try If dotPos = -1 Then - Return CType(CallByName(m_object, pName, CallType.Get), IList) + Return CType(CallByName(srcObj, pName, CallType.Get), IList) Else Dim o As Object Dim objName As String Dim propertyName As String objName = pName.Substring(0, dotPos) propertyName = pName.Substring(dotPos + 1) - o = CallByName(m_object, objName, CallType.Get) + o = CallByName(srcObj, objName, CallType.Get) If o Is Nothing Then Return Nothing End If Return CType(CallByName(o, propertyName, CallType.Get), IList) End If Catch err As Exception - Throw New Exception("getCollectionByAttribute failed for attribute " & pName & " in " & m_object.GetType.FullName, err) + Throw New Exception("getCollectionByAttribute failed for attribute " & pName & " in " & srcObj.GetType.FullName, err) End Try End Function Public Function getObjectByAttribute(ByVal pName As String) As IPersistableObject Implements IPersistableObject.getObjectByAttribute + Return getObjectByAttribute(m_object, pName) + End Function + + Private Function getObjectByAttribute(ByVal srcObj As Object, ByVal pName As String) As IPersistableObject Dim dotPos As Integer Dim obj As Object Dim injobj As CInjectedObject @@ -378,14 +398,14 @@ dotPos = pName.IndexOf(".") Try If dotPos = -1 Then - obj = CallByName(m_object, pName, CallType.Get) + obj = CallByName(srcObj, pName, CallType.Get) Else Dim o As Object Dim objName As String Dim propertyName As String objName = pName.Substring(0, dotPos) propertyName = pName.Substring(dotPos + 1) - o = CallByName(m_object, objName, CallType.Get) + o = CallByName(srcObj, objName, CallType.Get) If o Is Nothing Then Return Nothing End If @@ -399,7 +419,7 @@ injobj = pbroker.getInjectedObject(obj) End If Catch ex As Exception - Throw New Exception("getObjectByAttribute failed for attribute " & pName & " in " & m_object.GetType.FullName, ex) + Throw New Exception("getObjectByAttribute failed for attribute " & pName & " in " & srcObj.GetType.FullName, ex) End Try Return injobj End Function @@ -504,21 +524,29 @@ obj.State = Me.State End If + Dim ci As CInjectedObject + If Not obj.IsIPersistentObject Then + ci = CType(obj, CInjectedObject) + End If + 'set object's attributes - also copy the original values as well. 'set the associated objects For i = 1 To classMap.getStraightAssociationMapSize udamap = classMap.getStraightAssociationMap(i) If udamap.Cardinality = CUDAMap.CardinalityEnum.ONE_TO_ONE Then obj.SetAttributeValue(udamap.FromClassTarget, Me.getObjectByAttribute(udamap.FromClassTarget)) + If Not ci Is Nothing Then ci.setAttributeValue(ci.m_originalObject, udamap.FromClassTarget, Me.getObjectByAttribute(m_originalObject, udamap.FromClassTarget)) ElseIf udamap.Cardinality = CUDAMap.CardinalityEnum.ONE_TO_MANY Or udamap.Cardinality = CUDAMap.CardinalityEnum.MANY_TO_MANY Then obj.SetAttributeValue(udamap.FromClassTarget, Me.getCollectionByAttribute(udamap.FromClassTarget)) + If Not ci Is Nothing Then ci.setAttributeValue(ci.m_originalObject, udamap.FromClassTarget, Me.getCollectionByAttribute(m_originalObject, udamap.FromClassTarget)) End If Next i - - 'set object's attributes Dim AttrMap As CAttributeMap For i = 1 To CType(classMap.AttributeMaps.Count, Short) AttrMap = classMap.getAttributeMap(i) + If Not AttrMap.ColumnMap Is Nothing Then obj.SetAttributeValue(AttrMap.Name, Me.getValueByAttribute(AttrMap.Name)) + If Not ci Is Nothing Then ci.setAttributeValue(ci.m_originalObject, AttrMap.Name, Me.getOriginalValueByAttribute(AttrMap.Name)) + End If Next 'if it has superclass add its attributes @@ -529,21 +557,23 @@ udamap = cm.getStraightAssociationMap(i) If udamap.Cardinality = CUDAMap.CardinalityEnum.ONE_TO_ONE Then obj.SetAttributeValue(udamap.FromClassTarget, Me.getObjectByAttribute(udamap.FromClassTarget)) + If Not ci Is Nothing Then ci.setAttributeValue(ci.m_originalObject, udamap.FromClassTarget, Me.getObjectByAttribute(m_originalObject, udamap.FromClassTarget)) ElseIf udamap.Cardinality = CUDAMap.CardinalityEnum.ONE_TO_MANY Or udamap.Cardinality = CUDAMap.CardinalityEnum.MANY_TO_MANY Then obj.SetAttributeValue(udamap.FromClassTarget, Me.getCollectionByAttribute(udamap.FromClassTarget)) + If Not ci Is Nothing Then ci.setAttributeValue(ci.m_originalObject, udamap.FromClassTarget, Me.getCollectionByAttribute(m_originalObject, udamap.FromClassTarget)) End If Next i 'set superclass's attributes For i = 1 To CType(cm.AttributeMaps.Count, Short) AttrMap = cm.getAttributeMap(i) + If Not AttrMap.ColumnMap Is Nothing Then obj.SetAttributeValue(AttrMap.Name, Me.getValueByAttribute(AttrMap.Name)) + If Not ci Is Nothing Then ci.setAttributeValue(ci.m_originalObject, AttrMap.Name, Me.getValueByAttribute(m_originalObject, AttrMap.Name)) + End If Next cm = cm.SuperClass End While - - obj.IsDirty = Me.IsDirty - Return obj End Function @@ -709,5 +739,10 @@ Public Function IsIPersistentObject() As Boolean Implements IPersistableObject.IsIPersistentObject Return False End Function + + Public Function IsAlive() As Boolean + Return True + 'Return m_object.IsAlive + End Function End Class Index: CPersistentObject.vb =================================================================== RCS file: /cvsroot/jcframework/dotnet/CPersistentObject.vb,v retrieving revision 1.60 retrieving revision 1.61 diff -u -d -r1.60 -r1.61 --- CPersistentObject.vb 22 Mar 2005 06:09:11 -0000 1.60 +++ CPersistentObject.vb 1 Apr 2005 00:04:18 -0000 1.61 @@ -528,11 +528,11 @@ propertyName = pName.Substring(dotPos + 1) o = CallByName(Me, objName, CallType.Get) If o.GetType.IsValueType Then - Val = o + val = o If TypeOf (Value) Is System.SByte Then - CallByName(Val, propertyName, CallType.Set, IIf(Value.ToString = "1", True, False)) + CallByName(val, propertyName, CallType.Set, IIf(Value.ToString = "1", True, False)) Else - CallByName(Val, propertyName, CallType.Set, Value) + CallByName(val, propertyName, CallType.Set, Value) End If CallByName(Me, objName, CallType.Set, val) Else @@ -689,7 +689,7 @@ Return CallByName(o, propertyName, CallType.Get) End If Catch err As Exception - Throw New Exception("getCollectionByAttribute failed for class " & Me.getclassmap.name & " attribute: " & " " & pname, err) + Throw New Exception("getCollectionByAttribute failed for class " & Me.getClassMap.Name & " attribute: " & " " & pName, err) End Try End Function @@ -865,9 +865,10 @@ Dim x As Boolean Dim obj As CPersistentObject obj = Me.getNewObject - obj.ReplaceWith(Me) + 'Make sure event handlers are copied so that events fire during retrieve + obj.ReplaceWith(Me, True) x = obj.Retrieve(obj) - Me.ReplaceWith(obj) + Me.ReplaceWith(obj, False) Return x End Function @@ -934,8 +935,8 @@ Debug.WriteLine("The object with key " & ckey.ToString & " was already saved once") Else persistentBroker.saveObject(value) - 'Recopy one-to-many collections incase object is resaved later - value.CopyOneToManyCollections() + 'Recopy one-to-many collections incase object is resaved later + value.CopyOneToManyCollections() 'Need to recalculate the key here to handle objects using identity (autonumber) keys ckey = New CCacheKey(value) savedKeys.Add(ckey) @@ -1119,9 +1120,10 @@ Dim x As Boolean Dim obj As CPersistentObject obj = Me.getNewObject - obj.ReplaceWith(Me) + 'Make sure event handlers are copied so that events fire during find + obj.ReplaceWith(Me, True) x = obj.Find(obj) - Me.ReplaceWith(obj) + Me.ReplaceWith(obj, False) Return x End Function @@ -1282,7 +1284,7 @@ Public Overridable Function Copy() As IPersistableObject Implements IPersistentObject.Copy Dim obj As CPersistentObject obj = Me.getClassMap.CreateObjectInstance - obj.ReplaceWith(Me) + obj.ReplaceWith(Me, False) Return obj End Function @@ -1298,7 +1300,7 @@ ''' [rbanks] 12/08/2004 Created ''' </history> '''----------------------------------------------------------------------------- - Public Overridable Sub ReplaceWith(ByVal obj As IPersistableObject) Implements IPersistentObject.ReplaceWith + Public Overridable Sub ReplaceWith(ByVal obj As IPersistableObject, ByVal copyEventHandlers As Boolean) Implements IPersistentObject.ReplaceWith 'Use reflection to copy all of the fields from Obj to me (by value) 'Also copy collections If obj Is Nothing Then Return @@ -1312,14 +1314,18 @@ t = Me.GetType While Not t Is Nothing fields = t.GetFields(BindingFlags.Instance Or BindingFlags.NonPublic Or BindingFlags.Public) - 'Note that this will copy event handlers as well For Each f In fields - iListType = f.FieldType.GetInterface("IList", True) - iDicType = f.FieldType.GetInterface("IDictionary", True) - 'Do not copy collections yet - we'll do that at the end - If iListType Is Nothing AndAlso iDicType Is Nothing Then - value = f.GetValue(obj) - f.SetValue(Me, value) + If Not copyEventHandlers AndAlso (f.FieldType.Name = f.Name & "Handler" OrElse f.FieldType Is GetType(EventHandler)) Then + 'This is an event! + 'Do Nothing + Else + iListType = f.FieldType.GetInterface("IList", True) + iDicType = f.FieldType.GetInterface("IDictionary", True) + 'Do not copy collections yet - we'll do that at the end + If iListType Is Nothing AndAlso iDicType Is Nothing Then + value = f.GetValue(obj) + f.SetValue(Me, value) + End If End If Next If t.IsSubclassOf(GetType(CPersistentObject)) Then @@ -1762,9 +1768,9 @@ For Each collItem In origIList If NotInCollection(fromIList, collItem) Then If Not TypeOf collItem Is IPersistableObject Then - injObj = getPersistenceBrokerInstance.getInjectedObject(collItem, True) + injobj = getPersistenceBrokerInstance.getInjectedObject(collItem, True) Else - injObj = collItem + injobj = collItem End If toColl.Add(collItem) End If @@ -1831,7 +1837,7 @@ Public Overridable Sub BeginEdit() Implements System.ComponentModel.IEditableObject.BeginEdit If Not m_editing Then m_preEditCopy = Me.getNewObject - m_preEditCopy.ReplaceWith(Me) + m_preEditCopy.ReplaceWith(Me, False) m_editing = True End If End Sub @@ -1851,7 +1857,7 @@ <EditorBrowsable(EditorBrowsableState.Advanced)> _ Public Overridable Sub CancelEdit() Implements System.ComponentModel.IEditableObject.CancelEdit m_editing = False - Me.ReplaceWith(m_preEditCopy) + Me.ReplaceWith(m_preEditCopy, False) m_preEditCopy = Nothing If m_isNew Then m_isNew = False |
From: Richard B. <rb...@us...> - 2005-04-01 00:05:26
|
Update of /cvsroot/jcframework/dotnet/Providers/AF_MySQL In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18014/Providers/AF_MySQL Modified Files: CMySQLConnection.vb CMySqlDatabase.vb Log Message: Fixes for a number of issues with injected objects. Fixes for transactions when errors occur during the rollback, etc Fixes for removing event listeners from objects added to the cache to prevent multiple event firing. Index: CMySqlDatabase.vb =================================================================== RCS file: /cvsroot/jcframework/dotnet/Providers/AF_MySQL/CMySqlDatabase.vb,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- CMySqlDatabase.vb 15 Mar 2005 11:14:51 -0000 1.3 +++ CMySqlDatabase.vb 1 Apr 2005 00:04:35 -0000 1.4 @@ -311,28 +311,28 @@ '''----------------------------------------------------------------------------- Public Overrides Function getParamHolder(ByVal i As Integer) As String 'Return "?" - 'Return "@p" & CStr(i) - this is the old version - only use if still referencing bytefx - Return "?p" & CStr(i) 'New syntax as of v1.04 of MySQLConnect/NET - End Function + 'Return "@p" & CStr(i) - this is the old version - only use if still referencing bytefx + Return "?p" & CStr(i) 'New syntax as of v1.04 of MySQLConnect/NET + End Function - Public Overrides Function getClauseStringTableAlias(ByVal table As String, ByVal owner As String, ByVal pAlias As String) As String - Return Me.m_name & "." & table & " as " & pAlias - End Function + Public Overrides Function getClauseStringTableAlias(ByVal table As String, ByVal owner As String, ByVal pAlias As String) As String + Return Me.m_name & "." & 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 CMySqlConnection - While ConnectionPool.Count > 0 - conn = ConnectionPool.Pop - conn.Dispose() - End While - m_disposed = True - End If - End If - End Sub + Public Overloads Overrides Sub Dispose(ByVal disposing As Boolean) + If Not m_disposed Then + If disposing Then + Dim conn As CMySqlConnection + While ConnectionPool.Count > 0 + conn = ConnectionPool.Pop + conn.Dispose() + End While + m_disposed = True + End If + End If + End Sub - Public Overrides Function supportsSelectOffsets() As Boolean - Return True - End Function + Public Overrides Function supportsSelectOffsets() As Boolean + Return True + End Function End Class Index: CMySQLConnection.vb =================================================================== RCS file: /cvsroot/jcframework/dotnet/Providers/AF_MySQL/CMySQLConnection.vb,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- CMySQLConnection.vb 7 Feb 2005 13:22:07 -0000 1.2 +++ CMySQLConnection.vb 1 Apr 2005 00:04:35 -0000 1.3 @@ -184,12 +184,12 @@ End If End If If Me.ManageTransactions Then + m_transactioncalls += 1 If Not Me.Started Then + Me.Started = True m_transaction = m_connection.BeginTransaction getPersistenceBrokerInstance().startCacheTransaction(Me.Database) End If - m_transactioncalls += 1 - Me.Started = True End If End Sub @@ -212,12 +212,12 @@ End If End If If Me.ManageTransactions Then + m_transactioncalls += 1 If Not Me.Started Then + Me.Started = True m_transaction = m_connection.BeginTransaction(isolationLevel) getPersistenceBrokerInstance().startCacheTransaction(Me.Database) End If - m_transactioncalls += 1 - Me.Started = True End If End Sub @@ -335,16 +335,17 @@ End If End If If Me.ManageTransactions Then - If m_transactioncalls = 1 Then + m_transactioncalls -= 1 + If m_transactioncalls = 0 Then Try m_transaction.Rollback() + Me.Started = False + m_transaction = Nothing Catch ex As Exception + Debug.WriteLine("rollback failed " & ex.Message) End Try getPersistenceBrokerInstance().rollbackCache(Me.Database) - Me.Started = False - m_transaction = Nothing End If - m_transactioncalls -= 1 End If End Sub |
From: Richard B. <rb...@us...> - 2005-04-01 00:05:17
|
Update of /cvsroot/jcframework/dotnet/Providers/AF_OLEDB In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18014/Providers/AF_OLEDB Modified Files: COleDBConnection.vb Log Message: Fixes for a number of issues with injected objects. Fixes for transactions when errors occur during the rollback, etc Fixes for removing event listeners from objects added to the cache to prevent multiple event firing. Index: COleDBConnection.vb =================================================================== RCS file: /cvsroot/jcframework/dotnet/Providers/AF_OLEDB/COleDBConnection.vb,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- COleDBConnection.vb 11 Mar 2005 04:40:56 -0000 1.2 +++ COleDBConnection.vb 1 Apr 2005 00:04:36 -0000 1.3 @@ -173,12 +173,12 @@ End If End If If Me.ManageTransactions Then + m_transactioncalls += 1 If Not Me.Started Then + Me.Started = True m_transaction = m_connection.BeginTransaction getPersistenceBrokerInstance().startCacheTransaction(Me.Database) End If - m_transactioncalls += 1 - Me.Started = True End If End Sub @@ -293,16 +293,17 @@ End If End If If Me.ManageTransactions Then - If m_transactioncalls = 1 Then + m_transactioncalls -= 1 + If m_transactioncalls = 0 Then Try m_transaction.Rollback() + Me.Started = False + m_transaction = Nothing Catch ex As Exception + Debug.WriteLine("rollback failed " & ex.Message) End Try getPersistenceBrokerInstance().rollbackCache(Me.Database) - Me.Started = False - m_transaction = Nothing End If - m_transactioncalls -= 1 End If End Sub @@ -404,12 +405,12 @@ End If End If If Me.ManageTransactions Then + m_transactioncalls += 1 If Not Me.Started Then + Me.Started = True m_transaction = m_connection.BeginTransaction(isolationLevel) getPersistenceBrokerInstance().startCacheTransaction(Me.Database) End If - m_transactioncalls += 1 - Me.Started = True End If End Sub |
From: Richard B. <rb...@us...> - 2005-04-01 00:05:15
|
Update of /cvsroot/jcframework/dotnet/Providers/AF_ODBC In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18014/Providers/AF_ODBC Modified Files: CODBCConnection.vb Log Message: Fixes for a number of issues with injected objects. Fixes for transactions when errors occur during the rollback, etc Fixes for removing event listeners from objects added to the cache to prevent multiple event firing. Index: CODBCConnection.vb =================================================================== RCS file: /cvsroot/jcframework/dotnet/Providers/AF_ODBC/CODBCConnection.vb,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- CODBCConnection.vb 7 Feb 2005 07:37:53 -0000 1.1 +++ CODBCConnection.vb 1 Apr 2005 00:04:36 -0000 1.2 @@ -173,12 +173,12 @@ End If End If If Me.ManageTransactions Then + m_transactioncalls += 1 If Not Me.Started Then + Me.Started = True m_transaction = m_connection.BeginTransaction getPersistenceBrokerInstance().startCacheTransaction(Me.Database) End If - m_transactioncalls += 1 - Me.Started = True End If End Sub @@ -291,16 +291,17 @@ End If End If If Me.ManageTransactions Then - If m_transactioncalls = 1 Then + m_transactioncalls -= 1 + If m_transactioncalls = 0 Then Try m_transaction.Rollback() + Me.Started = False + m_transaction = Nothing Catch ex As Exception + Debug.WriteLine("rollback failed " & ex.Message) End Try getPersistenceBrokerInstance().rollbackCache(Me.Database) - Me.Started = False - m_transaction = Nothing End If - m_transactioncalls -= 1 End If End Sub @@ -402,12 +403,12 @@ End If End If If Me.ManageTransactions Then + m_transactioncalls += 1 If Not Me.Started Then + Me.Started = True m_transaction = m_connection.BeginTransaction(isolationLevel) getPersistenceBrokerInstance().startCacheTransaction(Me.Database) End If - m_transactioncalls += 1 - Me.Started = True End If End Sub |
From: Richard B. <rb...@us...> - 2005-04-01 00:05:15
|
Update of /cvsroot/jcframework/dotnet/Providers/AF_Informix In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18014/Providers/AF_Informix Modified Files: CInformixConnection.vb CInformixDatabase.vb Log Message: Fixes for a number of issues with injected objects. Fixes for transactions when errors occur during the rollback, etc Fixes for removing event listeners from objects added to the cache to prevent multiple event firing. Index: CInformixDatabase.vb =================================================================== RCS file: /cvsroot/jcframework/dotnet/Providers/AF_Informix/CInformixDatabase.vb,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- CInformixDatabase.vb 7 Feb 2005 13:22:06 -0000 1.2 +++ CInformixDatabase.vb 1 Apr 2005 00:04:32 -0000 1.3 @@ -24,15 +24,15 @@ Private m_user As String Private m_password As String Private m_serverName As String - Private m_host As String - Private m_service As String + Private m_host As String + Private m_service As String '''----------------------------------------------------------------------------- ''' <summary> ''' Establishes a new database connection. ''' </summary> - ''' <returns>A CInformixConnection containing the newly established connection.</returns> - ''' <remarks>The CInformixConnection class implements the _CConnection interface which + ''' <returns>A CInformixConnection containing the newly established connection.</returns> + ''' <remarks>The CInformixConnection class implements the _CConnection interface which ''' is required by this method. ''' <para>If the connection cannot be established an exception will be thrown.</para> ''' <para>The connection is established using normal SQL server authentication (ie @@ -43,7 +43,7 @@ '''----------------------------------------------------------------------------- Public Overrides Function getNewConnection() As _CConnection Dim conn As New CInformixConnection - conn.Connection = New IfxConnection + conn.Connection = New IfxConnection conn.ManageTransactions = True Try If m_user Is Nothing OrElse m_user.Length = 0 Then @@ -52,23 +52,23 @@ Dim pbroker As CPersistenceBroker pbroker = getPersistenceBrokerInstance() pbroker.GetLoginDetails(Me, m_user, m_password) - End If - If m_service = String.Empty Then m_service = "8080" - conn.Connection.ConnectionString = _ - "Server=" & m_serverName & ";" & _ - "Database=" & m_name & ";" & _ - "Host=" & m_host & ";" & _ - "Protocol=onsoctcp;" & _ - "Service=" & m_service & ";" & _ - "uid=" & m_user & ";" & _ - "Password=" & m_password - conn.Connection.Open() - Catch ex As IfxException - Throw New DatabaseConnectionException(ex.Message, ex) - Catch ex As Exception - Throw New DatabaseConnectionException(ex.Message, ex) - End Try - getNewConnection = conn + End If + If m_service = String.Empty Then m_service = "8080" + conn.Connection.ConnectionString = _ + "Server=" & m_serverName & ";" & _ + "Database=" & m_name & ";" & _ + "Host=" & m_host & ";" & _ + "Protocol=onsoctcp;" & _ + "Service=" & m_service & ";" & _ + "uid=" & m_user & ";" & _ + "Password=" & m_password + conn.Connection.Open() + Catch ex As IfxException + Throw New DatabaseConnectionException(ex.Message, ex) + Catch ex As Exception + Throw New DatabaseConnectionException(ex.Message, ex) + End Try + getNewConnection = conn End Function '''----------------------------------------------------------------------------- @@ -94,9 +94,9 @@ Public Overrides Sub init(ByVal properties As System.Collections.Specialized.HybridDictionary) m_name = properties.Item("name") m_serverName = properties.Item("serverName") - m_host = properties.Item("host") - m_service = properties.Item("service") - m_user = properties.Item("user") + m_host = properties.Item("host") + m_service = properties.Item("service") + m_user = properties.Item("user") m_password = properties.Item("password") If properties.Item("ansinulls") Is Nothing Then UseANSINulls = False @@ -156,11 +156,11 @@ If dd = Date.MinValue Then tempRetorno = "NULL" Else - tempRetorno = "'" & dd.ToString("yyyy-MM-dd HH:mm:ss") & "'" - End If + tempRetorno = "'" & dd.ToString("yyyy-MM-dd HH:mm:ss") & "'" + End If - System.Threading.Thread.CurrentThread.CurrentCulture = OriginalCulture - System.Threading.Thread.CurrentThread.CurrentUICulture = OriginalCulture + 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 @@ -186,11 +186,11 @@ '''----------------------------------------------------------------------------- Public Overrides Function getNextOIDAvalue() As Integer Dim rs As New DataSet - Dim da As New IfxDataAdapter - Dim cb As IfxCommandBuilder + Dim da As New IfxDataAdapter + Dim cb As IfxCommandBuilder Dim aValue As Integer Dim row As System.Data.DataRow - Dim p As IfxParameter + Dim p As IfxParameter Dim initvals() As Object = {1} Dim x As OIDException Dim conn As CInformixConnection @@ -198,8 +198,8 @@ conn.AutoCommit = False conn.startTransaction() Try - da.SelectCommand = New IfxCommand("select oidAValue from " & Me.OIDTable, conn.Connection, conn.Transaction) - cb = New IfxCommandBuilder(da) + da.SelectCommand = New IfxCommand("select oidAValue from " & Me.OIDTable, conn.Connection, conn.Transaction) + cb = New IfxCommandBuilder(da) da.Fill(rs, "oid") If rs.Tables(0).Rows.Count = 0 Then 'Seed with value = 1 @@ -212,19 +212,19 @@ da.Update(rs, "oid") da.Dispose() conn.commit() - Catch err As IfxException - 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 + Catch err As IfxException + 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 '''----------------------------------------------------------------------------- @@ -243,8 +243,8 @@ '''----------------------------------------------------------------------------- Public Overrides Function getIdentityValue(ByVal conn As _CConnection) As Integer Dim rs As New DataSet - Dim da As New IfxDataAdapter - Dim cb As IfxCommandBuilder + Dim da As New IfxDataAdapter + Dim cb As IfxCommandBuilder Dim aValue As Integer Dim connection As CInformixConnection @@ -252,8 +252,8 @@ connection.AutoCommit = False Try - da.SelectCommand = New IfxCommand("select @@IDENTITY", connection.Connection, connection.Transaction) - cb = New IfxCommandBuilder(da) + da.SelectCommand = New IfxCommand("select @@IDENTITY", connection.Connection, connection.Transaction) + cb = New IfxCommandBuilder(da) da.Fill(rs, "identity") If rs.Tables(0).Rows.Count = 0 Then Throw New IdentityValueException("Could not retrieve identity value") @@ -266,10 +266,10 @@ Debug.WriteLine("Returned Identity value: " & aValue.ToString) End If da.Dispose() - Catch err As IfxException - Throw New IdentityValueException(err.Message, err) - End Try - Return aValue + Catch err As IfxException + Throw New IdentityValueException(err.Message, err) + End Try + Return aValue End Function '''----------------------------------------------------------------------------- @@ -278,7 +278,7 @@ ''' </summary> ''' <param name="i">The number of the parameter being added</param> ''' <returns>A string containing the SQL parameter placeholder</returns> - ''' <remarks>Since the parameter is for an Informix connection only a the returned + ''' <remarks>Since the parameter is for an Informix 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 Index: CInformixConnection.vb =================================================================== RCS file: /cvsroot/jcframework/dotnet/Providers/AF_Informix/CInformixConnection.vb,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- CInformixConnection.vb 7 Feb 2005 13:22:06 -0000 1.2 +++ CInformixConnection.vb 1 Apr 2005 00:04:31 -0000 1.3 @@ -31,15 +31,15 @@ Implements IDisposable '************************************************** - 'Class: CInformixConnection + 'Class: CInformixConnection 'Author: Richard Banks '************************************************** - Private m_connection As IfxConnection + Private m_connection As IfxConnection Private m_autoCommit As Boolean Private m_started As Boolean Private m_manageTransactions As Boolean - Private m_transaction As IfxTransaction + Private m_transaction As IfxTransaction Private m_transactioncalls As Integer Private m_references As Integer Private m_db As _CRelationalDatabase @@ -48,7 +48,7 @@ '''----------------------------------------------------------------------------- ''' <summary> - ''' The actual Informix Server connection for the object. + ''' The actual Informix Server connection for the object. ''' </summary> ''' <value></value> ''' <remarks></remarks> @@ -56,408 +56,409 @@ ''' [rbanks] 1/12/2003 Created ''' </history> '''----------------------------------------------------------------------------- - Public Property Connection() As IfxConnection - Get - Connection = m_connection - End Get - Set(ByVal Value As IfxConnection) - m_connection = Value - End Set - End Property + Public Property Connection() As IfxConnection + Get + Connection = m_connection + End Get + Set(ByVal Value As IfxConnection) + m_connection = Value + End Set + End Property - '''----------------------------------------------------------------------------- - ''' <summary> - ''' See <see cref="P:AToMSFramework._CConnection.AutoCommit">_CConnection</see>. - ''' </summary> - ''' <value></value> - ''' <remarks></remarks> - ''' <history> - ''' [rbanks] 1/12/2003 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.AutoCommit">_CConnection</see>. + ''' </summary> + ''' <value></value> + ''' <remarks></remarks> + ''' <history> + ''' [rbanks] 1/12/2003 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] 1/12/2003 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.Started">_CConnection</see>. + ''' </summary> + ''' <value></value> + ''' <remarks></remarks> + ''' <history> + ''' [rbanks] 1/12/2003 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] 1/12/2003 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="P:AToMSFramework._CConnection.ManageTransactions">_CConnection</see>. + ''' </summary> + ''' <value></value> + ''' <remarks></remarks> + ''' <history> + ''' [rbanks] 1/12/2003 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] 1/12/2003 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> + ''' See <see cref="M:AToMSFramework._CConnection.commit">_CConnection</see>. + ''' </summary> + ''' <remarks></remarks> + ''' <history> + ''' [rbanks] 1/12/2003 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] 1/12/2003 Created - ''' </history> - '''----------------------------------------------------------------------------- - Public ReadOnly Property Transaction() As IfxTransaction - Get - Transaction = m_transaction - End Get - End Property + '''----------------------------------------------------------------------------- + ''' <summary> + ''' The current transaction for the connection. + ''' </summary> + ''' <history> + ''' [rbanks] 1/12/2003 Created + ''' </history> + '''----------------------------------------------------------------------------- + Public ReadOnly Property Transaction() As IfxTransaction + Get + Transaction = m_transaction + End Get + End Property - '''----------------------------------------------------------------------------- - ''' <summary> - ''' See <see cref="M:AToMSFramework._CConnection.startTransaction">_CConnection</see>. - ''' </summary> - ''' <history> - ''' [rbanks] 1/12/2003 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 - getPersistenceBrokerInstance().startCacheTransaction(Me.Database) - End If - m_transactioncalls += 1 - Me.Started = True - End If - End Sub + '''----------------------------------------------------------------------------- + ''' <summary> + ''' See <see cref="M:AToMSFramework._CConnection.startTransaction">_CConnection</see>. + ''' </summary> + ''' <history> + ''' [rbanks] 1/12/2003 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 + m_transactioncalls += 1 + If Not Me.Started Then + Me.Started = True + m_transaction = m_connection.BeginTransaction + getPersistenceBrokerInstance().startCacheTransaction(Me.Database) + End If + End If + End Sub - '''----------------------------------------------------------------------------- - ''' <summary> - ''' See <see cref="M:AToMSFramework._CConnection.processStatement">_CConnection</see>. - ''' </summary> - ''' <param name="statement"></param> - ''' <remarks></remarks> - ''' <history> - ''' [rbanks] 1/12/2003 Created - ''' [rbanks] 23/01/2004 Changed to use SQL parameters - ''' </history> - '''----------------------------------------------------------------------------- - Public Sub processStatement(ByVal statement As CSqlStatement) Implements _CConnection.processStatement - Dim m_command As New IfxCommand - Dim m_recordcount As Integer - Dim cp As CSQLParameter - Dim param As IfxParameter - Dim dd As Date + '''----------------------------------------------------------------------------- + ''' <summary> + ''' See <see cref="M:AToMSFramework._CConnection.processStatement">_CConnection</see>. + ''' </summary> + ''' <param name="statement"></param> + ''' <remarks></remarks> + ''' <history> + ''' [rbanks] 1/12/2003 Created + ''' [rbanks] 23/01/2004 Changed to use SQL parameters + ''' </history> + '''----------------------------------------------------------------------------- + Public Sub processStatement(ByVal statement As CSqlStatement) Implements _CConnection.processStatement + Dim m_command As New IfxCommand + Dim m_recordcount As Integer + Dim cp As CSQLParameter + Dim param As IfxParameter + 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 IfxParameter - param.ParameterName = cp.Name - param.IfxType = CType(cp.Column.ProviderType, IfxType) - 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 IfxException - Throw err - Catch err As Exception - Throw err - End Try - End Sub + Try + m_command.Connection = m_connection + m_command.CommandText = statement.SqlString + For Each cp In statement.Parameters + If Not cp.Ignore Then + param = New IfxParameter + param.ParameterName = cp.Name + param.IfxType = CType(cp.Column.ProviderType, IfxType) + 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 IfxException + 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] 1/12/2003 Created - ''' </history> - '''----------------------------------------------------------------------------- - Public Function processSelectStatement(ByVal statement As CSqlStatement) As CResultset Implements _CConnection.processSelectStatement - SyncLock GetType(CInformixConnection) - Dim x As RetrieveException - Dim rs As New CResultset - Dim param As IfxParameter - Dim dd As Date - Dim m_command As New IfxCommand + '''----------------------------------------------------------------------------- + ''' <summary> + ''' See <see cref="M:AToMSFramework._CConnection.processSelectStatement">_CConnection</see>. + ''' </summary> + ''' <param name="statement"></param> + ''' <returns></returns> + ''' <remarks></remarks> + ''' <history> + ''' [rbanks] 1/12/2003 Created + ''' </history> + '''----------------------------------------------------------------------------- + Public Function processSelectStatement(ByVal statement As CSqlStatement) As CResultset Implements _CConnection.processSelectStatement + SyncLock GetType(CInformixConnection) + Dim x As RetrieveException + Dim rs As New CResultset + Dim param As IfxParameter + Dim dd As Date + Dim m_command As New IfxCommand - If DEBUG_MODE Then - System.Diagnostics.Debug.WriteLine(statement.SqlString) - End If + 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 IfxParameter - param.ParameterName = cp.Name - param.IfxType = CType(cp.Column.ProviderType, IfxType) - param.Value = cp.Value - m_command.Parameters.Add(param) - End If - Next + 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 IfxParameter + param.ParameterName = cp.Name + param.IfxType = CType(cp.Column.ProviderType, IfxType) + param.Value = cp.Value + m_command.Parameters.Add(param) + End If + Next - Try - Dim m_adapter As New IfxDataAdapter(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 IfxException - x = New RetrieveException("SQL 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 + Try + Dim m_adapter As New IfxDataAdapter(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 IfxException + x = New RetrieveException("SQL 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] 1/12/2003 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() - Catch ex As Exception - End Try - getPersistenceBrokerInstance().rollbackCache(Me.Database) - Me.Started = False - m_transaction = Nothing - End If - m_transactioncalls -= 1 - End If - End Sub + '''----------------------------------------------------------------------------- + ''' <summary> + ''' See <see cref="M:AToMSFramework._CConnection.rollback">_CConnection</see>. + ''' </summary> + ''' <remarks></remarks> + ''' <history> + ''' [rbanks] 1/12/2003 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 + m_transactioncalls -= 1 + If m_transactioncalls = 0 Then + Try + m_transaction.Rollback() + Me.Started = False + m_transaction = Nothing + Catch ex As Exception + Debug.WriteLine("rollback failed " & ex.Message) + End Try + getPersistenceBrokerInstance().rollbackCache(Me.Database) + End If + 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 + 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] 1/12/2003 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="M:AToMSFramework._CConnection.CloseConnection">_CConnection</see>. + ''' </summary> + ''' <remarks></remarks> + ''' <history> + ''' [rbanks] 1/12/2003 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] 1/12/2003 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.IsClosed">_CConnection</see>. + ''' </summary> + ''' <value></value> + ''' <remarks></remarks> + ''' <history> + ''' [rbanks] 1/12/2003 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] 1/12/2003 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.ReferenceCount">_CConnection</see>. + ''' </summary> + ''' <value></value> + ''' <remarks></remarks> + ''' <history> + ''' [rbanks] 1/12/2003 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] 1/12/2003 Created - ''' </history> - '''----------------------------------------------------------------------------- - Public Function getTableSchema(ByVal tName As String) As System.Data.DataTable Implements _CConnection.getTableSchema - Dim statement As String - Dim cmd As IfxCommand - Dim dr As IfxDataReader - Dim dt As DataTable + '''----------------------------------------------------------------------------- + ''' <summary> + ''' See <see cref="P:AToMSFramework._CConnection.getTableSchema">_CConnection</see>. + ''' </summary> + ''' <param name="tName"></param> + ''' <returns></returns> + ''' <remarks></remarks> + ''' <history> + ''' [rbanks] 1/12/2003 Created + ''' </history> + '''----------------------------------------------------------------------------- + Public Function getTableSchema(ByVal tName As String) As System.Data.DataTable Implements _CConnection.getTableSchema + Dim statement As String + Dim cmd As IfxCommand + Dim dr As IfxDataReader + Dim dt As DataTable - statement = "select * from " & tName - Try - cmd = New IfxCommand(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 + statement = "select * from " & tName + Try + cmd = New IfxCommand(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) - getPersistenceBrokerInstance().startCacheTransaction(Me.Database) - End If - m_transactioncalls += 1 - Me.Started = True - End If - End Sub + 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 + m_transactioncalls += 1 + If Not Me.Started Then + Me.Started = True + m_transaction = m_connection.BeginTransaction(isolationLevel) + getPersistenceBrokerInstance().startCacheTransaction(Me.Database) + End If + 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 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 + 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 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 + Protected Overrides Sub Finalize() + ' Simply call Dispose(False). + Dispose(False) + End Sub End Class |
From: Richard B. <rb...@us...> - 2005-04-01 00:05:15
|
Update of /cvsroot/jcframework/dotnet/Providers/AF_MSSQL In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18014/Providers/AF_MSSQL Modified Files: CMsSqlConnection.vb Log Message: Fixes for a number of issues with injected objects. Fixes for transactions when errors occur during the rollback, etc Fixes for removing event listeners from objects added to the cache to prevent multiple event firing. Index: CMsSqlConnection.vb =================================================================== RCS file: /cvsroot/jcframework/dotnet/Providers/AF_MSSQL/CMsSqlConnection.vb,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- CMsSqlConnection.vb 7 Feb 2005 07:37:36 -0000 1.1 +++ CMsSqlConnection.vb 1 Apr 2005 00:04:35 -0000 1.2 @@ -180,12 +180,12 @@ End If End If If Me.ManageTransactions Then + m_transactioncalls += 1 If Not Me.Started Then + Me.Started = True m_transaction = m_connection.BeginTransaction getPersistenceBrokerInstance().startCacheTransaction(Me.Database) End If - m_transactioncalls += 1 - Me.Started = True End If End Sub @@ -321,16 +321,17 @@ End If End If If Me.ManageTransactions Then - If m_transactioncalls = 1 Then + m_transactioncalls -= 1 + If m_transactioncalls = 0 Then Try m_transaction.Rollback() + Me.Started = False + m_transaction = Nothing Catch ex As Exception + Debug.WriteLine("rollback failed " & ex.Message) End Try getPersistenceBrokerInstance().rollbackCache(Me.Database) - Me.Started = False - m_transaction = Nothing End If - m_transactioncalls -= 1 End If End Sub @@ -432,12 +433,12 @@ End If End If If Me.ManageTransactions Then + m_transactioncalls += 1 If Not Me.Started Then + Me.Started = True m_transaction = m_connection.BeginTransaction(isolationLevel) getPersistenceBrokerInstance().startCacheTransaction(Me.Database) End If - m_transactioncalls += 1 - Me.Started = True End If End Sub |
From: Richard B. <rb...@us...> - 2005-04-01 00:05:13
|
Update of /cvsroot/jcframework/dotnet/Providers/AF_MSOracle In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18014/Providers/AF_MSOracle Modified Files: COracleConnection.vb Log Message: Fixes for a number of issues with injected objects. Fixes for transactions when errors occur during the rollback, etc Fixes for removing event listeners from objects added to the cache to prevent multiple event firing. Index: COracleConnection.vb =================================================================== RCS file: /cvsroot/jcframework/dotnet/Providers/AF_MSOracle/COracleConnection.vb,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- COracleConnection.vb 7 Feb 2005 07:37:36 -0000 1.1 +++ COracleConnection.vb 1 Apr 2005 00:04:34 -0000 1.2 @@ -175,12 +175,12 @@ End If End If If Me.ManageTransactions Then + m_transactioncalls += 1 If Not Me.Started Then + Me.Started = True m_transaction = m_connection.BeginTransaction getPersistenceBrokerInstance().startCacheTransaction(Me.Database) End If - m_transactioncalls += 1 - Me.Started = True End If End Sub @@ -297,16 +297,17 @@ End If End If If Me.ManageTransactions Then - If m_transactioncalls = 1 Then + m_transactioncalls -= 1 + If m_transactioncalls = 0 Then Try m_transaction.Rollback() + Me.Started = False + m_transaction = Nothing Catch ex As Exception + Debug.WriteLine("rollback failed " & ex.Message) End Try getPersistenceBrokerInstance().rollbackCache(Me.Database) - Me.Started = False - m_transaction = Nothing End If - m_transactioncalls -= 1 End If End Sub @@ -408,12 +409,12 @@ End If End If If Me.ManageTransactions Then + m_transactioncalls += 1 If Not Me.Started Then + Me.Started = True m_transaction = m_connection.BeginTransaction(isolationLevel) getPersistenceBrokerInstance().startCacheTransaction(Me.Database) End If - m_transactioncalls += 1 - Me.Started = True End If End Sub |
From: Richard B. <rb...@us...> - 2005-04-01 00:05:09
|
Update of /cvsroot/jcframework/dotnet/Providers/AF_Firebird In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18014/Providers/AF_Firebird Modified Files: CFirebirdConnection.vb Log Message: Fixes for a number of issues with injected objects. Fixes for transactions when errors occur during the rollback, etc Fixes for removing event listeners from objects added to the cache to prevent multiple event firing. Index: CFirebirdConnection.vb =================================================================== RCS file: /cvsroot/jcframework/dotnet/Providers/AF_Firebird/CFirebirdConnection.vb,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- CFirebirdConnection.vb 7 Feb 2005 23:29:48 -0000 1.1 +++ CFirebirdConnection.vb 1 Apr 2005 00:04:20 -0000 1.2 @@ -180,12 +180,12 @@ End If End If If Me.ManageTransactions Then + m_transactioncalls += 1 If Not Me.Started Then + Me.Started = True m_transaction = m_connection.BeginTransaction getPersistenceBrokerInstance().startCacheTransaction(Me.Database) End If - m_transactioncalls += 1 - Me.Started = True End If End Sub @@ -303,16 +303,17 @@ End If End If If Me.ManageTransactions Then - If m_transactioncalls = 1 Then + m_transactioncalls -= 1 + If m_transactioncalls = 0 Then Try m_transaction.Rollback() + Me.Started = False + m_transaction = Nothing Catch ex As Exception + Debug.WriteLine("rollback failed " & ex.Message) End Try getPersistenceBrokerInstance().rollbackCache(Me.Database) - Me.Started = False - m_transaction = Nothing End If - m_transactioncalls -= 1 End If End Sub @@ -414,12 +415,12 @@ End If End If If Me.ManageTransactions Then + m_transactioncalls += 1 If Not Me.Started Then + Me.Started = True m_transaction = m_connection.BeginTransaction(isolationLevel) getPersistenceBrokerInstance().startCacheTransaction(Me.Database) End If - m_transactioncalls += 1 - Me.Started = True End If End Sub |
From: Richard B. <rb...@us...> - 2005-04-01 00:04:49
|
Update of /cvsroot/jcframework/dotnet/Providers/AF_PostgreSQL In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18014/Providers/AF_PostgreSQL Modified Files: CPostgreSQLConnection.vb Log Message: Fixes for a number of issues with injected objects. Fixes for transactions when errors occur during the rollback, etc Fixes for removing event listeners from objects added to the cache to prevent multiple event firing. Index: CPostgreSQLConnection.vb =================================================================== RCS file: /cvsroot/jcframework/dotnet/Providers/AF_PostgreSQL/CPostgreSQLConnection.vb,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- CPostgreSQLConnection.vb 7 Feb 2005 23:09:32 -0000 1.1 +++ CPostgreSQLConnection.vb 1 Apr 2005 00:04:37 -0000 1.2 @@ -180,12 +180,12 @@ End If End If If Me.ManageTransactions Then + m_transactioncalls += 1 If Not Me.Started Then + Me.Started = True m_transaction = m_connection.BeginTransaction getPersistenceBrokerInstance().startCacheTransaction(Me.Database) End If - m_transactioncalls += 1 - Me.Started = True End If End Sub @@ -303,16 +303,17 @@ End If End If If Me.ManageTransactions Then - If m_transactioncalls = 1 Then + m_transactioncalls -= 1 + If m_transactioncalls = 0 Then Try m_transaction.Rollback() + Me.Started = False + m_transaction = Nothing Catch ex As Exception + Debug.WriteLine("rollback failed " & ex.Message) End Try getPersistenceBrokerInstance().rollbackCache(Me.Database) - Me.Started = False - m_transaction = Nothing End If - m_transactioncalls -= 1 End If End Sub |
From: Richard B. <rb...@us...> - 2005-04-01 00:00:51
|
Update of /cvsroot/jcframework/Nunit/InheritedClasses In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15894/InheritedClasses Modified Files: AtomsFrameworkTests.vb CEmployee.vb Log Message: Unit tests for caching and event listeners, and also for timestamps on interfaces. Index: CEmployee.vb =================================================================== RCS file: /cvsroot/jcframework/Nunit/InheritedClasses/CEmployee.vb,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- CEmployee.vb 16 Mar 2005 11:34:12 -0000 1.2 +++ CEmployee.vb 1 Apr 2005 00:00:10 -0000 1.3 @@ -15,6 +15,7 @@ Private WithEvents m_children As CPersistentCollection Private m_team As CTeam Private m_teamoid As String + Public Event NameChanged As EventHandler <AFColumn("name", Find:=True)> _ Public Property Name() As String @@ -24,6 +25,7 @@ Set(ByVal Value As String) m_name = Value SetDirtyFlag() + RaiseEvent NameChanged(Me, New System.EventArgs) End Set End Property Index: AtomsFrameworkTests.vb =================================================================== RCS file: /cvsroot/jcframework/Nunit/InheritedClasses/AtomsFrameworkTests.vb,v retrieving revision 1.15 retrieving revision 1.16 diff -u -d -r1.15 -r1.16 --- AtomsFrameworkTests.vb 3 Mar 2005 00:37:24 -0000 1.15 +++ AtomsFrameworkTests.vb 1 Apr 2005 00:00:10 -0000 1.16 @@ -593,5 +593,89 @@ Assert.IsTrue(emp.Persistent, "persistent check failed") End Sub + <Test()> Public Sub CheckEvents() + AddHandler emp.NameChanged, AddressOf NameChanged + eventcount = 0 + emp.Name = "Events" + Assert.AreEqual(1, eventcount) + emp.Find() + Assert.IsFalse(emp.Persistent) + emp.Save() + emp = New CEmployee + emp.Name = "Events" + emp.Find() + 'Should not have any events from the previous handler still firing + eventcount = 0 + emp.Name = "New Name 1" + Assert.AreEqual(0, eventcount) + AddHandler emp.NameChanged, AddressOf NameChanged + emp.Name = "New Name 2" + Assert.AreEqual(1, eventcount) + End Sub + + <Test()> Public Sub CheckEvents2() + AddHandler emp.NameChanged, AddressOf NameChanged + eventcount = 0 + emp.Name = "Events2" + Assert.AreEqual(1, eventcount) + emp.Find() + Assert.IsFalse(emp.Persistent) + emp.Save() + emp = New CEmployee + eventcount = 0 + AddHandler emp.NameChanged, AddressOf NameChanged + emp.Name = "Events2" + Assert.AreEqual(1, eventcount) + 'Should retain the event handlers + emp.Find() + emp.Name = "New Name 1" + Assert.AreEqual(2, eventcount) + End Sub + + <Test()> Public Sub CheckEvents3() + AddHandler emp.NameChanged, AddressOf NameChanged + eventcount = 0 + emp.Name = "Events3" + Assert.AreEqual(1, eventcount) + emp.Find() + Assert.IsFalse(emp.Persistent) + emp.Save() + pbroker.ClearCache() + emp = New CEmployee + eventcount = 0 + AddHandler emp.NameChanged, AddressOf NameChanged + emp.Name = "Events3" + Assert.AreEqual(1, eventcount) + 'Event should fire when property is set during retrieve + emp.Find() + Assert.AreEqual(2, eventcount) + 'Check event is still wired up after find completes + emp.Name = "Events3a" + Assert.AreEqual(3, eventcount) + End Sub + + <Test()> Public Sub CheckEvents4() + AddHandler emp.NameChanged, AddressOf NameChanged + eventcount = 0 + emp.Name = "Events4" + Assert.AreEqual(1, eventcount) + emp.Find() + Assert.IsFalse(emp.Persistent) + emp.Save() + emp = New CEmployee + emp.Name = "Events4" + emp.Find(emp) + 'Should not have any events from the previous handler still firing + eventcount = 0 + emp.Name = "Events4a" + Assert.AreEqual(0, eventcount) + AddHandler emp.NameChanged, AddressOf NameChanged + emp.Name = "Events4b" + Assert.AreEqual(1, eventcount) + End Sub + + Private Sub NameChanged(ByVal sender As Object, ByVal e As System.EventArgs) + eventcount += 1 + End Sub End Class End Namespace \ No newline at end of file |
From: Richard B. <rb...@us...> - 2005-04-01 00:00:22
|
Update of /cvsroot/jcframework/Nunit/StandardClasses In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15894/StandardClasses Modified Files: NonInheritedTests.vb Log Message: Unit tests for caching and event listeners, and also for timestamps on interfaces. Index: NonInheritedTests.vb =================================================================== RCS file: /cvsroot/jcframework/Nunit/StandardClasses/NonInheritedTests.vb,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- NonInheritedTests.vb 21 Mar 2005 08:06:15 -0000 1.8 +++ NonInheritedTests.vb 1 Apr 2005 00:00:11 -0000 1.9 @@ -39,25 +39,28 @@ <Test()> Public Sub LoadJob_a1() job.Id = "a1" - pbroker.GetObject(CType(job, NPJob)) + pbroker.GetObject(job) Assert.IsTrue(pbroker.getInjectedObject(job).Persistent) Assert.AreEqual("basic", job.Description) End Sub <Test()> Public Sub FindJob_basic() + pbroker.ClearCache() Dim job As New NPJob - job.Description = "basic" - pbroker.FindObject(CType(job, NPJob)) + 'NPJob has no find attributes so we set the key id + job.Id = "a1" + pbroker.FindObject(job) + Assert.IsTrue(pbroker.getInjectedObject(job).Persistent) Assert.AreEqual("basic", job.Description) End Sub <Test(), ExpectedException(GetType(System.Exception))> Public Sub CheckForError() - pbroker.StartTracking(job) + pbroker.GetObject(job) End Sub <Test()> Public Sub SaveJob_a2() job.Id = "a2" - pbroker.StartTracking(job) + pbroker.GetObject(job) job.Description = "SomeJob" Assert.IsTrue(pbroker.getInjectedObject(job).IsDirty) pbroker.PersistChanges(job) @@ -66,7 +69,7 @@ <Test()> Public Sub DeleteAJob() job.Id = "a3" - pbroker.StartTracking(job) + pbroker.GetObject(job) job.Description = "SomeJob3" pbroker.PersistChanges(job) pbroker.MarkForDeletion(job) @@ -77,16 +80,16 @@ <Test()> Public Sub CheckInjectionCache() Dim job2 As New NPJob Try - pbroker.StartTracking(job) + pbroker.GetObject(job) Catch End Try Assert.IsFalse(pbroker.ObjectIsTracked(job)) job.Id = "1" - pbroker.StartTracking(job) + pbroker.GetObject(job) job.Description = "a" Assert.IsTrue(pbroker.ObjectIsTracked(job)) job2.Id = "2" - pbroker.StartTracking(job2) + pbroker.GetObject(job2) job2.Description = "b" pbroker.PersistChanges(job) pbroker.PersistChanges(job2) @@ -96,8 +99,8 @@ Dim job2 As New NPJob job.Id = "3" job2.Id = "4" - pbroker.StartTracking(job) - pbroker.StartTracking(job2) + pbroker.GetObject(job) + pbroker.GetObject(job2) job.Description = "c" job2.Description = "d" Assert.IsFalse(pbroker.getInjectedObject(job).Persistent) @@ -198,7 +201,7 @@ Dim emp2 As New NPEmployee Dim emp3 As New NPEmployee emp.Name = "theBoss" - pbroker.StartTracking(emp) + pbroker.GetObject(emp) emp2.Name = "middleMgr" emp3.Name = "slave" emp.Workers.Add(emp2) @@ -220,7 +223,7 @@ Dim emp2 As New NPEmployee Dim emp3 As New NPEmployee emp.Name = "ABoss" - pbroker.StartTracking(emp) + pbroker.GetObject(emp) emp2.Name = "AManager" emp3.Name = "AWorker" emp.Workers.Add(emp2) |
From: Richard B. <rb...@us...> - 2005-04-01 00:00:21
|
Update of /cvsroot/jcframework/Nunit In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15894 Modified Files: AtomsFramework.xml Nunit_AtomsFramework.vbproj Log Message: Unit tests for caching and event listeners, and also for timestamps on interfaces. Index: Nunit_AtomsFramework.vbproj =================================================================== RCS file: /cvsroot/jcframework/Nunit/Nunit_AtomsFramework.vbproj,v retrieving revision 1.20 retrieving revision 1.21 diff -u -d -r1.20 -r1.21 --- Nunit_AtomsFramework.vbproj 22 Mar 2005 06:07:53 -0000 1.20 +++ Nunit_AtomsFramework.vbproj 1 Apr 2005 00:00:10 -0000 1.21 @@ -86,9 +86,9 @@ HintPath = "..\..\..\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.Windows.Forms.dll" /> <Reference - Name = "Atoms.Framework" - Project = "{8FFD05CF-E733-4D8E-BC0E-D9DD37B87384}" - Package = "{F184B08F-C81C-45F6-A57F-5ABD9991F28F}" + Name = "AToMSFramework" + AssemblyName = "AToMSFramework" + HintPath = "..\dotnet\bin\AToMSFramework.dll" /> </References> <Imports> Index: AtomsFramework.xml =================================================================== RCS file: /cvsroot/jcframework/Nunit/AtomsFramework.xml,v retrieving revision 1.20 retrieving revision 1.21 diff -u -d -r1.20 -r1.21 --- AtomsFramework.xml 22 Mar 2005 06:07:53 -0000 1.20 +++ AtomsFramework.xml 1 Apr 2005 00:00:09 -0000 1.21 @@ -367,7 +367,7 @@ </associationTable> </association> - <class name="IOptimistic" table="NPOptimistic" database="MSA" namespace="NunitTests.Interfaces"> + <class name="IOptimistic" table="NPOptimistic" database="MSA" namespace="NunitTests.Interfaces" factory="IOptimisticFactory"> <attribute name="GUIDValue" column="GuidValue" key="primary"/> <attribute name="Description" column="Description" /> <attribute name="CreatedDate" column="CreatedDate" timestamp="true" /> |
From: Richard B. <rb...@us...> - 2005-04-01 00:00:21
|
Update of /cvsroot/jcframework/Nunit/Interfaces In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15894/Interfaces Modified Files: ManyToManyTests.vb Added Files: IOptimistic.vb TimestampTests.vb Log Message: Unit tests for caching and event listeners, and also for timestamps on interfaces. --- NEW FILE: IOptimistic.vb --- Namespace Interfaces Public Interface IOptimistic Property GuidValue() As String Property Description() As String Property CreatedDate() As Date Property ModifiedDate() As Date End Interface Public Class COptimistic Implements IOptimistic Private m_guid As Guid = Guid.Empty Private m_description As String Private m_created As Date Private m_modified As Date Public Property Description() As String Implements IOptimistic.Description Get Return m_description End Get Set(ByVal Value As String) If Not String.Equals(m_description, Value) Then m_description = Value m_modified = Now End If End Set End Property Public Property GuidValue() As String Implements IOptimistic.GuidValue Get If m_guid.Equals(Guid.Empty) Then m_guid = Guid.NewGuid End If Return m_guid.ToString("N") End Get Set(ByVal value As String) m_guid = New Guid(value) End Set End Property Public Property CreatedDate() As Date Implements IOptimistic.CreatedDate Get Return m_created End Get Set(ByVal Value As Date) m_created = Value End Set End Property Public Property ModifiedDate() As Date Implements IOptimistic.ModifiedDate Get Return m_modified End Get Set(ByVal Value As Date) m_modified = Value End Set End Property Public Sub New() m_created = Now End Sub End Class Public Class IOptimisticFactory Implements AToMSFramework.IClassFactory Public Function CreateObject() As Object Implements AToMSFramework.IClassFactory.CreateObject Return New COptimistic End Function End Class End Namespace Index: ManyToManyTests.vb =================================================================== RCS file: /cvsroot/jcframework/Nunit/Interfaces/ManyToManyTests.vb,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- ManyToManyTests.vb 1 Mar 2005 20:51:33 -0000 1.2 +++ ManyToManyTests.vb 1 Apr 2005 00:00:10 -0000 1.3 @@ -37,7 +37,7 @@ Dim gval As String Dim x As Integer, y As Integer A = New M2MA - pbroker.StartTracking(A) + pbroker.GetObject(A) A.Description = "A-one" gval = A.GUIDValue B = New M2MB @@ -79,7 +79,7 @@ Dim gval As String Dim x As Integer, y As Integer A = New M2MA - pbroker.StartTracking(A) + pbroker.GetObject(A) A.Description = "A1" gval = A.GUIDValue B = New M2MB @@ -129,7 +129,7 @@ Dim gvalA, gvalB As String Dim s As String A = New M2MA - pbroker.StartTracking(A) + pbroker.GetObject(A) A.Description = "A1" gvalA = A.GUIDValue B = New M2MB @@ -149,7 +149,7 @@ Dim gvalA, gvalB As String Dim s As String A = New M2MA - pbroker.StartTracking(A) + pbroker.GetObject(A) A.Description = "A1" gvalA = A.GUIDValue B = New M2MB --- NEW FILE: TimestampTests.vb --- Imports AToMSFramework Imports NUnit.Framework Namespace Interfaces <TestFixture()> Public Class TimestampTests Private pbroker As CPersistenceBroker Private opt As IOptimistic <TestFixtureSetUp()> Public Sub Init() Environment.CurrentDirectory = System.AppDomain.CurrentDomain.BaseDirectory 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 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 <SetUp()> Public Sub TestInit() opt = New COptimistic End Sub <Test()> Public Sub SaveAndModify() Dim gVal As String gVal = opt.GuidValue pbroker.GetObject(opt) opt.Description = "a" pbroker.PersistChanges(opt) pbroker.ClearCache() opt = New COptimistic opt.GuidValue = gVal pbroker.GetObject(opt) Assert.AreEqual("a", opt.Description) opt.Description = "b" pbroker.PersistChanges(opt) End Sub End Class End Namespace |
From: Richard B. <rb...@us...> - 2005-03-31 23:11:31
|
Update of /cvsroot/jcframework/dotnet In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20546 Modified Files: userguide.sh5 Log Message: more updates Index: userguide.sh5 =================================================================== RCS file: /cvsroot/jcframework/dotnet/userguide.sh5,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 Binary files /tmp/cvs0T0CD4 and /tmp/cvsODXtkW differ |
From: Richard B. <rb...@us...> - 2005-03-28 22:07:52
|
Update of /cvsroot/jcframework/dotnet In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21462 Modified Files: userguide.sh5 Log Message: Udpate to help guide Index: userguide.sh5 =================================================================== RCS file: /cvsroot/jcframework/dotnet/userguide.sh5,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 Binary files /tmp/cvsqmmSTJ and /tmp/cvs8lxb7g differ |
From: Richard B. <rb...@us...> - 2005-03-25 06:49:22
|
Update of /cvsroot/jcframework/dotnet In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1788 Added Files: AtomsFramework.ndoc userguide.sh5 Log Message: Added user guide (skeleton only) and ndoc project file --- NEW FILE: AtomsFramework.ndoc --- <project SchemaVersion="1.3"> <assemblies> <assembly location="C:\Projects\MMM\Atoms_Framework\bin\AToMSFramework.dll" documentation="C:\Projects\MMM\Atoms_Framework\AToMSFramework.xml" /> </assemblies> <documenters> <documenter name="JavaDoc"> <property name="OutputDirectory" value=".\doc\" /> </documenter> <documenter name="LaTeX"> <property name="OutputDirectory" value=".\doc\" /> <property name="TextFileFullName" value="Documentation.tex" /> <property name="TexFileBaseName" value="Documentation" /> <property name="LatexCompiler" value="latex" /> <property name="TexFileFullPath" value=".\doc\Documentation.tex" /> </documenter> <documenter name="LinearHtml"> <property name="OutputDirectory" value=".\doc\" /> <property name="Title" value="An NDoc Documented Class Library" /> </documenter> <documenter name="MSDN"> <property name="OutputDirectory" value=".\doc\" /> <property name="HtmlHelpName" value="AtomsFramework" /> <property name="Title" value="AtomsFramework Persistence Layer Reference Guide" /> <property name="ShowVisualBasic" value="True" /> <property name="AssemblyVersionInfo" value="AssemblyVersion" /> <property name="UseNamespaceDocSummaries" value="True" /> </documenter> <documenter name="VS.NET 2003"> <property name="OutputDirectory" value=".\doc2\" /> <property name="HtmlHelpName" value="AtomsFramework Documentation" /> <property name="Title" value="AtomsFramework Documentation" /> <property name="CollectionNamespace" value="AtomsFramework" /> <property name="GenerateCollectionFiles" value="True" /> <property name="AssemblyVersionInfo" value="AssemblyVersion" /> </documenter> <documenter name="XML"> <property name="OutputFile" value=".\doc\doc.xml" /> </documenter> </documenters> </project> --- NEW FILE: userguide.sh5 --- (This appears to be a binary file; contents omitted.) |
From: Richard B. <rb...@us...> - 2005-03-22 06:19:23
|
Update of /cvsroot/jcframework/dotnet/Providers/AF_OLEDB In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24965/Providers/AF_OLEDB Modified Files: COleDbDatabase.vb Log Message: Changed default Ansi Null handling for Access and MSSQL databases Index: COleDbDatabase.vb =================================================================== RCS file: /cvsroot/jcframework/dotnet/Providers/AF_OLEDB/COleDbDatabase.vb,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- COleDbDatabase.vb 11 Mar 2005 04:40:56 -0000 1.2 +++ COleDbDatabase.vb 22 Mar 2005 06:19:15 -0000 1.3 @@ -57,7 +57,7 @@ m_user = properties.Item("user") m_password = properties.Item("password") If properties.Item("ansinulls") Is Nothing Then - UseANSINulls = False + UseANSINulls = True Else UseANSINulls = properties.Item("ansinulls") End If |
From: Richard B. <rb...@us...> - 2005-03-22 06:19:23
|
Update of /cvsroot/jcframework/dotnet/Providers/AF_MSSQL In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24965/Providers/AF_MSSQL Modified Files: CMsSqlDatabase.vb Log Message: Changed default Ansi Null handling for Access and MSSQL databases Index: CMsSqlDatabase.vb =================================================================== RCS file: /cvsroot/jcframework/dotnet/Providers/AF_MSSQL/CMsSqlDatabase.vb,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- CMsSqlDatabase.vb 7 Feb 2005 07:37:36 -0000 1.1 +++ CMsSqlDatabase.vb 22 Mar 2005 06:19:14 -0000 1.2 @@ -101,7 +101,7 @@ m_user = properties.Item("user") m_password = properties.Item("password") If properties.Item("ansinulls") Is Nothing Then - UseANSINulls = False + UseANSINulls = True Else UseANSINulls = properties.Item("ansinulls") End If |
Update of /cvsroot/jcframework/dotnet In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18481 Modified Files: CClassMap.vb CCursor.vb CInjectedObject.vb CPersistenceBroker.vb CPersistentObject.vb CSqlStatement.vb IPersistentObject.vb Log Message: Changes for timestamps on interface based persistence, plus a few other fixes Index: CPersistenceBroker.vb =================================================================== RCS file: /cvsroot/jcframework/dotnet/CPersistenceBroker.vb,v retrieving revision 1.101 retrieving revision 1.102 diff -u -d -r1.101 -r1.102 --- CPersistenceBroker.vb 21 Mar 2005 08:00:23 -0000 1.101 +++ CPersistenceBroker.vb 22 Mar 2005 06:09:11 -0000 1.102 @@ -441,6 +441,9 @@ cm2.populateObject(cm2, targetobj, rs, mapName) End If If targetobj.Persistent Then + If targetobj.IsIPersistentObject Then + StartTracking(targetobj) + End If tmpObj = m_cache.Item(targetobj) If Not (tmpObj Is Nothing) Then targetobj = tmpObj @@ -482,6 +485,9 @@ If Not targetobj Is Nothing AndAlso targetobj.Persistent Then tmpObj = m_cache.Item(targetobj) + If Not targetobj.IsIPersistentObject Then + StartTracking(targetobj) + End If If Not (tmpObj Is Nothing) Then targetobj = tmpObj Try @@ -517,7 +523,7 @@ If Not targetobj Is Nothing Then cm2.populateObject(cm2, targetobj, rs, mapName) If targetobj.Persistent Then - If TypeOf (targetobj) Is CInjectedObject Then + If Not targetobj.IsIPersistentObject Then StartTracking(targetobj) End If tmpObj = m_cache.Item(targetobj) @@ -587,6 +593,9 @@ classMapCount -= 1 'This is because we added one in the beginning of the for loop If Not targetobj Is Nothing AndAlso targetobj.Persistent Then tmpObj = m_cache.Item(targetobj) + If Not targetobj.IsIPersistentObject Then + StartTracking(targetobj) + End If If Not (tmpObj Is Nothing) Then targetobj = tmpObj Try @@ -639,7 +648,7 @@ rw = rs.ResultSet.Tables(0).Rows(i) toClass.populateObject(toClass, targetobj, rw, mapName) If targetobj.Persistent Then - If TypeOf (targetobj) Is CInjectedObject Then + If Not targetobj.IsIPersistentObject Then StartTracking(targetobj) End If tmpObj = m_cache.Item(targetobj) @@ -817,9 +826,9 @@ Value = udaMap.ToClass.CreateObjectInstance anObjPers = Value If udaMap.LazyLoad Then - cursor.loadProxy(anObjPers.GetSourceObject) + cursor.loadProxy(anObjPers) Else - cursor.loadObject(anObjPers.GetSourceObject) + cursor.loadObject(anObjPers) 'To prevent recursive associations causing problems we need to add the 'object to the cache here as a preliminary measure m_cache.Add(anObjPers) @@ -828,6 +837,9 @@ anObjPers.IsDirty = False 'After populating a new object anObjPers.OriginalCacheKey = New CCacheKey(anObjPers) col.Add(anObjPers.GetSourceObject) + If Not anObjPers.IsIPersistentObject Then + StartTracking(anObjPers) + End If m_cache.Add(anObjPers) 'Add retrieved objects to the cache Try PCCacheSize.RawValue = m_cache.Count @@ -956,8 +968,6 @@ clMap = obj.GetClassMap cm = clMap - 'Clear dirty flag so that recursion in the class structure doesn't cause an infinite loop - obj.IsDirty = False Debug.WriteLine("Saving object " & cm.Name) @@ -1013,13 +1023,15 @@ 'Need to reset the modified date to the new modified date after saving. 'If we don't do this the object won't get saved correctly on subsequent calls. - obj.ResetOriginalDates() + If obj.IsIPersistentObject Then + CType(obj, IPersistentObject).ResetOriginalDates() + End If obj.Persistent = True obj.State = PersistenceState.Persistent obj.IsDirty = False obj.IsQueued = False 'Update cache key in-case primary key fields have changed value - If Not obj.GetObjectType.IsSubclassOf(GetType(CPersistentObject)) Then + If Not obj.IsIPersistentObject Then If Not obj.OriginalCacheKey Is Nothing Then m_cache.Remove(obj.OriginalCacheKey) Try @@ -1208,7 +1220,7 @@ PCSQLHits.Increment() Catch End Try - If TypeOf (obj) Is CInjectedObject Then + If not obj.IsIPersistentObject Then m_objectsToDelete.Add(obj) End If conn.processStatement(statement) @@ -2874,7 +2886,6 @@ Public Function getInjectedObject(ByVal obj As Object) As CInjectedObject Return getInjectedObject(obj, False) - End Function Public Function getInjectedObject(ByVal obj As Object, ByVal createTemporary As Boolean) As CInjectedObject @@ -3320,10 +3331,10 @@ Return toColl End Function - Private Sub AddToQueue(ByVal obj As Object, ByRef queue As Queue) + Private Sub AddToQueue(ByVal obj As IPersistableObject, ByRef queue As Queue) Call AddToQueue(obj, queue, True) End Sub - Private Sub AddToQueue(ByVal obj As Object, ByRef queue As Queue, ByVal includeObject As Boolean) + Private Sub AddToQueue(ByVal obj As IPersistableObject, ByRef queue As Queue, ByVal includeObject As Boolean) 'Called recursively so that objects with superclasses are queued from the 'top most object down. Dim cm As CClassMap Index: IPersistentObject.vb =================================================================== RCS file: /cvsroot/jcframework/dotnet/IPersistentObject.vb,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -r1.11 -r1.12 --- IPersistentObject.vb 21 Mar 2005 08:00:25 -0000 1.11 +++ IPersistentObject.vb 22 Mar 2005 06:09:11 -0000 1.12 @@ -5,10 +5,6 @@ Property ExpiryInterval() As Double Property OIDValue() As String Property GUIDValue() As String - Property CreatedDate() As Date - Property ModifiedDate() As Date - ReadOnly Property OriginalCreatedDate() As Date - Property OriginalModifiedDate() As Date Property AssociationsLoaded() As Boolean Property IsLoading() As Boolean Property IsQueued() As Boolean @@ -33,15 +29,21 @@ Function Equals(ByVal obj As IPersistableObject) As Boolean Function Copy() As IPersistableObject Sub ReplaceWith(ByVal obj As IPersistableObject) - Sub ResetOriginalDates() Function GetObjectByClassMap(ByVal classMap As CClassMap) As IPersistableObject Function GetSourceObject() As Object Function HasValidKey() As Boolean + Function IsIPersistentObject() As Boolean End Interface Public Interface IPersistentObject Inherits IPersistableObject + Property CreatedDate() As Date + Property ModifiedDate() As Date + ReadOnly Property OriginalCreatedDate() As Date + Property OriginalModifiedDate() As Date + Sub ResetOriginalDates() + Function Retrieve() As Boolean Function Retrieve(ByRef obj As CPersistentObject) As Boolean Function Retrieve(ByRef obj As CPersistentObject, ByVal usecache As Boolean) As Boolean Index: CClassMap.vb =================================================================== RCS file: /cvsroot/jcframework/dotnet/CClassMap.vb,v retrieving revision 1.54 retrieving revision 1.55 diff -u -d -r1.54 -r1.55 --- CClassMap.vb 21 Mar 2005 08:00:22 -0000 1.54 +++ CClassMap.vb 22 Mar 2005 06:09:03 -0000 1.55 @@ -1319,7 +1319,11 @@ If Me.getAttributeMap(i).isTimeStamp Then paramCount += 1 m_updateStatement.addSqlClause(" " & RelationalDatabase.getClauseStringAnd & " " & Me.getAttributeMap(i).ColumnMap.getFullyQualifiedName & m_relationalDatabase.getClauseStringEqualTo("_" & paramCount.ToString & "_")) + If obj.IsIPersistentObject Then m_updateStatement.addSqlParameter(paramCount, obj.GetValueByAttribute("Original" & Me.getAttributeMap(i).Name), Me.getAttributeMap(i).ColumnMap) + Else + m_updateStatement.addSqlParameter(paramCount, CType(obj, CInjectedObject).getOriginalValueByAttribute(Me.getAttributeMap(i).Name), Me.getAttributeMap(i).ColumnMap) + End If End If Next i @@ -2198,4 +2202,8 @@ End While Return result End Function + + Protected Overrides Sub Finalize() + MyBase.Finalize() + End Sub End Class \ No newline at end of file Index: CCursor.vb =================================================================== RCS file: /cvsroot/jcframework/dotnet/CCursor.vb,v retrieving revision 1.15 retrieving revision 1.16 diff -u -d -r1.15 -r1.16 --- CCursor.vb 28 Feb 2005 23:07:44 -0000 1.15 +++ CCursor.vb 22 Mar 2005 06:09:03 -0000 1.16 @@ -216,6 +216,15 @@ End Set End Property + Public Sub loadObject(ByRef obj As Object) + If obj.GetType.IsSubclassOf(GetType(CPersistentObject)) Then + loadPersistentObject(obj) + Else + Dim injobj As IPersistableObject + injobj = getPersistenceBrokerInstance.getInjectedObject(obj) + loadObject(injobj) + End If + End Sub '''----------------------------------------------------------------------------- ''' <summary> @@ -235,63 +244,57 @@ ''' [rbanks] 4/12/2003 Created ''' </history> '''----------------------------------------------------------------------------- - Public Sub loadObject(ByRef obj As Object) - If obj.GetType.IsSubclassOf(GetType(CPersistentObject)) OrElse TypeOf (obj) Is CPersistentObject Then - loadPersistentObject(obj) + Public Sub loadObject(ByRef obj As IPersistableObject) + If Not obj.IsIPersistentObject Then + loadObject(CType(obj, CInjectedObject), 0) Else - loadObject(obj, 0) + loadPersistentObject(obj) End If End Sub - Public Sub loadObject(ByRef obj As Object, ByVal offset As Integer) - If obj.GetType.IsSubclassOf(GetType(CPersistentObject)) OrElse TypeOf (obj) Is CPersistentObject Then - loadPersistentObject(obj, offset) - Exit Sub - End If + Public Sub loadObject(ByRef obj As CInjectedObject, ByVal offset As Integer) Dim _alias As String = "" Dim mr As CMultiRetrieveCriteria Dim clMap As CClassMap Dim pbroker As CPersistenceBroker = modPersistenceBrokerSingleton.getPersistenceBrokerInstance - Dim injObj As CInjectedObject - injObj = pbroker.getInjectedObject(obj) If Not m_parentCriteria Is Nothing Then If m_parentCriteria.GetType Is GetType(CMultiRetrieveCriteria) Then mr = m_parentCriteria - _alias = mr.getObjectAlias(injObj, offset) - clMap = pbroker.getClassMap(obj.GetType) + _alias = mr.getObjectAlias(obj, offset) + clMap = pbroker.getClassMap(obj.GetObjectType) If Not m_holdsProxies Then - clMap.populateObject(clMap, injObj, m_row, _alias) + clMap.populateObject(clMap, obj, m_row, _alias) If clMap.AssociationMapCount > 0 Then - injObj.AssociationsLoaded = False + obj.AssociationsLoaded = False Else - injObj.AssociationsLoaded = True + obj.AssociationsLoaded = True End If - pbroker.InjectedObjects.Add(injObj) + pbroker.InjectedObjects.Add(obj) Else 'need to retrieve the proxy and then load the object - clMap.populateProxy(injObj, m_row, _alias) - pbroker.retrieveObject(injObj, False, True) - pbroker.InjectedObjects.Add(injObj) + clMap.populateProxy(obj, m_row, _alias) + pbroker.retrieveObject(obj, False, True) + pbroker.InjectedObjects.Add(obj) End If Exit Sub End If End If - clMap = pbroker.getClassMap(obj.GetType) + clMap = pbroker.getClassMap(obj.GetObjectType) If Not m_holdsProxies Then - clMap.populateObject(injObj, m_row) + clMap.populateObject(obj, m_row) If clMap.AssociationMapCount > 0 Then - injObj.AssociationsLoaded = False + obj.AssociationsLoaded = False Else - injObj.AssociationsLoaded = True + obj.AssociationsLoaded = True End If - pbroker.InjectedObjects.Add(injObj) + pbroker.InjectedObjects.Add(obj) Else 'need to retrieve the proxy and then load the object - clMap.populateProxy(injObj, m_row) - pbroker.retrieveObject(injObj, False, True) - pbroker.InjectedObjects.Add(injObj) + clMap.populateProxy(obj, m_row) + pbroker.retrieveObject(obj, False, True) + pbroker.InjectedObjects.Add(obj) End If End Sub @@ -443,37 +446,39 @@ ''' </history> '''----------------------------------------------------------------------------- Public Sub loadProxy(ByRef obj As Object) - If obj.GetType.IsSubclassOf(GetType(CPersistentObject)) OrElse TypeOf (obj) Is CPersistentObject Then + If obj.GetType.IsSubclassOf(GetType(CPersistentObject)) Then loadPersistentProxy(obj, 0) Else - loadProxy(obj, 0) + Dim injobj As IPersistableObject + injobj = getPersistenceBrokerInstance.getInjectedObject(obj) + loadProxy(injobj) End If End Sub - Public Sub loadProxy(ByRef obj As Object, ByVal offset As Integer) - If obj.GetType.IsSubclassOf(GetType(CPersistentObject)) OrElse TypeOf (obj) Is CPersistentObject Then - loadPersistentProxy(obj, offset) - Exit Sub + Public Sub loadProxy(ByRef obj As IPersistableObject) + If Not obj.IsIPersistentObject Then + loadProxy(obj, 0) + Else + loadPersistentProxy(obj, 0) End If - + End Sub + Public Sub loadProxy(ByRef obj As CInjectedObject, ByVal offset As Integer) Dim _alias As String = "" Dim cm As CMultiRetrieveCriteria Dim clMap As CClassMap Dim pbroker As CPersistenceBroker = modPersistenceBrokerSingleton.getPersistenceBrokerInstance - Dim injObj As CInjectedObject - injObj = pbroker.getInjectedObject(obj) If Not m_parentCriteria Is Nothing Then If m_parentCriteria.GetType Is GetType(CMultiRetrieveCriteria) Then cm = m_parentCriteria - _alias = cm.getObjectAlias(injObj, offset) - clMap = pbroker.getClassMap(obj.GetType) - clMap.populateProxy(injObj, m_row, _alias) + _alias = cm.getObjectAlias(obj, offset) + clMap = pbroker.getClassMap(obj.GetObjectType) + clMap.populateProxy(obj, m_row, _alias) Exit Sub End If End If - clMap = pbroker.getClassMap(obj.GetType) - clMap.populateProxy(injObj, m_row) + clMap = pbroker.getClassMap(obj.GetObjectType) + clMap.populateProxy(obj, m_row) End Sub Index: CInjectedObject.vb =================================================================== RCS file: /cvsroot/jcframework/dotnet/CInjectedObject.vb,v retrieving revision 1.19 retrieving revision 1.20 diff -u -d -r1.19 -r1.20 --- CInjectedObject.vb 21 Mar 2005 08:00:23 -0000 1.19 +++ CInjectedObject.vb 22 Mar 2005 06:09:11 -0000 1.20 @@ -12,9 +12,6 @@ Private m_originalObject As Object Private m_associationsLoaded As Boolean Private m_oid As COID - Private m_createdDate As Date 'Set when object is created - Private m_modifiedDate As Date 'Set when Dirty flag is set on persisted objects - Private m_originalModDate, m_blankDate As Date Private m_cacheExpiry As Double Private m_guid As Guid Private m_classmap As CClassMap @@ -61,7 +58,7 @@ Throw New Exception("Objects must be of the same type") End If Dim injObj As CInjectedObject - If TypeOf (obj) Is CInjectedObject Then + If Not obj.IsIPersistentObject Then injObj = CType(obj, CInjectedObject) ReplaceValues(injObj.m_object, m_object) Else @@ -175,15 +172,6 @@ End Set End Property - Public Property CreatedDate() As Date Implements IPersistableObject.CreatedDate - Get - Return m_createdDate - End Get - Set(ByVal Value As Date) - m_createdDate = Value - End Set - End Property - Public Property ExpiryInterval() As Double Implements IPersistableObject.ExpiryInterval Get Return m_cacheExpiry @@ -323,15 +311,6 @@ End Get End Property - Public Property ModifiedDate() As Date Implements IPersistableObject.ModifiedDate - Get - Return m_modifiedDate - End Get - Set(ByVal Value As Date) - m_modifiedDate = Value - End Set - End Property - Public Property OIDValue() As String Implements IPersistableObject.OIDValue Get Dim oidfactory As COIDFactory @@ -426,6 +405,10 @@ End Function Public Sub setAttributeValue(ByVal pName As String, ByRef Value As Object) Implements IPersistableObject.setAttributeValue + setAttributeValue(m_object, pName, Value) + End Sub + + Public Sub setAttributeValue(ByVal obj As Object, ByVal pName As String, ByRef Value As Object) If TypeOf (Value) Is System.DBNull Then Exit Sub End If @@ -436,9 +419,9 @@ Try If dotPos = -1 Then If TypeOf (Value) Is System.SByte Then - CallByName(m_object, pName, CallType.Set, IIf(Value.ToString = "1", True, False)) + CallByName(obj, pName, CallType.Set, IIf(Value.ToString = "1", True, False)) Else - CallByName(m_object, pName, CallType.Set, Value) + CallByName(obj, pName, CallType.Set, Value) End If Else Dim o As Object @@ -447,7 +430,7 @@ Dim val As ValueType objName = pName.Substring(0, dotPos) propertyName = pName.Substring(dotPos + 1) - o = CallByName(m_object, objName, CallType.Get) + o = CallByName(obj, objName, CallType.Get) If o Is Nothing Then Return End If @@ -458,7 +441,7 @@ Else CallByName(val, propertyName, CallType.Set, Value) End If - CallByName(m_object, objName, CallType.Set, val) + CallByName(obj, objName, CallType.Set, val) Else If TypeOf (Value) Is System.SByte Then CallByName(o, propertyName, CallType.Set, IIf(Value.ToString = "1", True, False)) @@ -505,10 +488,6 @@ Return injobj End Function - Friend Sub ResetOriginalDates() Implements IPersistableObject.ResetOriginalDates - m_originalModDate = m_modifiedDate - End Sub - Function getObjectByClassMap(ByVal classMap As CClassMap) As IPersistableObject Implements IPersistableObject.getObjectByClassMap Dim obj, Value As IPersistableObject Dim col As IList @@ -536,8 +515,10 @@ Next i 'set object's attributes + Dim AttrMap As CAttributeMap For i = 1 To CType(classMap.AttributeMaps.Count, Short) - obj.SetAttributeValue(classMap.getAttributeMap(i).Name, Me.getValueByAttribute(classMap.getAttributeMap(i).Name)) + AttrMap = classMap.getAttributeMap(i) + obj.SetAttributeValue(AttrMap.Name, Me.getValueByAttribute(AttrMap.Name)) Next 'if it has superclass add its attributes @@ -555,35 +536,17 @@ 'set superclass's attributes For i = 1 To CType(cm.AttributeMaps.Count, Short) - obj.SetAttributeValue(cm.getAttributeMap(i).Name, Me.getValueByAttribute(cm.getAttributeMap(i).Name)) + AttrMap = cm.getAttributeMap(i) + obj.SetAttributeValue(AttrMap.Name, Me.getValueByAttribute(AttrMap.Name)) Next cm = cm.SuperClass End While - 'copy the OriginalModifiedDate and the ModifiedDate from the child to the parent. - 'if we don't do this the object won't get saved correctly on subsequent calls. - obj.ModifiedDate = Me.ModifiedDate - obj.OriginalModifiedDate = Me.OriginalModifiedDate obj.IsDirty = Me.IsDirty Return obj End Function - Public Property OriginalModifiedDate() As Date Implements IPersistableObject.OriginalModifiedDate - Get - Return m_originalModDate - End Get - Set(ByVal Value As Date) - m_originalModDate = Value - End Set - End Property - - Public ReadOnly Property OriginalCreatedDate() As Date Implements IPersistableObject.OriginalCreatedDate - Get - Return m_createdDate - End Get - End Property - Public Overrides Function ToString() As String Dim s As String Dim i As Short @@ -743,5 +706,8 @@ End Try End Function + Public Function IsIPersistentObject() As Boolean Implements IPersistableObject.IsIPersistentObject + Return False + End Function End Class Index: CSqlStatement.vb =================================================================== RCS file: /cvsroot/jcframework/dotnet/CSqlStatement.vb,v retrieving revision 1.12 retrieving revision 1.13 diff -u -d -r1.12 -r1.13 --- CSqlStatement.vb 7 Feb 2005 07:37:35 -0000 1.12 +++ CSqlStatement.vb 22 Mar 2005 06:09:11 -0000 1.13 @@ -116,7 +116,7 @@ ''' [rbanks] 23/01/2004 Created ''' </history> '''----------------------------------------------------------------------------- - Public Sub addSqlParameter(ByVal i As Integer, ByRef obj As Object, ByRef c As CColumnMap) + Public Sub addSqlParameter(ByVal i As Integer, ByVal obj As Object, ByVal c As CColumnMap) Dim sp As New CSQLParameter Dim dd As DateTime Index: CPersistentObject.vb =================================================================== RCS file: /cvsroot/jcframework/dotnet/CPersistentObject.vb,v retrieving revision 1.59 retrieving revision 1.60 diff -u -d -r1.59 -r1.60 --- CPersistentObject.vb 21 Mar 2005 08:00:25 -0000 1.59 +++ CPersistentObject.vb 22 Mar 2005 06:09:11 -0000 1.60 @@ -413,7 +413,7 @@ ''' [rbanks] 25/11/2003 Created ''' </history> '''----------------------------------------------------------------------------- - <Browsable(False)> Public ReadOnly Property OriginalCreatedDate() As Date Implements IPersistableObject.OriginalCreatedDate + <Browsable(False)> Public ReadOnly Property OriginalCreatedDate() As Date Implements IPersistentObject.OriginalCreatedDate Get Return m_createdDate End Get @@ -1949,4 +1949,8 @@ Public Function GetSourceObject() As Object Implements IPersistableObject.GetSourceObject Return Me End Function + + Public Function IsIPersistentObject() As Boolean Implements IPersistableObject.IsIPersistentObject + Return True + End Function End Class |
From: Richard B. <rb...@us...> - 2005-03-22 06:08:08
|
Update of /cvsroot/jcframework/Nunit In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17680 Modified Files: AtomsFramework.xml Nunit_AtomsFramework.vbproj original db1.mdb Log Message: Unit test for timestamps on interface based persistence Index: Nunit_AtomsFramework.vbproj =================================================================== RCS file: /cvsroot/jcframework/Nunit/Nunit_AtomsFramework.vbproj,v retrieving revision 1.19 retrieving revision 1.20 diff -u -d -r1.19 -r1.20 --- Nunit_AtomsFramework.vbproj 1 Mar 2005 20:51:34 -0000 1.19 +++ Nunit_AtomsFramework.vbproj 22 Mar 2005 06:07:53 -0000 1.20 @@ -86,9 +86,9 @@ HintPath = "..\..\..\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.Windows.Forms.dll" /> <Reference - Name = "AToMSFramework" - AssemblyName = "AToMSFramework" - HintPath = "..\dotnet\bin\AToMSFramework.dll" + Name = "Atoms.Framework" + Project = "{8FFD05CF-E733-4D8E-BC0E-D9DD37B87384}" + Package = "{F184B08F-C81C-45F6-A57F-5ABD9991F28F}" /> </References> <Imports> @@ -215,6 +215,11 @@ BuildAction = "Compile" /> <File + RelPath = "Interfaces\IOptimistic.vb" + SubType = "Code" + BuildAction = "Compile" + /> + <File RelPath = "Interfaces\ManyToManyClasses.vb" SubType = "Code" BuildAction = "Compile" @@ -225,6 +230,11 @@ BuildAction = "Compile" /> <File + RelPath = "Interfaces\TimestampTests.vb" + SubType = "Code" + BuildAction = "Compile" + /> + <File RelPath = "Interfaces\ValidatedEmployee.vb" SubType = "Code" BuildAction = "Compile" Index: original db1.mdb =================================================================== RCS file: /cvsroot/jcframework/Nunit/original db1.mdb,v retrieving revision 1.13 retrieving revision 1.14 diff -u -d -r1.13 -r1.14 Binary files /tmp/cvs0YfS3H and /tmp/cvsO086Rb differ Index: AtomsFramework.xml =================================================================== RCS file: /cvsroot/jcframework/Nunit/AtomsFramework.xml,v retrieving revision 1.19 retrieving revision 1.20 diff -u -d -r1.19 -r1.20 --- AtomsFramework.xml 28 Feb 2005 23:05:47 -0000 1.19 +++ AtomsFramework.xml 22 Mar 2005 06:07:53 -0000 1.20 @@ -367,4 +367,12 @@ </associationTable> </association> + <class name="IOptimistic" table="NPOptimistic" database="MSA" namespace="NunitTests.Interfaces"> + <attribute name="GUIDValue" column="GuidValue" key="primary"/> + <attribute name="Description" column="Description" /> + <attribute name="CreatedDate" column="CreatedDate" timestamp="true" /> + <attribute name="ModifiedDate" column="ModifiedDate" timestamp="true" /> + </class> + + </map> \ No newline at end of file |
From: Richard B. <rb...@us...> - 2005-03-21 08:06:28
|
Update of /cvsroot/jcframework/Nunit/Interfaces In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12611/Interfaces Modified Files: ManyToManyClasses.vb Log Message: New unit tests. Index: ManyToManyClasses.vb =================================================================== RCS file: /cvsroot/jcframework/Nunit/Interfaces/ManyToManyClasses.vb,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- ManyToManyClasses.vb 1 Mar 2005 20:51:33 -0000 1.2 +++ ManyToManyClasses.vb 21 Mar 2005 08:06:14 -0000 1.3 @@ -21,7 +21,7 @@ Public Class M2MA Implements iM2MA - Private _guid As Guid + Private _guid As Guid = Guid.NewGuid Private _description As String Private _bCol As M2MBCollection @@ -63,7 +63,7 @@ Public Class M2MB Implements iM2MB - Private _guid As Guid + Private _guid As Guid = Guid.NewGuid Private _description As String Private _aCol As M2MACollection |
From: Richard B. <rb...@us...> - 2005-03-21 08:06:28
|
Update of /cvsroot/jcframework/Nunit/StandardClasses In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12611/StandardClasses Modified Files: LazyEmployee.vb NPEmployee.vb NonInheritedTests.vb Log Message: New unit tests. Index: NPEmployee.vb =================================================================== RCS file: /cvsroot/jcframework/Nunit/StandardClasses/NPEmployee.vb,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- NPEmployee.vb 25 Oct 2004 07:14:15 -0000 1.2 +++ NPEmployee.vb 21 Mar 2005 08:06:15 -0000 1.3 @@ -40,6 +40,10 @@ End Get Set(ByVal Value As String) m_parentname = Value + 'Clear the parent object if the name is cleared + If m_parentname = Nothing OrElse m_parentname = String.Empty Then + m_parent = Nothing + End If End Set End Property Index: NonInheritedTests.vb =================================================================== RCS file: /cvsroot/jcframework/Nunit/StandardClasses/NonInheritedTests.vb,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- NonInheritedTests.vb 1 Mar 2005 20:51:34 -0000 1.7 +++ NonInheritedTests.vb 21 Mar 2005 08:06:15 -0000 1.8 @@ -216,6 +216,35 @@ Assert.AreEqual("slave", emp2.Name) End Sub + <Test()> Public Sub RemoveFromCollection() + Dim emp2 As New NPEmployee + Dim emp3 As New NPEmployee + emp.Name = "ABoss" + pbroker.StartTracking(emp) + emp2.Name = "AManager" + emp3.Name = "AWorker" + emp.Workers.Add(emp2) + emp2.ReportsTo = emp + emp2.Workers.Add(emp3) + emp3.ReportsTo = emp2 + pbroker.PersistChanges(emp) + pbroker.ClearCache() + emp = New NPEmployee + emp.Name = "ABoss" + pbroker.FindObject(emp) + emp.Workers.Clear() 'Save auto is true so workers should be deleted + pbroker.PersistChanges(emp) + emp = New NPEmployee + emp.Name = "AManager" + pbroker.FindObject(emp) + Assert.IsTrue(pbroker.getInjectedObject(emp).Persistent, "AManager was deleted") + Assert.IsNull(emp.ReportsTo, "AManager's ReportsTo wasn't cleared") + emp = New NPEmployee + emp.Name = "AWorker" + pbroker.FindObject(emp) + Assert.IsTrue(pbroker.getInjectedObject(emp).Persistent, "AWorker was deleted") + End Sub + <Test()> Public Sub LazyLoadEmployees() Dim emp1 As New LazyEmployee emp1.Name = "aa" Index: LazyEmployee.vb =================================================================== RCS file: /cvsroot/jcframework/Nunit/StandardClasses/LazyEmployee.vb,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- LazyEmployee.vb 31 Oct 2004 23:08:36 -0000 1.1 +++ LazyEmployee.vb 21 Mar 2005 08:06:15 -0000 1.2 @@ -38,6 +38,10 @@ End Get Set(ByVal Value As String) m_parentname = Value + 'Clear the parent object if the name is cleared + If m_parentname = Nothing OrElse m_parentname = String.Empty Then + m_parent = Nothing + End If End Set End Property |
Update of /cvsroot/jcframework/dotnet In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12214 Modified Files: AToMSFramework.vbproj Removed Files: CMsAccessDatabase.vb CMsSqlDatabase.vb CMySqlDatabase.vb CODBCDatabase.vb COracleDatabase.vb CSqlStatementItem.vb Log Message: Removed old files. Made sure project file is up to date, Index: AToMSFramework.vbproj =================================================================== RCS file: /cvsroot/jcframework/dotnet/AToMSFramework.vbproj,v retrieving revision 1.24 retrieving revision 1.25 diff -u -d -r1.24 -r1.25 --- AToMSFramework.vbproj 11 Feb 2005 02:51:35 -0000 1.24 +++ AToMSFramework.vbproj 21 Mar 2005 08:05:08 -0000 1.25 @@ -289,6 +289,11 @@ BuildAction = "Compile" /> <File + RelPath = "CQueuedDelete.vb" + SubType = "Code" + BuildAction = "Compile" + /> + <File RelPath = "CRelationalDatabase.vb" SubType = "Code" BuildAction = "Compile" --- CSqlStatementItem.vb DELETED --- --- CMsSqlDatabase.vb DELETED --- --- COracleDatabase.vb DELETED --- --- CMySqlDatabase.vb DELETED --- --- CMsAccessDatabase.vb DELETED --- --- CODBCDatabase.vb DELETED --- |
From: Richard B. <rb...@us...> - 2005-03-21 08:00:59
|
Update of /cvsroot/jcframework/dotnet In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9538 Modified Files: AtomsFramework.xml CClassMap.vb CInjectedObject.vb CMultiSummaryCriteria.vb CPersistenceBroker.vb CPersistentObject.vb IPersistentObject.vb Added Files: CQueuedDelete.vb Log Message: Bug fixes for Many-to-many associations, and missing OriginalCreatedDate for CInjectedObject. Added support for auto clean up of associations when removing items, without having to manually delete objects. Index: CMultiSummaryCriteria.vb =================================================================== RCS file: /cvsroot/jcframework/dotnet/CMultiSummaryCriteria.vb,v retrieving revision 1.15 retrieving revision 1.16 diff -u -d -r1.15 -r1.16 --- CMultiSummaryCriteria.vb 16 Mar 2005 11:32:41 -0000 1.15 +++ CMultiSummaryCriteria.vb 21 Mar 2005 08:00:23 -0000 1.16 @@ -134,7 +134,6 @@ Public Sub New(ByVal obj As CPersistentObject) Me.New() - ' m_objectsToJoin.Add(obj) Me.addObjectToJoin(obj, Nothing, "") Me.ClassMap = obj.getClassMap(obj) End Sub @@ -268,7 +267,8 @@ strName = myArrayStrings(i) udaMap = clMap.AssociationMaps(strName) If udaMap Is Nothing Then - Throw New AToMSFramework.RetrieveException("Could not find association named " & strName & " for class " & clMap.Name) + Throw New AToMSFramework.RetrieveException("Could not find association named " & strName & " for class " & clMap.Name) + End If clMap = udaMap.ToClass If clMap Is Nothing Then Index: CPersistenceBroker.vb =================================================================== RCS file: /cvsroot/jcframework/dotnet/CPersistenceBroker.vb,v retrieving revision 1.100 retrieving revision 1.101 diff -u -d -r1.100 -r1.101 --- CPersistenceBroker.vb 16 Mar 2005 11:32:42 -0000 1.100 +++ CPersistenceBroker.vb 21 Mar 2005 08:00:23 -0000 1.101 @@ -637,7 +637,7 @@ Else targetobj = toClass.CreateObjectInstance rw = rs.ResultSet.Tables(0).Rows(i) - cm2.populateObject(cm2, targetobj, rw, mapName) + toClass.populateObject(toClass, targetobj, rw, mapName) If targetobj.Persistent Then If TypeOf (targetobj) Is CInjectedObject Then StartTracking(targetobj) @@ -2563,6 +2563,7 @@ Dim tmpObj As Object Dim aObj As CAssociationObject Dim isNewManyToMany As Boolean + Dim qd As CQueuedDelete If obj.IsQueued Then 'if an object has already been added to the save queue, there is no need to add @@ -2606,9 +2607,7 @@ If includeBaseObject AndAlso _ (obj.IsDirty AndAlso Not obj.IsProxy AndAlso Not obj.IsReadOnly AndAlso Not obj.IsModifyOnly) Then 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 AddToQueue(obj, queue) End If Else @@ -2646,6 +2645,30 @@ Next Next k End If + 'Now go through and find out which objects have been removed from the collection + 'and attempt to modify and/or delete them. + For Each value In obj.GetRemovedCollectionItems(udamap.FromClassTarget) + If udamap.DeleteAutomatic = True Then + 'Delete the object + qd = New CQueuedDelete + qd.ObjectToDelete = value + queue.Enqueue(qd) + Else + For Each e As CUDAMapEntry In udamap.Entries + 'Try to set to nothing first. If it fails set the value to NULL alias value + 'Need to do a get first so we know what type to alias + Try + value.SetAttributeValue(e.ToAttrMap.Name, Nothing) + Catch ex As Exception + tmpObj = value.GetValueByAttribute(e.ToAttrMap.Name) + modAliasNull.NullToAlias(DBNull.Value, tmpObj) + value.SetAttributeValue(e.ToAttrMap.Name, tmpObj) + End Try + Next + 'Now add object to list to be saved + queue.Enqueue(value) + End If + Next ElseIf udamap.Cardinality = CUDAMap.CardinalityEnum.MANY_TO_MANY Then If obj.GetClassMap.Name = udamap.FromClass.Name Then col = obj.GetCollectionByAttribute(udamap.FromClassTarget) @@ -2706,7 +2729,7 @@ ''' </history> ''' ----------------------------------------------------------------------------- Function getObjectsToSave(ByVal obj As CPersistentObject) As Queue - Return getObjectsToSave(obj, True, False) + Return getObjectsToSave(obj, True, True) End Function ''' ----------------------------------------------------------------------------- @@ -2850,7 +2873,8 @@ End Sub Public Function getInjectedObject(ByVal obj As Object) As CInjectedObject - Return getInjectedObject(obj, False) + Return getInjectedObject(obj, False) + End Function Public Function getInjectedObject(ByVal obj As Object, ByVal createTemporary As Boolean) As CInjectedObject @@ -2863,7 +2887,7 @@ 'recursively referencing each other we need to add the objects to the cache 'in order to prevent nested recursion. This temporary addition is only 'used in getObjectsToSave - m_injectedObjects.AddTemp(injObj, True) + m_injectedObjects.AddTemp(injObj, True) End If End If Return injObj @@ -2930,13 +2954,13 @@ For Each de As DictionaryEntry In objectsToPersist injObj = de.Value If Not injObj.MarkedForDeletion Then - PersistChanges(injObj.ReferencedObject) + PersistChanges(injObj.ReferencedObject, checkAssociationsRecursively) End If Next For Each de As DictionaryEntry In objectsToPersist injObj = de.Value If injObj.MarkedForDeletion And injObj.Persistent Then - PersistChanges(injObj.ReferencedObject) + PersistChanges(injObj.ReferencedObject, checkAssociationsRecursively) End If Next m_inPersistChangesLoop = False @@ -2959,9 +2983,9 @@ Public Sub PersistChanges(ByVal obj As Object, ByVal checkAssociationsRecursively As Boolean) Dim value As IPersistableObject - Dim queue As Queue + Dim queue As queue Dim qObject As Object - Dim injObj As CInjectedObject + Dim injObj, tmpObj As CInjectedObject Dim ckey As CCacheKey Dim savedKeys As New ArrayList @@ -2987,6 +3011,17 @@ Try If GetType(CAssociationObject).IsInstanceOfType(qObject) Then saveAssociationObject(qObject) + ElseIf GetType(CQueuedDelete).IsInstanceOfType(qObject) Then + Try + tmpObj = CType(qObject, CQueuedDelete).ObjectToDelete + deleteObject(tmpObj, tmpObj.WillDeleteParents) + If Not m_inPersistChangesLoop Then + m_injectedObjects.Remove(tmpObj) + End If + Catch ex As Exception + Debug.WriteLine("(QueuedDelete) Tried to delete an object that was already deleted") + Debug.WriteLine(ex.Message) + End Try Else value = qObject ckey = New CCacheKey(value) @@ -2995,6 +3030,8 @@ Debug.WriteLine("The object with key " & ckey.ToString & " was already saved once") Else saveObject(value) + 'Recopy one-to-many collections incase object is resaved later + value.CopyOneToManyCollections() 'Recalculate key value - required when identity columns are used ckey = New CCacheKey(value) savedKeys.Add(ckey) @@ -3014,7 +3051,7 @@ End If End If If Not m_inPersistChangesLoop Then - m_injectedObjects.CleanUp() + m_injectedObjects.CleanUp() End If End Sub @@ -3220,6 +3257,69 @@ Next End Sub + ''' ----------------------------------------------------------------------------- + ''' <summary> + ''' Makes a copy of a collection as referenced by the propertyname parameter + ''' </summary> + ''' <param name="fromObject">The object to copy from</param> + ''' <param name="propertyName">The property of the from object to copy</param> + ''' <returns>A collection.</returns> + ''' <remarks>Event handlers not copied. + ''' </remarks> + ''' <history> + ''' [rbanks] 21/03/2005 Created + ''' </history> + ''' ----------------------------------------------------------------------------- + Friend Shared Function CopyCollection(ByVal fromObject As IPersistableObject, ByVal propertyName As String) As Object + Dim t, iListType, iDicType As Type + Dim fromColl, toColl, collItem As Object + Dim il As IList + Dim id As IDictionary + Dim p As PropertyInfo + Dim tmpObj As Object + + fromColl = fromObject.GetCollectionByAttribute(propertyName) + If fromColl Is Nothing Then + Return Nothing + End If + + p = fromObject.GetObjectType.GetProperty(propertyName, BindingFlags.Instance Or BindingFlags.NonPublic Or BindingFlags.Public) + iListType = p.PropertyType.GetInterface("IList", True) + iDicType = p.PropertyType.GetInterface("IDictionary", True) + If Not iListType Is Nothing OrElse Not iDicType Is Nothing Then + Dim ICloneType As Type = p.PropertyType.GetInterface("ICloneable", True) + If Not ICloneType Is Nothing Then + 'Getting the ICloneable interface from the object. + tmpObj = p.GetValue(fromObject.GetSourceObject, Nothing) + If Not tmpObj Is Nothing Then + Dim IClone As ICloneable = CType(tmpObj, ICloneable) + toColl = IClone.Clone() + Else + toColl = Nothing + End If + Return toColl + Else + 'If the field doesn't support the ICloneable interface then just set it. + 'need to copy collection members one by one + t = p.PropertyType + toColl = Activator.CreateInstance(t) + Dim fColl, fieldsColl() As FieldInfo + If Not iListType Is Nothing Then + il = CType(toColl, IList) + For Each collItem In fromColl + il.Add(collItem) + Next + Else + id = CType(toColl, IDictionary) + For Each de As DictionaryEntry In fromColl + id.Add(de.Key, de.Value) + Next + End If + End If + End If + Return toColl + End Function + Private Sub AddToQueue(ByVal obj As Object, ByRef queue As Queue) Call AddToQueue(obj, queue, True) End Sub Index: IPersistentObject.vb =================================================================== RCS file: /cvsroot/jcframework/dotnet/IPersistentObject.vb,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- IPersistentObject.vb 3 Mar 2005 00:38:24 -0000 1.10 +++ IPersistentObject.vb 21 Mar 2005 08:00:25 -0000 1.11 @@ -7,6 +7,7 @@ Property GUIDValue() As String Property CreatedDate() As Date Property ModifiedDate() As Date + ReadOnly Property OriginalCreatedDate() As Date Property OriginalModifiedDate() As Date Property AssociationsLoaded() As Boolean Property IsLoading() As Boolean @@ -25,6 +26,9 @@ Function GetValueByAttribute(ByVal pName As String) As Object Sub SetAttributeValue(ByVal pName As String, ByRef Value As Object) + Function GetRemovedCollectionItems(ByVal propertyName As String) As Collection + Sub CopyOneToManyCollections() + Function GetObjectType() As Type Function Equals(ByVal obj As IPersistableObject) As Boolean Function Copy() As IPersistableObject Index: CClassMap.vb =================================================================== RCS file: /cvsroot/jcframework/dotnet/CClassMap.vb,v retrieving revision 1.53 retrieving revision 1.54 diff -u -d -r1.53 -r1.54 --- CClassMap.vb 11 Mar 2005 04:40:55 -0000 1.53 +++ CClassMap.vb 21 Mar 2005 08:00:22 -0000 1.54 @@ -1869,7 +1869,7 @@ classMapCount += 1 mapName = "t" & classMapCount.ToString If udamap.Cardinality = CUDAMap.CardinalityEnum.MANY_TO_MANY AndAlso Me.Name <> udamap.FromClass.Name Then - rMaps.Add(mapName, udamap.ToClass) + rMaps.Add(mapName, udamap.FromClass) m_joinSet = New CJoin(m_joinSet, udamap.FromClass, mapName, udamap) pbroker.createJoinForMultipleInheritance(udamap.FromClass, classMapCount, m_joinSet, rMaps) Else @@ -1996,11 +1996,17 @@ If udamap.RetrieveAutomatic Then classMapCount += 1 mapName = "t" & classMapCount.ToString + If udamap.Cardinality = CUDAMap.CardinalityEnum.MANY_TO_MANY AndAlso Me.Name <> udamap.FromClass.Name Then + rMaps.Add(mapName, udamap.FromClass) + m_joinSet = New CJoin(m_joinSet, udamap.FromClass, mapName, udamap) + pbroker.createJoinForMultipleInheritance(udamap.FromClass, classMapCount, m_joinSet, rMaps) + Else rMaps.Add(mapName, udamap.ToClass) m_joinSet = New CJoin(m_joinSet, udamap.ToClass, mapName, udamap) 'Add joins for multiple inheritance pbroker.createJoinForMultipleInheritance(udamap.ToClass, classMapCount, m_joinSet, rMaps) End If + End If Next 'Now build the SQL statement --- NEW FILE: CQueuedDelete.vb --- ''' ----------------------------------------------------------------------------- ''' <summary> ''' Class used for adding an object to delete to the queue of objects to save ''' </summary> ''' <remarks> ''' Specifically used for automatic clean up of one-to-many associations and ''' created during the GetObjectsToSave method. ''' </remarks> ''' <history> ''' [rbanks] 21/03/2005 Created ''' </history> ''' ----------------------------------------------------------------------------- Friend Class CQueuedDelete Private m_object As IPersistableObject Public Property ObjectToDelete() As IPersistableObject Get Return m_object End Get Set(ByVal Value As IPersistableObject) m_object = Value End Set End Property End Class Index: AtomsFramework.xml =================================================================== RCS file: /cvsroot/jcframework/dotnet/AtomsFramework.xml,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- AtomsFramework.xml 6 Feb 2005 02:44:00 -0000 1.9 +++ AtomsFramework.xml 21 Mar 2005 08:00:15 -0000 1.10 @@ -1,7258 +1,6601 @@ -<?xml version="1.0"?> -<doc> - <assembly> - <name>AToMSFramework</name> - <version>2.1.0.0</version> - <fullname>AToMSFramework, Version=2.1.0.0, Culture=neutral, PublicKeyToken=e5c3a6c915b93944</fullname> - </assembly> - <members> - <member name="T:AToMSFramework.AFTableAttribute"> - <summary> - Custom attribute to define table mappings for a class [...13828 lines suppressed...] + <history> + [rbanks] 18/12/2003 Created + </history></member><member name="T:AToMSFramework.modOIDFactorySingleton"><summary> + Module for managing the ObjectID Factory singleton object + </summary> + <remarks>Manages the references to the singleton <see cref="T:AToMSFramework.COIDFactory" /> object.</remarks> + <history> + [rbanks] 18/12/2003 Created + </history></member><member name="M:AToMSFramework.modOIDFactorySingleton.getOIDFactoryInstance"><summary> + Gets a reference to the COIDFactory instance. + </summary> + <returns>A reference to the COIDFactory object.</returns> + <remarks>If the <see cref="M:AToMSFramework.modOIDFactorySingleton.getOIDFactoryInstance" /> instance does not yet + exist it is created.</remarks> + <history> + [rbanks] 18/12/2003 Created + </history></member></para></remarks></member> + </members> </doc> \ No newline at end of file Index: CInjectedObject.vb =================================================================== RCS file: /cvsroot/jcframework/dotnet/CInjectedObject.vb,v retrieving revision 1.18 retrieving revision 1.19 diff -u -d -r1.18 -r1.19 --- CInjectedObject.vb 17 Mar 2005 06:14:36 -0000 1.18 +++ CInjectedObject.vb 21 Mar 2005 08:00:23 -0000 1.19 @@ -26,6 +26,7 @@ Private m_proxy As Boolean Private m_markedForDeletion As Boolean Private m_deleteParents As Boolean + Private m_oneToManyCollections As New Collection Public Sub New(ByVal obj As Object) MyBase.New() @@ -76,7 +77,8 @@ End If Dim f, fields() As FieldInfo Dim value As Object - Dim t, iListType, iDicType As Type Try + Dim t, iListType, iDicType As Type + Try t = sourceObject.GetType While Not t Is Nothing fields = t.GetFields(BindingFlags.Instance Or BindingFlags.NonPublic Or BindingFlags.Public) @@ -96,7 +98,8 @@ t = Nothing End If End While - CPersistenceBroker.CopyCollections(sourceObject, targetObject) Catch ex As Exception + CPersistenceBroker.CopyCollections(sourceObject, targetObject) + Catch ex As Exception Debug.WriteLine(ex.Message) End Try End Sub @@ -104,65 +107,13 @@ Public Function getClassMap() As CClassMap Implements IPersistableObject.getClassMap Dim tmpCMap As CClassMap If m_classmap Is Nothing Then - 'm_classmap = getClassMap(TypeName(m_object), m_object.GetType.FullName) - 'If m_classmap Is Nothing Then - Dim persistenceBroker As CPersistenceBroker - persistenceBroker = getPersistenceBrokerInstance() - m_classmap = persistenceBroker.getClassMap(m_object.GetType) - - ''try to find an interface that is mapped - first mapped interface we find will be used - 'Dim intType, tmpType, interfaces() As Type - 'interfaces = m_object.GetType.GetInterfaces - - ''----------------------------------------- - '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 - ' m_classmap = getClassMap(interfaces(n).Name, interfaces(n).FullName) - ' If (Not m_classmap Is Nothing) AndAlso m_classmap.SuperClass Is Nothing Then - ' super = m_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 - ' m_classmap = super - ' For m = n To interfaces.Length - 2 - ' interfaces(m) = interfaces(m + 1) - ' Next - ' interfaces(m) = Nothing - - ' If interfaces(0) Is Nothing Then - ' m_classmap = tmpCMap - ' Exit While - ' End If - ' n = 0 - ' Else - ' n = n + 1 - ' End If - ' Else - ' n = n + 1 - ' End If - 'End While - End If - If (m_classmap Is Nothing) Then - Throw New NoClassMapException("No class map for " & m_object.GetType.FullName) - End If - 'End If + Dim persistenceBroker As CPersistenceBroker + persistenceBroker = getPersistenceBrokerInstance() + m_classmap = persistenceBroker.getClassMap(m_object.GetType) + End If + If (m_classmap Is Nothing) Then + Throw New NoClassMapException("No class map for " & m_object.GetType.FullName) + End If Return m_classmap End Function @@ -188,18 +139,18 @@ Return m_object.GetType End Function - Public Function getValueByAttribute(ByVal pName As String) As Object Implements IPersistableObject.getValueByAttribute + Public Function getValueByAttribute(ByVal obj As Object, ByVal pName As String) As Object Dim dotPos As Integer dotPos = pName.IndexOf(".") If dotPos = -1 Then - Return CallByName(m_object, pName, CallType.Get) + Return CallByName(obj, pName, CallType.Get) Else Dim o As Object Dim objName As String Dim propertyName As String objName = pName.Substring(0, dotPos) propertyName = pName.Substring(dotPos + 1) - o = CallByName(m_object, objName, CallType.Get) + o = CallByName(obj, objName, CallType.Get) If o Is Nothing Then Return Nothing End If @@ -207,23 +158,12 @@ End If End Function + Public Function getValueByAttribute(ByVal pName As String) As Object Implements IPersistableObject.getValueByAttribute + Return getValueByAttribute(m_object, pName) + End Function + Public Function getOriginalValueByAttribute(ByVal pName As String) As Object - Dim dotPos As Integer - dotPos = pName.IndexOf(".") - If dotPos = -1 Then - Return CallByName(m_originalObject, pName, CallType.Get) - Else - Dim o As Object - Dim objName As String - Dim propertyName As String - objName = pName.Substring(0, dotPos) - propertyName = pName.Substring(dotPos + 1) - o = CallByName(m_originalObject, objName, CallType.Get) - If o Is Nothing Then - Return Nothing - End If - Return CallByName(o, propertyName, CallType.Get) - End If + Return getValueByAttribute(m_originalObject, pName) End Function Public Property AssociationsLoaded() As Boolean Implements IPersistableObject.AssociationsLoaded @@ -292,7 +232,6 @@ End Property Public Function ObjectsMatch(ByVal sourceObject As Object, ByVal targetObject As Object) As Boolean - 'Use reflection to compare all of the fields from sourceObj to targetobject (by value) If sourceObject Is Nothing AndAlso targetObject Is Nothing Then Return True If sourceObject Is Nothing OrElse targetObject Is Nothing Then Return False If Not sourceObject.GetType Is targetObject.GetType Then @@ -310,10 +249,10 @@ While Not cmap Is Nothing For Each att As CAttributeMap In cmap.AttributeMaps If Not att.ColumnMap Is Nothing Then - value = getValueByAttribute(att.Name) - value1 = getOriginalValueByAttribute(att.Name) + value = getValueByAttribute(sourceObject, att.Name) + value1 = getValueByAttribute(targetObject, att.Name) If Not Equals(value, value1) Then - Return True + Return False End If End If Next @@ -323,38 +262,13 @@ cmap = Nothing End If End While - Return False + Return True - 'Dim f, fields() As FieldInfo - 'Dim t As Type - 'Try - ' t = sourceObject.GetType - ' While Not t Is Nothing - ' fields = t.GetFields(BindingFlags.Instance Or BindingFlags.NonPublic Or BindingFlags.Public) - ' 'Note that this will copy event handlers as well - ' For Each f In fields - ' value = f.GetValue(sourceObject) - ' value1 = f.GetValue(targetObject) - ' If Not Equals(value, value1) Then - ' Return True - ' End If - ' Next - ' If Not t.BaseType Is Nothing Then - ' t = t.BaseType - ' Else - ' t = Nothing - ' End If - ' End While - 'Catch ex As Exception - ' Debug.WriteLine(ex.Message) - ' Return False - 'End Try - 'Return False End Function Public Property IsDirty() As Boolean Implements IPersistableObject.IsDirty Get - Return ObjectsMatch(m_object, m_originalObject) + Return Not ObjectsMatch(m_object, m_originalObject) End Get Set(ByVal Value As Boolean) 'For injected objects this should only be called from the persistence broker and @@ -372,6 +286,9 @@ Return m_loading End Get Set(ByVal Value As Boolean) + If m_loading <> Value AndAlso Value = False Then + CopyOneToManyCollections() + End If m_loading = Value End Set End Property @@ -502,8 +419,8 @@ pbroker = getPersistenceBrokerInstance() injobj = pbroker.getInjectedObject(obj) End If - Catch err As Exception - Throw New Exception("getObjectByAttribute failed for attribute " & pName & " in " & m_object.GetType.FullName, err) + Catch ex As Exception + Throw New Exception("getObjectByAttribute failed for attribute " & pName & " in " & m_object.GetType.FullName, ex) End Try Return injobj End Function @@ -661,6 +578,12 @@ End Set End Property + Public ReadOnly Property OriginalCreatedDate() As Date Implements IPersistableObject.OriginalCreatedDate + Get + Return m_createdDate + End Get + End Property + Public Overrides Function ToString() As String Dim s As String Dim i As Short @@ -728,5 +651,97 @@ Next Return False End Function + + Private Sub CopyOneToManyCollections() Implements IPersistableObject.CopyOneToManyCollections + Dim cm As CClassMap + Dim coll As Object + cm = Me.getClassMap + m_oneToManyCollections = New Collection + Dim aMap As CUDAMap + For Each de As DictionaryEntry In cm.AssociationMaps + aMap = de.Value + If aMap.Cardinality = aMap.CardinalityEnum.ONE_TO_MANY Then + coll = CPersistenceBroker.CopyCollection(Me, aMap.FromClassTarget) + m_oneToManyCollections.Add(coll, aMap.FromClassTarget) + End If + Next + End Sub + + Public Function GetRemovedCollectionItems(ByVal propertyName As String) As Collection Implements IPersistableObject.GetRemovedCollectionItems + Dim t, iListType, iDicType As Type + Dim fromColl, origColl, collItem As Object + Dim fromIList, origIList As IList + Dim fromDict, origDict As IDictionary + Dim p As PropertyInfo + Dim tmpObj As Object + Dim toColl As New Collection + Dim injObj As IPersistableObject + + Try + origColl = m_oneToManyCollections.Item(propertyName) + Catch + origColl = Nothing + End Try + If origColl Is Nothing Then Return toColl + + p = Me.GetObjectType.GetProperty(propertyName, BindingFlags.Instance Or BindingFlags.NonPublic Or BindingFlags.Public) + iListType = p.PropertyType.GetInterface("IList", True) + iDicType = p.PropertyType.GetInterface("IDictionary", True) + If Not iListType Is Nothing OrElse Not iDicType Is Nothing Then + If Not iListType Is Nothing Then + origIList = CType(origColl, IList) + fromIList = CType(Me.getValueByAttribute(propertyName), IList) + For Each collItem In origIList + If NotInCollection(fromIList, collItem) Then + If Not TypeOf collItem Is IPersistableObject Then + injObj = getPersistenceBrokerInstance.getInjectedObject(collItem, True) + Else + injObj = collItem + End If + toColl.Add(injObj) + End If + Next + Else + origDict = CType(origColl, IDictionary) + fromDict = CType(Me.getValueByAttribute(propertyName), IDictionary) + For Each de As DictionaryEntry In origColl + If NotInCollection(fromDict, de.Key) Then + If Not TypeOf collItem Is IPersistableObject Then + injObj = getPersistenceBrokerInstance.getInjectedObject(de.Value, True) + Else + injObj = de.Value + End If + toColl.Add(injObj) + End If + Next + End If + End If + Return toColl + End Function + + Private Function NotInCollection(ByVal coll As IList, ByVal item As Object) As Boolean + Try + If coll.Contains(item) Then + Return False + Else + Return True + End If + Catch ex As Exception + Return True + End Try + End Function + + Private Function NotInCollection(ByVal coll As IDictionary, ByVal key As Object) As Boolean + Try + If coll.Contains(key) Then + Return False + Else + Return True + End If + Catch ex As Exception + Return True + End Try + End Function + End Class Index: CPersistentObject.vb =================================================================== RCS file: /cvsroot/jcframework/dotnet/CPersistentObject.vb,v retrieving revision 1.58 retrieving revision 1.59 diff -u -d -r1.58 -r1.59 --- CPersistentObject.vb 3 Mar 2005 00:38:24 -0000 1.58 +++ CPersistentObject.vb 21 Mar 2005 08:00:25 -0000 1.59 @@ -54,9 +54,10 @@ Friend Event RemoveMe(ByVal pObj As CPersistentObject) <NonSerialized()> Private m_preEditCopy As CPersistentObject - <NonSerialized()> Private m_retrievedCacheKey As CCacheKey + <NonSerialized()> Private m_oneToManyCollections As New Collection + #Region "Properties" '''----------------------------------------------------------------------------- ''' <summary> @@ -412,7 +413,7 @@ ''' [rbanks] 25/11/2003 Created ''' </history> '''----------------------------------------------------------------------------- - <Browsable(False)> Public ReadOnly Property OriginalCreatedDate() As Date + <Browsable(False)> Public ReadOnly Property OriginalCreatedDate() As Date Implements IPersistableObject.OriginalCreatedDate Get Return m_createdDate End Get @@ -441,6 +442,9 @@ RaiseEvent LoadStarted(Me, New EventArgs) Else RaiseEvent LoadFinished(Me, New EventArgs) + 'Also need to copy collections for one-to-many associations so that we + 'have a reference point when figuring out what changed. + CopyOneToManyCollections() End If End If m_isLoading = Value @@ -914,6 +918,13 @@ Try If GetType(CAssociationObject).IsInstanceOfType(qObject) Then persistentBroker.saveAssociationObject(qObject) + ElseIf GetType(CQueuedDelete).IsInstanceOfType(qObject) Then + Try + persistentBroker.deleteObject(CType(qObject, CQueuedDelete).ObjectToDelete) + Catch ex As Exception + Debug.WriteLine("(Queued Delete) Tried to delete an object that has already been removed") + Debug.WriteLine(ex.Message) + End Try Else value = qObject 'Normal object saving @@ -923,6 +934,8 @@ Debug.WriteLine("The object with key " & ckey.ToString & " was already saved once") Else persistentBroker.saveObject(value) + 'Recopy one-to-many collections incase object is resaved later + value.CopyOneToManyCollections() 'Need to recalculate the key here to handle objects using identity (autonumber) keys ckey = New CCacheKey(value) savedKeys.Add(ckey) @@ -1294,7 +1307,8 @@ End If Dim f, fields() As FieldInfo Dim value As Object - Dim t, iListType, iDicType As Type Try + Dim t, iListType, iDicType As Type + Try t = Me.GetType While Not t Is Nothing fields = t.GetFields(BindingFlags.Instance Or BindingFlags.NonPublic Or BindingFlags.Public) @@ -1314,7 +1328,8 @@ t = Nothing End If End While - CPersistenceBroker.CopyCollections(obj, Me) Catch ex As Exception + CPersistenceBroker.CopyCollections(obj, Me) + Catch ex As Exception Debug.WriteLine(ex.Message) End Try End Sub @@ -1705,6 +1720,97 @@ Return obj End Function + Private Sub CopyOneToManyCollections() Implements IPersistableObject.CopyOneToManyCollections + Dim cm As CClassMap + Dim coll As Object + cm = Me.getClassMap + m_oneToManyCollections = New Collection + Dim aMap As CUDAMap + For Each de As DictionaryEntry In cm.AssociationMaps + aMap = de.Value + If aMap.Cardinality = aMap.CardinalityEnum.ONE_TO_MANY Then + coll = CPersistenceBroker.CopyCollection(Me, aMap.FromClassTarget) + m_oneToManyCollections.Add(coll, aMap.FromClassTarget) + End If + Next + End Sub + + Public Function GetRemovedCollectionItems(ByVal propertyName As String) As Collection Implements IPersistableObject.GetRemovedCollectionItems + Dim t, iListType, iDicType As Type + Dim fromColl, origColl, collItem As Object + Dim fromIList, origIList As IList + Dim fromDict, origDict As IDictionary + Dim p As PropertyInfo + Dim tmpObj As Object + Dim toColl As New Collection + Dim injobj As IPersistableObject + + Try + origColl = m_oneToManyCollections.Item(propertyName) + Catch + origColl = Nothing + End Try + If origColl Is Nothing Then Return toColl + + p = Me.GetObjectType.GetProperty(propertyName, BindingFlags.Instance Or BindingFlags.NonPublic Or BindingFlags.Public) + iListType = p.PropertyType.GetInterface("IList", True) + iDicType = p.PropertyType.GetInterface("IDictionary", True) + If Not iListType Is Nothing OrElse Not iDicType Is Nothing Then + If Not iListType Is Nothing Then + origIList = CType(origColl, IList) + fromIList = CType(Me.getValueByAttribute(propertyName), IList) + For Each collItem In origIList + If NotInCollection(fromIList, collItem) Then + If Not TypeOf collItem Is IPersistableObject Then + injObj = getPersistenceBrokerInstance.getInjectedObject(collItem, True) + Else + injObj = collItem + End If + toColl.Add(collItem) + End If + Next + Else + origDict = CType(origColl, IDictionary) + fromDict = CType(Me.getValueByAttribute(propertyName), IDictionary) + For Each de As DictionaryEntry In origColl + If NotInCollection(fromDict, de.Key) Then + If Not TypeOf collItem Is IPersistableObject Then + injobj = getPersistenceBrokerInstance.getInjectedObject(de.Value, True) + Else + injobj = de.Value + End If + toColl.Add(de.Value) + End If + Next + End If + End If + Return toColl + End Function + + Private Function NotInCollection(ByVal coll As IList, ByVal item As Object) As Boolean + Try + If coll.Contains(item) Then + Return False + Else + Return True + End If + Catch ex As Exception + Return True + End Try + End Function + + Private Function NotInCollection(ByVal coll As IDictionary, ByVal key As Object) As Boolean + Try + If coll.Contains(key) Then + Return False + Else + Return True + End If + Catch ex As Exception + Return True + End Try + End Function + #End Region #Region "IEditableObject" |
From: Richard B. <rb...@us...> - 2005-03-17 06:14:46
|
Update of /cvsroot/jcframework/dotnet In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4492 Modified Files: CInjectedObject.vb Log Message: Improved exception message when class is incorrectly mapped (for injected objects) Index: CInjectedObject.vb =================================================================== RCS file: /cvsroot/jcframework/dotnet/CInjectedObject.vb,v retrieving revision 1.17 retrieving revision 1.18 diff -u -d -r1.17 -r1.18 --- CInjectedObject.vb 14 Mar 2005 03:21:48 -0000 1.17 +++ CInjectedObject.vb 17 Mar 2005 06:14:36 -0000 1.18 @@ -469,7 +469,7 @@ Return CType(CallByName(o, propertyName, CallType.Get), IList) End If Catch err As Exception - Throw New Exception("getCollectionByAttribute failed", err) + Throw New Exception("getCollectionByAttribute failed for attribute " & pName & " in " & m_object.GetType.FullName, err) End Try End Function @@ -480,27 +480,31 @@ Dim pbroker As CPersistenceBroker dotPos = pName.IndexOf(".") - If dotPos = -1 Then - obj = CallByName(m_object, pName, CallType.Get) - Else - Dim o As Object - Dim objName As String - Dim propertyName As String - objName = pName.Substring(0, dotPos) - propertyName = pName.Substring(dotPos + 1) - o = CallByName(m_object, objName, CallType.Get) - If o Is Nothing Then - Return Nothing + Try + If dotPos = -1 Then + obj = CallByName(m_object, pName, CallType.Get) + Else + Dim o As Object + Dim objName As String + Dim propertyName As String + objName = pName.Substring(0, dotPos) + propertyName = pName.Substring(dotPos + 1) + o = CallByName(m_object, objName, CallType.Get) + If o Is Nothing Then + Return Nothing + End If + obj = CallByName(o, propertyName, CallType.Get) End If - obj = CallByName(o, propertyName, CallType.Get) - End If - If obj Is Nothing Then Return Nothing - If obj.GetType.IsSubclassOf(GetType(IPersistableObject)) Then - injobj = CType(obj, CInjectedObject) - Else - pbroker = getPersistenceBrokerInstance() - injobj = pbroker.getInjectedObject(obj) - End If + If obj Is Nothing Then Return Nothing + If obj.GetType.IsSubclassOf(GetType(IPersistableObject)) Then + injobj = CType(obj, CInjectedObject) + Else + pbroker = getPersistenceBrokerInstance() + injobj = pbroker.getInjectedObject(obj) + End If + Catch err As Exception + Throw New Exception("getObjectByAttribute failed for attribute " & pName & " in " & m_object.GetType.FullName, err) + End Try Return injobj End Function |