Android Ormlite外国集合没有用

时间:2016-10-04 05:44:50

标签: android ormlite

我正在尝试在ORMLite中使用外部集合。但没有奏效。

模型类
User.java

@DatabaseTable(tableName = "users")
public class User {

    public static String COL_UID = "uid";
    public static String COL_NAME = "name";
    public static String COL_USERNAME = "username";
    public static String COL_UPDATED_DATE = "updated_date";
    @DatabaseField(generatedId = true)
    private int id;
    @DatabaseField
    private int uid;
    @DatabaseField
    private String name;
    @DatabaseField
    private String username;
    @DatabaseField
    private String updated_date;
    @ForeignCollectionField
    private Collection<Image> images;

    public int getUid() {
        return uid;
    }

    public void setUid(int uid) {
        this.uid = uid;
    }

    public String getName() {
        return name;
    }

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

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getUpdated_date() {
        return updated_date;
    }

    public void setUpdated_date(String updated_date) {
        this.updated_date = updated_date;
    }
}

Image.java

@DatabaseTable(tableName = "images")
public class Image implements Parcelable{
    @DatabaseField(generatedId = true)
    private int id;
    @DatabaseField(columnName = "img_id")
    private int imgId;
    @DatabaseField(unique = true)
    private String uri;
    @DatabaseField
    private String name;
    @DatabaseField
    private String extention;
    @DatabaseField(foreign = true)
    protected Place place;
    public Image() {
    }

    public Image(int imgId, String uri, String name, String extention) {
        this.imgId = imgId;
        this.uri = uri;
        this.name = name;
        this.extention = extention;
    }

    public int getId() {
        return id;
    }

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

    public int getImgId() {
        return imgId;
    }

    public void setImgId(int imgId) {
        this.imgId = imgId;
    }

    public String getUri() {
        return uri;
    }

    public void setUri(String uri) {
        this.uri = uri;
    }

    public String getName() {
        return name;
    }

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

    public String getExtention() {
        return extention;
    }

    public void setExtention(String extention) {
        this.extention = extention;
    }
}

0 个答案:

没有答案