Crud with tables related in spring mvc

Asked

Viewed 318 times

1

I’m developing an application java, using spring mvc. And in a functionality CRUD, I have an Incident Registration screen. On this screen, I have the fields mapped according to Incident.java. However in the registration screen I have more fields that are not part of this entity, is part of another entity. What would be the best way to solve this?

Model: inserir a descrição da imagem aqui

Class, model, Incident:

public class Incidente {

    @Id
    @Column(name = "ID")
    private Integer id;

    @Column(name = "CD_TICKET")
    private Integer ticket;

    @Column(name = "DESC_RESUMIDA")
    private String descricaoResumida;
}

Class model Enterprise:

public class Empresa {

    @Id
    @Column(name = "ID")
    private int id;

    @Column(name = "NM_EMPRESA")
    private String nome;
}

Class model Impacto:

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;
}

Obs: Remembering that, on the incident registration screen, I have a combobox (select/dropdowlist), services, and also companies. On this screen I should be able to inform the impacts that this incident has, example:

In the registration screen of incident 1, I will inform: *

incidente 1 - impacta o servico A
incidente 1 - impacta o servico C
incidente 1 - impacta o servico J

*

This I 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....*

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.