Table not found HIBERNATE

Asked

Viewed 39 times

2

I was doing some tests with Hibernate using abstract classes to create a kind of inheritance and generate my DB from the classes, but I got a problem trying to persist.

The case is, I have an abstract class employee and another dentist and attendant when I ask the Ibernate generate the bank it shows the table not error found, but still creates the bank correctly, When I try to persist I have the same error accompanied by:

Hibernate: select tbl.next_val from hibernate_sequences tbl Where tbl.sequence_name=? for update of tbl Hibernate: update hibernate_sequences set next_val=? Where next_val=? and sequence_name=? Hibernate: select nextval ('hibernate_sequence')

What’s the problem with the code, I’ll be leaving the classes here.

Working class:

@Entity
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
public abstract class Funcionario implements Serializable, EntidadeBase {

private static final long serialVersionUID = 1L;

@Id
@GeneratedValue(strategy = GenerationType.TABLE)
private Long id;

@Column(nullable=false,length=100)
private String nome;

@Column(nullable=false)
@Temporal(TemporalType.DATE)
private Date dtNascimento;

@Column(nullable=false)
private Double salario;

@Column(nullable=false,length=14,unique=true)
private String cpf;

@Column(nullable=false,length=3)
private String sexo;

@Column(nullable=false,length=13)
private String telefone;

@Column(nullable=false,length=15,unique=true)
private String celular;

@Column(nullable=false,unique=true,length=100)
private String email;

@Column(nullable=false,unique=true,length=11)
private String tituloEleitor;

@Column(nullable=false,length=10,unique=true)
private int Num_Serie_CTPS;

@OneToOne(cascade = CascadeType.ALL)    
private Endereco endereco;

//Construtor
public Funcionario(){
    this.endereco = new Endereco();
}

Dental class:

@Entity
@Table(name = "tb_dentista")
public class Dentista extends Funcionario implements Serializable {

private static final long serialVersionUID = 1L;

@Column(unique=true,nullable=false,length=6)
private String cro;

@Column(nullable=false,length=50)
private String especialidade;

//getters e setters
public String getCro() {
    return cro;
}

public void setCro(String cro) {
    this.cro = cro;
}

public String getEspecialidade() {
    return especialidade;
}

public void setEspecialidade(String especialidade) {
    this.especialidade = especialidade;
}

//construtor
public Dentista(){

}

Class clerk:

@Entity
@Table(name = "tb_atendente")
public class Atendente extends Funcionario implements Serializable{

private static final long serialVersionUID = 1L;

public Atendente(){

}

//Não tem nada que não seja o que já tem em funcionario!
}
No answers

Browser other questions tagged

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