08-31-2011 10:39 AM
I am curious about if two persistence store hold same object, what will happen and what is memory allocated?
Store A object handle -------- Object content --------- object handle Store B.
if changing Object from Store A handle and save it, I believe it will effect B.
what is pros / cons?
08-31-2011 10:48 AM
08-31-2011 07:35 PM
OK, well I have a slightly different model on PersistentStore from Simon.
Firstly the difference is does the BB actually Serialize the Object. I don't think it does. I think it stores the Object in its internal Object form. And I think you can actually reference this Object. Until you change it, it will remain in the Persisted memory.
The follow-on form this is what happens when an Object is referenced twice. There are two cases.
First the simple case.
I have a Vector, in element 0 and element 1, I have a reference to an Object - the same Object. I persist that Vector. When I restart my device and get back my Vector will I still have element 0 and element 1 referencing the same Object. I think so.
Now the more complicated case.
Say I have two Vectors, Both have in Element 0, a reference to the same Object. I persist both Vectors, but I persist them in different 'IDs' Then I retrieve both. So I have two different Vectors, but do both have the same Object in element 0. I think they do.
This would be easy to test. But unfortunately I'm not going to find time in the immediate future, but if some one else could test, that would be fantastic. Thanks
And I should point out when designing data that is going to be persisted,I recommend that you make sure there are no cross references, so this sort of problem does not worry you. One way is to 'normalize' the Objects, so that if Object A references Object B, it will actually have an id for Object B, not a reference for Object B.
09-01-2011 04:52 AM
09-01-2011 04:11 PM
Thanks you guys kind post.
I keep my words to test in future. my project is whipping my A... right now.
I will do test which peter mentioned in thread and let you know the result.