I'm looking for a solution to my problem. I have 2 java class of domain. Graduacao and Aluno, in Graduacao I have an attribute "graus" that is a Collection. In Aluno class, I have collection attribute "List graduacao". I add the Graduacao in a JComboBox about ComboBoxModel and when user selected a Graduacao I have a JList that show the "graus" of Graduacao.
What I need is get Graduacao and graus that user choose and add to Aluno and persist after show results in a JTable with AbstractTableModel.
I'm trying this
@Entity
@Table(name="graduacao")
public class Graduacao {
@Id @GeneratedValue
private Integer id;
@NotNull @Column(unique = true)
private String graduacao;
@ElementCollection
@CollectionTable(name="graduacao_grau", joinColumns=@JoinColumn(name="id_graduacao"))
@Column(name="grau")
private List<String> graus;
//get and set
@Entity
@Table(name="aluno")
public class Aluno {
@Id @GeneratedValue
private Integer id;
//informacoes gerais
@NotNull
private String nome;
private String cpf;
private String rg;
private String nomePai;
private String nomeMae;
@Temporal(TemporalType.DATE)
private Date dtNascimento;
@Temporal(TemporalType.TIMESTAMP)
private Date dtCadastro;
private String status;
private String observacoes;
//logradouro
private String endereco;
private String bairro;
private String complemento;
private String cidade;
private String cep;
@Enumerated(EnumType.STRING)
private EstadoBrasileiro uf;
//contato
@ElementCollection
@CollectionTable(name="telefone_aluno", joinColumns=@JoinColumn(name="id_aluno"))
@Column(name="telefone")
private List<String> telefones;
private String email;
//graduacao
@OneToMany @JoinColumn(name="id_aluno")
private List<Graduacao> graduacao;
@Temporal(TemporalType.DATE)
private Date dataGraduou;
//federacao
@OneToMany @JoinColumn(name="id_federacao")
private List<Federacao> federacao;
//get and set
here the print
/** edit */ I solved the problem, here the project: http://www.4shared.com/zip/1Gbj-IZLce/project_example.html