我正在寻找解决问题的方法。我有2个java类的域名。 Graduacao和Aluno,在Graduacao我有一个属性“graus”,这是一个集合。 在Aluno类中,我有收集属性“List graduacao”。 我在JComboBox中添加了关于ComboBoxModel的Graduacao,当用户选择了Graduacao时,我有一个显示Graduacao“graus”的JList。
我需要的是获得用户选择并添加到Aluno的Graduacao和graus,并在使用AbstractTableModel在JTable中显示结果后保留。
我正在尝试这个
@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
这是印刷品
/ **编辑* / 我解决了这个问题,这个项目是:http://www.4shared.com/zip/1Gbj-IZLce/project_example.html