I have this two classes,
public class Banda {
private int BandaId;
private String Nome;
private Date DataDeCriacao;
private Collection<SetList> setLists;
public Banda(){
}
}
and
public class Evento {
private int EventoId;
private String Nome;
private Date DataDoEvento;
private String Local;
private String Tipo;
private Banda banda;
public Evento() {
}
}
I'm trying configure his database creation using OrmLite, and I have this config class:
public class BandaConfiguration extends DatabaseTableConfig<Banda>{
public BandaConfiguration() {
ArrayList<DatabaseFieldConfig> fields = new ArrayList<>();
fields.add(getBandaIdField());
fields.add(getNomeField());
fields.add(getDataDeCriacaoField());
setFieldConfigs(fields);
}
private DatabaseFieldConfig getBandaIdField() {
DatabaseFieldConfig fieldBandaId = new DatabaseFieldConfig();
fieldBandaId.setFieldName("BandaId");
fieldBandaId.setColumnName("BandaId");
fieldBandaId.setGeneratedId(true);
return fieldBandaId;
}
private DatabaseFieldConfig getNomeField(){
DatabaseFieldConfig fieldNome = new DatabaseFieldConfig();
fieldNome.setFieldName("Nome");
fieldNome.setColumnName("Nome");
fieldNome.setDataType(DataType.STRING);
fieldNome.setWidth(100);
return fieldNome;
}
private DatabaseFieldConfig getDataDeCriacaoField(){
DatabaseFieldConfig fieldDataDeCriacao = new DatabaseFieldConfig();
fieldDataDeCriacao.setFieldName("DataDeCriacao");
fieldDataDeCriacao.setColumnName("DataDeCriacao");
fieldDataDeCriacao.setDataType(DataType.DATE_STRING);
fieldDataDeCriacao.setFormat("yyyy-MM-dd HH:mm:ss");
return fieldDataDeCriacao;
}
}
I don't want to use annotations because I want to keep my domain module with no framework, like an pure Java code layer.
So my doubt is, how can I configure the relation between this two entites?
Thanks for all!