1

I'm using Ormlite plugin on Android to manage my database, I set a class field with foreignAutoRefresh on true because this is the default behavior (normally I wanna to get all the Objects loaded automatically).

@DatabaseTable(tableName = "MyClass")
public class MyClass {

    @DatabaseField(columnName = "field",
                   foreign = true, foreignAutoRefresh = true )
    private MyObject field;

    ...
}

But in a specific rare situation I wanna to load a instance of MyClass without load automatically the Object field (setting the foreignAutoRefresh to false temporally)

How I can do that?

public class DBHelper extends OrmLiteSqliteOpenHelper {

    @Override
    public void onUpgrade(...) {

        // ... here I want to set MyClass.field.autoreRefresh to false.

        List<MyClass> myClass = myClassDao.queryForAll();

        ... do some of work here ...

        // ... set again the autoRefresh field value to true.
    }
}

Thank you a lot!

Viktor Valencia
  • 405
  • 5
  • 11

1 Answers1

0

You are looking for a way of changing java annotations on-the-fly. Go and see how to do this at: Modify a class definition's annotation string parameter at runtime

Community
  • 1
  • 1