ORMLite中的分层继承支持?

时间:2016-02-22 05:50:57

标签: android orm ormlite single-table-inheritance

以下是我的班级结构

@DatabaseTable(tableName = "Payment")
Class Payment{  

    @DatabaseField(generatedId = true)
    public long id;

    @DatabaseField
    private long amount;

    @DatabaseField
    private String type;

    @DatabaseField(foreign = true, foreignAutoRefresh = true, foreignAutoCreate = true)
    private TenderDescriptor tender_descriptor;
}
下面的

是BaseClass: -

public static abstract class TenderDescriptor implements Parcelable, Serializable {
        @DatabaseField(generatedId=true, columnName = "_id")
        private long id;

        public TenderDescriptor() {
        }

        public abstract String getPaymentType();
}
下面的

是两个派生类

@DatabaseTable(tableName = "CreditPaymentTenderDescriptor")
    public static class CreditPaymentTenderDescriptor extends TenderDescriptor {

        @DatabaseField
        private boolean cardEncoded;

        @DatabaseField
        private String cardholder;

        @DatabaseField
        private String creditCardType;

        @DatabaseField
        private String creditCardLastFour;

        @DatabaseField
        private String cardNumber;
}

@DatabaseTable(tableName = "CashPaymentTenderDescriptor")
    public static class CashPaymentTenderDescriptor extends TenderDescriptor {

        @DatabaseField
        private int no_coins ;

        @DatabaseField
        private int no_dollars;
}

当支付类型为creditPayment时,tender_descriptor引用CreditPaymentTenderDescriptor,当它尝试创建表格时,它会失败。 ORMLite中是否具有分层继承支持?如果是,它是如何实施的?简而言之,我需要tender_descriptor指向并存储适当的描述符。

0 个答案:

没有答案