mardi 2 février 2016

Sqlite - Programmatically increase database

My question is at the same time easy and hard. I"ll try to explain the best I can.

I want to make possible for my entities to grow or to create new entities programmatically. Example:

public class Foo{
    public UUID id;
    public String fooName;
}

I want to programmatically add some field to my entity, for example the previous entity should become similar to this:

public class Foo{
    public UUID id;
    public String fooName;
    public String addedField;
}

I know I can't edit my class's text but I can programmatically add some fields to my database. The problem is that even if the database has n fields but the class has less fields, the adapter will not create a bigger class and the fields which are only in the database are lost.

I think I can do something like using only generics and reflection. And I'm pretty sure it will work, but is there a simpler way to achieve this?

Thanks all

Aucun commentaire:

Enregistrer un commentaire