Ola galera…
alguem pode me ajudar a fazer a herança, principalmente uma classe para cada tabela…
eu tenho as seguintes classes…
Pessoa…
@Entity
@Table(name = "Pessoa", catalog = "Banco", uniqueConstraints = {})
public class Pessoa implements Serializable
{
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(unique = true, nullable = false)
private int id;
// nao pode ser null tamanho
@Column(nullable = false, length = 45)
private String nome;
// / pode ser null pode inserir pode atualizar tamanho
@Column(nullable = true, insertable = true, updatable = true, length = 45)
private String telefone;
@OneToOne(cascade = { CascadeType.ALL }, fetch = FetchType.LAZY)
@PrimaryKeyJoinColumn
private Endereco endereco;
....
}
e Aluno…
@Entity
@Table(name = "Professor", catalog = "Banco", uniqueConstraints = {})
public class Professor extends Pessoa
{
private static final long serialVersionUID = 1L;
@Column(nullable = false, length = 45)
private String titulo;
@OneToMany(cascade={CascadeType.ALL}, fetch=FetchType.LAZY, mappedBy="Professor")
private Set<Turma> turma = new HashSet<Turma>(0);
valews…