Ormlite Foreign collections

128 Views Asked by At

Is it possible to have such a construction in ormlite, if yes how can I query to get the third collection

@DatabaseTable(tableName = "persons")
public class Person {

    @DatabaseField(generatedId = true)
    private int id;

    @DatabaseField(canBeNull = true)
    private String name;

    @ForeignCollectionField
    private ForeignCollection<App> apps;
}

@DatabaseTable(tableName = "apps")
public class App {

    @DatabaseField(generatedId = true)
    private int id;

    @DatabaseField(canBeNull = true)
    private String name;

    @DatabaseField(foreign = true, foreignAutoRefresh = true, columnName = "person_id")
    private Person person;

    @ForeignCollectionField
    private ForeignCollection<New> news;
}

@DatabaseTable(tableName = "news")
public class New {

    @DatabaseField(generatedId = true)
    private int id;

    @DatabaseField(canBeNull = true)
    private String name;

    public App getApp() {
        return app;
    }

    public void setApp(App app) {
        this.app = app;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    @DatabaseField(foreign = true, foreignAutoRefresh = true, columnName = "app_id")

    private App app;
}

tnx in advance

0

There are 0 best solutions below