Friend Sub StartTransaction(ByVal reldb As _CRelationalDatabase)
Dim x As DictionaryEntry
Dim ce As CCacheEntry
'precopy collection objects
For Each x In Me
ce = x.Value
If ce.PersistentObject.GetClassMap.RelationalDatabase Is reldb Then
ce.CopyObject()
End If
Next
End Sub
I don't understand when ce.PersistentObject is nothing ?????????????
I am using transaction, when I execute my application and start a transaction, I create many objects without save, then execute rollback. It is correct, but now, if I start transaction inmediatily, i get an error.
Saludos
Victor
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I am debuging this method, I think that when I create a new object into of the transaction and this object is add to cache, but I execute rollback, this object will be deleted, because when I init transaction and execute precopy collection objects, the cacheentry.persistent is false.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Sorry for the delay in getting back to you, it's been a very busy period...
I've just committed a number of changes to the framework that fixed a few issues with caching, etc.
Could you try your code against the new version, and if it still breaks could you put together an Nunit test that duplicates the problem for me - it will make it a lot easier to debug and prove that things work.
Thanks,
- Richard
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
in the code:
Public Function Find(ByVal obj As IPersistableObject) As IPersistableObject
Dim x As DictionaryEntry
Dim ce As CCacheEntry
Dim attrmap As CAttributeMap
Dim i As Integer
Dim found As Boolean
Dim cm As CClassMap
Dim t As Type
Dim interval As Double
cm = obj.GetClassMap
'Debug.WriteLine("Cache - Attempt to Find() <" & cm.Name & "> object in cache")
'We only process cache objects of the same type
'We will check for cache expiry on the objects based on the time set in the
'persistent object, or the cache default if not supplied.
'Dirty objects cannot be deleted from the cache.
Dim m_Enumerator As Collections.IEnumerator = Me.GetEnumerator()
While m_Enumerator.MoveNext()
x = m_Enumerator.Current
ce = x.Value
t = ce.PersistentObject.GetObjectType
If t Is obj.GetObjectType Or t.IsSubclassOf(obj.GetObjectType) Then
If ce.IsExpired() And Not ce.PersistentObject.IsDirty Then
'Debug.WriteLine("Cache - Removing expired object from cache during Find()")
MyBase.Remove(x.Key) 'delete object from cache
m_Enumerator = Me.GetEnumerator
m_Enumerator.Reset() 'Reset enumerator after removing item
Else
found = True
For i = 1 To cm.getFindSize
attrmap = cm.FindAttributeMaps(i)
If obj.GetValueByAttribute(attrmap.Name) <> ce.PersistentObject.GetValueByAttribute(attrmap.Name) Then
found = False
Exit For
End If
Next i
If found Then
'Debug.WriteLine("Cache - Found object in cache")
If ce.TransactionType = CCacheEntry.CacheTransaction.Deleted Then
m_status = StatusEnum.Deleted
Return Nothing
End If
Debug.WriteLine([String].Format("Cache - getting {0} object from cache. Key..." & vbCrLf & x.Key.ToString, x.Key.ObjType.Name))
m_status = StatusEnum.Found
Return GetCachedObject(ce)
End If
End If
End If
End While
'Debug.WriteLine("Cache - object not cached")
m_status = StatusEnum.NotFound
Return Nothing
End Function
*****************************
in the line
t = ce.PersistentObject.GetObjectType
ce.PersistentObject is nothing, then error is produced. I don't understand because only an object is the problem.
It's probably a bug in the cache rollback code, but I've got a number of NUnit tests that check for cache problems after a rollback and they all pass.
It would _really_ help if you could take the Nunit code from CVS, add a test that duplicates the problem and send me the code, or post it as a patch. If you need to add a table to the Original Db1.mdb file it's not a problem, as I'll keep your test in the test suite to make sure I don't break the code in future changes.
- Richard
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I have a problem with the code:
Friend Sub StartTransaction(ByVal reldb As _CRelationalDatabase)
Dim x As DictionaryEntry
Dim ce As CCacheEntry
'precopy collection objects
For Each x In Me
ce = x.Value
If ce.PersistentObject.GetClassMap.RelationalDatabase Is reldb Then
ce.CopyObject()
End If
Next
End Sub
I don't understand when ce.PersistentObject is nothing ?????????????
I am using transaction, when I execute my application and start a transaction, I create many objects without save, then execute rollback. It is correct, but now, if I start transaction inmediatily, i get an error.
Saludos
Victor
I am debuging this method, I think that when I create a new object into of the transaction and this object is add to cache, but I execute rollback, this object will be deleted, because when I init transaction and execute precopy collection objects, the cacheentry.persistent is false.
any idea
Sorry for not responding - I've been on holidays over Easter and haven't caught up yet.
Hopefully I'll get some time tomorrow to have a bit of a look at it.
Hi Victor,
Sorry for the delay in getting back to you, it's been a very busy period...
I've just committed a number of changes to the framework that fixed a few issues with caching, etc.
Could you try your code against the new version, and if it still breaks could you put together an Nunit test that duplicates the problem for me - it will make it a lot easier to debug and prove that things work.
Thanks,
- Richard
Hi.
I have a same problem:
in the code:
Public Function Find(ByVal obj As IPersistableObject) As IPersistableObject
Dim x As DictionaryEntry
Dim ce As CCacheEntry
Dim attrmap As CAttributeMap
Dim i As Integer
Dim found As Boolean
Dim cm As CClassMap
Dim t As Type
Dim interval As Double
cm = obj.GetClassMap
'Debug.WriteLine("Cache - Attempt to Find() <" & cm.Name & "> object in cache")
'We only process cache objects of the same type
'We will check for cache expiry on the objects based on the time set in the
'persistent object, or the cache default if not supplied.
'Dirty objects cannot be deleted from the cache.
Dim m_Enumerator As Collections.IEnumerator = Me.GetEnumerator()
While m_Enumerator.MoveNext()
x = m_Enumerator.Current
ce = x.Value
t = ce.PersistentObject.GetObjectType
If t Is obj.GetObjectType Or t.IsSubclassOf(obj.GetObjectType) Then
If ce.IsExpired() And Not ce.PersistentObject.IsDirty Then
'Debug.WriteLine("Cache - Removing expired object from cache during Find()")
MyBase.Remove(x.Key) 'delete object from cache
m_Enumerator = Me.GetEnumerator
m_Enumerator.Reset() 'Reset enumerator after removing item
Else
found = True
For i = 1 To cm.getFindSize
attrmap = cm.FindAttributeMaps(i)
If obj.GetValueByAttribute(attrmap.Name) <> ce.PersistentObject.GetValueByAttribute(attrmap.Name) Then
found = False
Exit For
End If
Next i
If found Then
'Debug.WriteLine("Cache - Found object in cache")
If ce.TransactionType = CCacheEntry.CacheTransaction.Deleted Then
m_status = StatusEnum.Deleted
Return Nothing
End If
Debug.WriteLine([String].Format("Cache - getting {0} object from cache. Key..." & vbCrLf & x.Key.ToString, x.Key.ObjType.Name))
m_status = StatusEnum.Found
Return GetCachedObject(ce)
End If
End If
End If
End While
'Debug.WriteLine("Cache - object not cached")
m_status = StatusEnum.NotFound
Return Nothing
End Function
*****************************
in the line
t = ce.PersistentObject.GetObjectType
ce.PersistentObject is nothing, then error is produced. I don't understand because only an object is the problem.
my code is:
begin transaction
serial.nombre="a"
serial.find(serial)
serial.valor=serial.valor+1
serial.save
...... .....
rollback
.....
an any object
a.find(a)
when the atoms find a in the cache, the object serial have a property PersistenObject is nothing int he cacheEntry.
Why??????????? or I am doing bad
Hi Victor,
It's very hard to tell what's going on from here.
It's probably a bug in the cache rollback code, but I've got a number of NUnit tests that check for cache problems after a rollback and they all pass.
It would _really_ help if you could take the Nunit code from CVS, add a test that duplicates the problem and send me the code, or post it as a patch. If you need to add a table to the Original Db1.mdb file it's not a problem, as I'll keep your test in the test suite to make sure I don't break the code in future changes.
- Richard