Android ORMLite中的列和自定义类

Android ORMLite中的列和自定义类,android,ormlite,Android,Ormlite,我正在尝试使用ORMLite存储我的应用程序的信息。我的问题是,我有一个类事件,它有一些变量和另一些类,比如自定义日期,它们也有另一个变量或类 这是我的主要课程: @DatabaseTable(tableName = "evento") public class Evento_ORM implements Serializable{ public static final String ID = "_id"; public static final String TIPO_EV

我正在尝试使用ORMLite存储我的应用程序的信息。我的问题是,我有一个类事件,它有一些变量和另一些类,比如自定义日期,它们也有另一个变量或类

这是我的主要课程:

@DatabaseTable(tableName = "evento")
public class Evento_ORM implements Serializable{

    public static final String ID = "_id";
    public static final String TIPO_EVENTO = "tipo_evento";
    public static final String IDIOMA = "idioma";
    public static final String TITULO = "titulo";
    public static final String SLUG = "slug";
    public static final String UBICACION = "ubicacion";
    public static final String DESCRIPCION = "descripcion";
    public static final String FECHA_INICIO = "fecha_inicio";
    public static final String FECHA_CREACION = "fecha_creacion";
    public static final String FECHA_MODIFICACION = "fecha_modificacion";
    public static final String FECHA_FIN = "fecha_fin";

    @DatabaseField(index = true, columnName = ID)
    private int id;

    @DatabaseField(canBeNull = false, columnName = TIPO_EVENTO, dataType = DataType.SERIALIZABLE)
    private TipoEvento_ORM tipo_evento;

    @DatabaseField(canBeNull = false, columnName = IDIOMA, dataType = DataType.SERIALIZABLE)
    private Idioma_ORM idioma;

    @DatabaseField(canBeNull = false, columnName = TITULO)
    private String titulo;

    @DatabaseField(canBeNull = false, columnName = SLUG)
    private String slug;

    @DatabaseField(canBeNull = false, columnName = UBICACION)
    private String ubicacion;

    @DatabaseField(canBeNull = false, columnName = DESCRIPCION)
    private String descripcion;

    @DatabaseField(canBeNull = false, columnName = FECHA_INICIO, dataType = DataType.SERIALIZABLE)
    private Fecha_ORM fecha_inicio;

    @DatabaseField(canBeNull = false, columnName = FECHA_CREACION, dataType = DataType.SERIALIZABLE)
    private Fecha_ORM fecha_creacion;

    @DatabaseField(canBeNull = false, columnName = FECHA_MODIFICACION, dataType = DataType.SERIALIZABLE)
    private Fecha_ORM fecha_modificacion;

    @DatabaseField(canBeNull = false, columnName = FECHA_FIN, dataType = DataType.SERIALIZABLE)
    private Fecha_ORM fecha_fin;

    public Evento_ORM() {
    }

    public Evento_ORM(int id, TipoEvento_ORM tipo_evento, Idioma_ORM idioma, String titulo, String slug, String ubicacion, String descripcion, Fecha_ORM fecha_inicio, Fecha_ORM fecha_creacion, Fecha_ORM fecha_modificacion, Fecha_ORM fecha_fin) {
        this.id = id;
        this.tipo_evento = tipo_evento;
        this.idioma = idioma;
        this.titulo = titulo;
        this.slug = slug;
        this.ubicacion = ubicacion;
        this.descripcion = descripcion;
        this.fecha_inicio = fecha_inicio;
        this.fecha_creacion = fecha_creacion;
        this.fecha_modificacion = fecha_modificacion;
        this.fecha_fin = fecha_fin;
    }

    public int getId() {
        return id;
    }

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

    public String getTitulo() {
        return titulo;
    }

    public void setTitulo(String titulo) {
        this.titulo = titulo;
    }

    public String getSlug() {
        return slug;
    }

    public void setSlug(String slug) {
        this.slug = slug;
    }

    public String getUbicacion() {
        return ubicacion;
    }

    public void setUbicacion(String ubicacion) {
        this.ubicacion = ubicacion;
    }

    public String getDescripcion() {
        return descripcion;
    }

    public void setDescripcion(String descripcion) {
        this.descripcion = descripcion;
    }

    public Fecha_ORM getFecha_inicio() {
        return fecha_inicio;
    }

    public void setFecha_inicio(Fecha_ORM fecha_inicio) {
        this.fecha_inicio = fecha_inicio;
    }

    public Fecha_ORM getFecha_creacion() {
        return fecha_creacion;
    }

    public void setFecha_creacion(Fecha_ORM fecha_creacion) {
        this.fecha_creacion = fecha_creacion;
    }

    public Fecha_ORM getFecha_modificacion() {
        return fecha_modificacion;
    }

    public void setFecha_modificacion(Fecha_ORM fecha_modificacion) {
        this.fecha_modificacion = fecha_modificacion;
    }

    public Fecha_ORM getFecha_fin() {
        return fecha_fin;
    }

    public void setFecha_fin(Fecha_ORM fecha_fin) {
        this.fecha_fin = fecha_fin;
    }

    public TipoEvento_ORM getTipo_evento() {
        return tipo_evento;
    }

    public void setTipo_evento(TipoEvento_ORM tipo_evento) {
        this.tipo_evento = tipo_evento;
    }

    public Idioma_ORM getIdioma() {
        return idioma;
    }

    public void setIdioma(Idioma_ORM idioma) {
        this.idioma = idioma;
    }

    @Override
    public String toString() {
        return "Evento{" +
                "id=" + id +
                ", tipo_evento=" + tipo_evento +
                ", idioma=" + idioma +
                ", titulo='" + titulo + '\'' +
                ", slug='" + slug + '\'' +
                ", ubicacion='" + ubicacion + '\'' +
                ", descripcion='" + descripcion + '\'' +
                ", fecha_inicio=" + fecha_inicio +
                ", fecha_creacion=" + fecha_creacion +
                ", fecha_modificacion=" + fecha_modificacion +
                ", fecha_fin=" + fecha_fin +
                '}';
    }
}
自定义类,例如date(“FECHA”):

我的问题是,存储的信息在变量中是正确的,但在自定义类中,它只存储一个值为“information”的列(如果您看到带有visor的ormlite.db)。这是一个截图,语言是西班牙语

Description是Description,fecha\u creacion是creation\u date,fecha\u fin是end\u date

我的问题是,在自定义类的fecha_creacion或fecha_fin列的位置上,不应该有包含此自定义类变量的列


您应该在主键中添加id值:
@DatabaseField(index=true,columnName=id,id=true)
在自定义类列中,您必须添加值
foreign=true
@DatabaseField(canBeNull=false,columnName=IDIOMA,dataType=dataType.SERIALIZABLE,foreign=true)private-IDIOMA\u-IDIOMA谢谢,我正在尝试执行您的解决方案,但我收到一条简单的错误消息“error”:S。我正在尝试找出错误。您能显示堆栈跟踪吗?08-22 11:00:07.380 17744-17744/com.nikolay.summa.app E/summa_DAO__错误﹕ 创建事件时出错
public class Fecha_ORM implements Serializable{

    @DatabaseField(canBeNull = false, columnName = "timestamp")
    long timestamp;

    @DatabaseField(canBeNull = false, columnName = "offset")
    int offset;

    @DatabaseField(canBeNull = false, columnName = "lastErrors", dataType = DataType.SERIALIZABLE)
    Error_ORM lastErrors;

    @DatabaseField(canBeNull = false, columnName = "timezoneORM", dataType = DataType.SERIALIZABLE)
    Timezone_ORM timezoneORM;

    public Fecha_ORM() {
    }

    public Fecha_ORM(long timestamp, int offset, Error_ORM lastErrors, Timezone_ORM timezoneORM) {
        this.timestamp = timestamp;
        this.offset = offset;
        this.lastErrors = lastErrors;
        this.timezoneORM = timezoneORM;
    }

    public long getTimestamp() {
        return timestamp;
    }

    public void setTimestamp(long timestamp) {
        this.timestamp = timestamp;
    }

    public int getOffset() {
        return offset;
    }

    public void setOffset(int offset) {
        this.offset = offset;
    }

    public Error_ORM getLastErrors() {
        return lastErrors;
    }

    public void setLastErrors(Error_ORM lastErrors) {
        this.lastErrors = lastErrors;
    }

    public Timezone_ORM getTimezoneORM() {
        return timezoneORM;
    }

    public void setTimezoneORM(Timezone_ORM timezoneORM) {
        this.timezoneORM = timezoneORM;
    }

    @Override
    public String toString() {
        return "Fecha_ORM{" +
                ", timestamp=" + timestamp +
                ", offset=" + offset +
                ", lastErrors=" + lastErrors +
                ", timezoneORM=" + timezoneORM +
                '}';
    }
}