Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Developer
dev2011
Posts: 17
Registered: ‎08-14-2009
My Device: Not Specified
Accepted Solution

Persitent Store Help

I have a little problem with how peristent object behave:

 

Current behaviour:

1. I store an object using storeObject.commit();

2. I make changes to the object.

3. Retrieve object using storeObject.getContents();

4. Object is in the same state as it was before. All changes made after the commit() are still there.

 

Desired behaviour:

1. I store an object using storeObject.commit();

2. I make changes to the object.

3. Retrieve object using storeObject.getContents();

4. Object is in the state, as it was at the time I did the commit(), therefore all changes made after the commit() are dismissed.

 

Is that possible? Thanks! :smileyhappy:

 

Developer
peter_strange
Posts: 19,610
Registered: ‎07-14-2008
My Device: Not Specified

Re: Persistent Store Help

The behavior you are seeing is what I have noted too.  I remember asking if this was expected and getting the response, I believe from msohm, that this was what would happen but if the device was reset (battery out) the data would revert to the pre-committed state.  You could test to see if you see this behavior too. 

 

In addition, if another application requests access to the same persistent object, they will see the changed state before the commit. 

 

You won't find the response from msohm on this forum, I asked the question in the old forum, it was that long ago!

 

The result is that I clone objects where I'm want to be able to discard changes.

Developer
dev2011
Posts: 17
Registered: ‎08-14-2009
My Device: Not Specified

Re: Persistent Store Help

You're right, after a hard-reset my objects are reverting, too. Wasn't quiet the behaviour I was expecting. Guess I also need to clone my objects - although I was kinda trying to avoid that. Thanks!