Вопрос

i have implemented a persistent store saving on my BB app.

i have been running the right way to do it i think. But i still don't understand when somehow my app throws a NonPersistableDataException

I was saving a set of key-value pair in an overriden Hashtable that implements Persistable. And the object of that hashtable was being added into an overriden vector that implements Persistable as well, and finally store it to the persistent store.

I did access such saved persistable object from persistable store by getting the overriden vector object, and then getting the individual overriden hashtable from its item.

I think both of vector and hashtable are persistable object. Then, what might actually cause this exception?

Это было полезно?

Решение

These exceptions are usually quite hard to find, especially when you add a collection as a 'leaf' of another collection.

Remember that not only does the collection need to be Persistable (which Vector and Hashtable are anyway) but all the objects you add to these collections need to be Persistable as well. So look for every occasion when you add an Object to any of your persisted collections and you will find your problem.

Good luck.

Noting this comment: "the error happened when making a HTTP connection".

As I understand it (and I'm not a BBRY employee, so this is just from experience) BlackBerry PersistentStore sometimes has a mind of its own, most significantly, when you or anyone else does a commit, it will commit all outstanding changes. So you can get this when you did nothing, because something else did a commit. Now PersistentStore has to be consistent, so it will commit all Objects, and all Objects that these use, and all Objects they use and so on recursively searching for Object references until it makes sure it has a complete set. So, for example, if you have a collection (say a Vector) and this Vector is persisted, then you add a non persistable class to the Vector, but then remove it before you commit, you might get away with it. But if something else does a commit between the add and the remove, then you can get this exception. So be very, very careful regarding adding Objects to collections that are persisted.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top