I'm developing a java application, using spring mvc . And in a CRUD functionality, I have an Incident signup screen. On this screen, I have the fields mapped according to the entity Incident.java. However in the registration screen I have more fields that are not part of this entity, it is part of another entity. What would be the best way to solve this?
Class,model,Incident:
publicclassIncidente{@Id@Column(name="ID")
private Integer id;
@Column(name = "CD_TICKET")
private Integer ticket;
@Column(name = "DESC_RESUMIDA")
private String descricaoResumida;
}
Class model Company:
public class Empresa {
@Id
@Column(name = "ID")
private int id;
@Column(name = "NM_EMPRESA")
private String nome;
}
Class model Impact:
public class Impacto implements Serializable {
/**
* Serial Version
*/
private static final long serialVersionUID = 1L;
@Id
@NotNull
@ManyToOne
@JoinColumn(name = "ID_INCIDENTE")
private Incidente incidente;
@Id
@NotNull
@ManyToOne
@JoinColumn(name = "ID_SERVICO")
private Servico servico;
}
Class model Service:
public class Servico {
@Id
@Column(name = "ID")
private Integer id;
@Column(name = "NM_SERVICO")
private String nome;
}
Note: Remembering that in the incident log, I have a combobox (select / dropdowlist), services, and also companies. On this screen I should be able to report the impacts of this incident, for example:
In the record of incident 1, I will inform you: *
incidente 1 - impacta o servico A
incidente 1 - impacta o servico C
incidente 1 - impacta o servico J
*
This will save on the impact table: *
incidente 1 - servico A
incidente 1 - servico C
incidente 1 - servico J
incidente 2 - servico A
incidente 3 - servico D
etc ... *