InthefollowingclassdiagramIamtryingtomakethefollowingrelationshipsbetweenclasswhereademandwillhavearesponsibleanalystandarequestingclient.Iwouldliketoknowifmymappingissureifthelistgetsintheclassdemandsinsteadthefollowingmodelsfollow:
packagebr.com.deivsoft.model;importjava.util.Date;importjava.util.List;importjavax.persistence.Column;importjavax.persistence.Entity;importjavax.persistence.EnumType;importjavax.persistence.Enumerated;importjavax.persistence.GeneratedValue;importjavax.persistence.GenerationType;importjavax.persistence.Id;importjavax.persistence.JoinColumn;importjavax.persistence.JoinTable;importjavax.persistence.ManyToOne;importjavax.persistence.OneToMany;importjavax.persistence.Table;importjavax.persistence.Temporal;importjavax.persistence.TemporalType;importbr.com.deivsoft.enums.PrioridadeEnum;importbr.com.deivsoft.enums.StatusEnum;@Entity@Table(name="DEMANDAS")
public class Demanda {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "ID_DEMANDAS")
private Long id;
@Column(name = "NRO_TICKET", length = 50, nullable = false)
private String nro_ticket;
/* Enum de PRIORIDADE */
@Enumerated(EnumType.ORDINAL)
private PrioridadeEnum prioridade;
/* Enum de STATUS */
@Enumerated(EnumType.ORDINAL)
private StatusEnum status;
@OneToMany
@JoinTable(name = "DEMANDA_ANALISTA", joinColumns = @JoinColumn(name = "ID_ANALITAS"), inverseJoinColumns = @JoinColumn(name = "ID_DEMANDAS"))
private List<Contato> contato;
@OneToMany
@JoinTable(name = "DEMANDA_ANALISTA", joinColumns = @JoinColumn(name = "ID_ANALITAS"), inverseJoinColumns = @JoinColumn(name = "ID_DEMANDAS"))
private List<Analista> analista;
@Temporal(TemporalType.DATE)
private Date dt_abertura;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getNro_ticket() {
return nro_ticket;
}
public void setNro_ticket(String nro_ticket) {
this.nro_ticket = nro_ticket;
}
public StatusEnum getStatus() {
return status;
}
public void setStatus(StatusEnum status) {
this.status = status;
}
public PrioridadeEnum getPrioridade() {
return prioridade;
}
public void setPrioridade(PrioridadeEnum prioridade) {
this.prioridade = prioridade;
}
public List<Contato> getContato() {
return contato;
}
public void setContato(List<Contato> contato) {
this.contato = contato;
}
public List<Analista> getAnalista() {
return analista;
}
public void setAnalista(List<Analista> analista) {
this.analista = analista;
}
public void setDt_abertura(Date dt_abertura) {
this.dt_abertura = dt_abertura;
}
}
package br.com.deivsoft.model;
import java.util.List;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import br.com.deivsoft.model.Equipe.grupamentoEnum;
@Entity
@Table(name ="ANALISTAS")
public class Analista {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "ID_ANALISTAS")
private Long id;
@Column(name = "MATRICULA", length = 15, nullable = false)
private String matricula;
@Column(name = "NOME", length = 255, nullable = false)
private String nome;
@Column(name = "EQUIPE", length = 150, nullable = false)
private grupamentoEnum equipe;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getMatricula() {
return matricula;
}
public void setMatricula(String matricula) {
this.matricula = matricula;
}
public String getNome() {
return nome;
}
public void setNome(String nome) {
this.nome = nome;
}
public grupamentoEnum getEquipe() {
return equipe;
}
public void setEquipe(grupamentoEnum equipe) {
this.equipe = equipe;
}
public List<Demanda> getDemanda() {
return demanda;
}
public void setDemanda(List<Demanda> demanda) {
this.demanda = demanda;
}
}
Class Customer is the one below in the code I called contact
package br.com.deivsoft.model;
import java.util.List;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.OneToMany;
import javax.persistence.Table;
@Entity
@Table(name = "CONTATOS")
public class Contato {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "ID_CONTATOS")
private Long Id;
@Column(name = "NOME", length = 155, nullable = false)
private String nome;
@Column(name = "MATRICULA", length = 20, nullable = false)
private String matricula;
@Column(name = "LOTACAO", length = 155, nullable = false)
private String lotacao;
@OneToMany
@JoinTable(name="DEMANDA_CONTATO",
joinColumns=@JoinColumn(name="ID_CONTATOS"),
inverseJoinColumns = @JoinColumn(name="ID_DEMANDAS"))
private List<Demanda> demanda;
public Long getId() {
return Id;
}
public void setId(Long id) {
Id = id;
}
public String getNome() {
return nome;
}
public void setNome(String nome) {
this.nome = nome;
}
public String getMatricula() {
return matricula;
}
public void setMatricula(String matricula) {
this.matricula = matricula;
}
public String getLotacao() {
return lotacao;
}
public void setLotacao(String lotacao) {
this.lotacao = lotacao;
}
public List<Demanda> getDemanda() {
return demanda;
}
public void setDemanda(List<Demanda> demanda) {
this.demanda = demanda;
}
}