1
Class A{
    @DatabaseField(generatedId=true, columnName=ID_FIELD_NAME)
    private int id:
    @DatabaseField
    private C cfield;
}


@DatabaseTable(tableName="B class")
Class B extends A{
    ...
    ...
}

Is it possible to say to class B to ignore the C field from the base class?

4

2 回答 2

3
private C cfield; 

Will be ignored by ORMLite by default.

The reason is there is no annotation given for the cfield. If you don't specify annotation @DatabaseField for an attribute, that will be ignored.


Visibility of attributes can do the trick. Like

Class A {
    @DatabaseField(generatedId=true, columnName=ID_FIELD_NAME)
    protected int id; // Set public or protected for sharable attributes
    @DatabaseField
    private C cfield; // Set private which you want to ignore from Child class
}
于 2013-10-03T10:33:24.430 回答
1

Is it possible to say to class B to ignore the C field from the base class?

Sorry but no. ORMLite by default investigates all base class fields and will find the fields that have annotations -- even if marked as private.

于 2013-12-18T21:21:28.673 回答