Google Groups

Re: Question about OrmLite cache

Viktor Nyblom Feb 19, 2013 1:08 AM
Posted in group: RoboSpice
Hi Stephane,

I appreciate the quick reply. The answers confirmed my picture of the workflow.

As for the code, I don't think I am allowed to share it (corporate policy), so I'll just have to go through it again. And again. And again... 

The samples were my starting point, but I noticed that only the persisted objects lies in ForeignCollections in the parent. Only the children have ForeignField with a reference to the parent (of the persisted fields that is). And I might be misinterpreting this, but it looks like the InDatabaseObjectPersister and it's testcases asumes that the DatabaseFields are collections. Don't know if I have the skills yet to contribute, though.

On a whole other subject, I must say that I like how you guys mavenize and modularize everything. It was a bit harder for me to get started but gave me a good reason to learn how to use Maven for real. Clone the samples, run mvn clean install and everything is setup properly. Beautiful. I saw something in another thread about putting dependencies in the libs folder, but this would probably just mess things up. Better to force the user to learn a good build tool.


Den tisdagen den 19:e februari 2013 kl. 15:58:09 UTC+8 skrev Stéphane Nicolas:
Hello Viktor,

1. Yes

2. You a re right. This is take care of by RS. They are no limitations known till now.

3. You got a RoboSpiceDataBaseHelper for that. Also, note that RoboSpice caching is meant to be transparent and is completely encapsulated in the SpiceService. It should be possilbe to access the cache system (in your case the databse) directly through a shared reference to it (shared by the service and your activities). Also, in that case, nothing will prevent side-effects like concurrent access or database inconsistency. You will be on your own past that point.

4. I can't tell you what's wrong in your code. Did you check the robospice ormlite sample ? The only diffference I can see quickly is that we don't use underscores for id... Otherwise, do you have a github repo for your code so that we can work on it. 

And finally, yes, you are right, the orm lite module is still in beta. We developped that module for an app and we know it works but we didn't fully test or implement it, just enough for our needs up to now. We are pretty open to contributions for that module.


2013/2/19 Viktor Nyblom <>
I just started using the ORMlite module for cacheing (Gson for parsing json and Spring for networking) and I have a couple of questions about how this works.

1. From my understanding the caching takes place after loadDataFromNetwork, so whatever is returned from that method is what is run through the caching process, right?

2. The OrmLite documentation states that "if your foreign object has a generated-id which is provided by the database then you need to create it before you create any objects that reference it ", but from what I could deduce from the source code this is taken care of. Correct? If so, is there any limitation on how many levels of nesting I can have?

3. Is it possible to access and manipulate the database outside of the Robospice controll

4. What the hell am I doing wrong? =) The most simple use case is fetching a User with a UserName foreign field. Somewhat simplified the classes look like this:

public class User{

    private int _id;

    public String gender;

    @DatabaseField(foreign = true, foreignAutoRefresh = true)
    public UserName name;


public class UserName{

    private int _id;

    public String preferred;


The tables are created as the should and the gender field is persisted in the database but not the name field. I always get the default 0 and the username table is empty.

I know the ORMLite module is still in beta and I guess I should ask ORMLite specific questions on SO or ORMLite user groups, but I have to try. =) 

Thanks in advance

Vous recevez ce message, car vous êtes abonné au groupe Google Groupes RoboSpice.
Pour vous désabonner de ce groupe et ne plus recevoir d'e-mails le concernant, envoyez un e-mail à l'adresse
Pour plus d'options, visitez le site .

Stéphane NICOLAS,
OCTO Technology 
Développeur & Consultant Android / Java
50, Avenue des Champs-Elysées
75008 Paris
+33 (0) -