Is it possible to create several POJOs mapping for one table?

45 views
Skip to first unread message

Larion Babych

unread,
Aug 4, 2015, 4:49:14 AM8/4/15
to ORMLite Users
I need data sometimes with foreignAutoRefreshing property and sometimes - without it. But ORMLite and java is static, though I have decided create two pojos for one table - one simple and complex, both extends abstraction with table mappings. Is it possible?

Does it matter with what Pojos.class create table with TableUtil.createTable( ... )? 

Would it be any problems ? 

Larion Babych

unread,
Aug 4, 2015, 4:52:17 AM8/4/15
to ORMLite Users

I add examples: 

public class ComplexHistory extends HistoryItem{

    @DatabaseField(columnName = FIELD_ID, foreign = true, foreignAutoCreate = true)
    private Field field;

    public void setField(Field field) {
        this.field = field;
    }

    public Field getField() {
        return field;
    }
}


//////////////////////////////////////

public class SimpleHistory extends HistoryItem {

    @JsonProperty(value = FIELD_ID)
    @DatabaseField(columnName = FIELD_ID, index = true,
            columnDefinition = "integer references " + FIELD + "(" + ID + ") on delete cascade")
    private int fieldId;

    public void setFieldId(int fieldId) {
      this.fieldId = fieldId;
    }

    public int getFieldId() {
       return fieldId;
    }

}
Reply all
Reply to author
Forward
0 new messages