Situation 1
I have the following very simple tables:
.......................
And I have the following classes:
Client:
@Entity
public class Cliente implements Serializable {
private static final long serialVersionUID = 7402770378598465859L;
private Short id;
private String nome;
@Column(name="data_nascimento")
private LocalDate dataNascimento;
private Contato contato;
//Constructor
// get e sets
}
Contact:
@Entity
public class Contato implements Serializable {
private static final long serialVersionUID = -5040500676803061821L;
private String telefone;
private String celular;
//Constructor
// get e sets
}
Employee:
@Entity
public class Funcionario implements Serializable{
private static final long serialVersionUID = -5718684144972644433L;
private Short id;
private String nome;
private String rg;
private String cpf;
private boolean ativo;
private Contato contato;
//Constructor
// get e sets
}
Situation 2
I have the following very simple tables:
AndIhavethefollowingclasses:
Client:
@EntitypublicclassClienteimplementsSerializable{privatestaticfinallongserialVersionUID=7402770378598465859L;privateShortid;privateStringnome;@Column(name="data_nascimento")
private LocalDate dataNascimento;
private String telefone;
private String celular;
// Constructor
// get e sets
}
Employee:
@Entity
public class Funcionario implements Serializable {
private static final long serialVersionUID = -5718684144972644433L;
private Short id;
private String nome;
private String rg;
private String cpf;
private boolean ativo;
private String telefone;
private String celular;
// Constructor
// get e sets
}
Issues
1 - In "Situation 1", we have 2 tables and 3 classes, in which the phone and cell properties of the Contact class are represented as columns in the Employee and Client tables in the database, how is the mapping of this situation using JPA?
2 - In "Situation 2", we have 3 tables and 2 classes, in which the columns of the "Contact" table of the database are represented in the application as properties of the Employee and Client , how do I map using JPA in this situation?
3 - In the Client class we have the property dataNascimento that stores an object of type java.time.LocalDate
. Does the JPA (2.1) and / or Hibernate (4.3.5.Final) provide some annotation or some other means for mapping this object? If not, is there any other alternative but to reuse java.util.Date
?
4 - This is a curious question about SQL, does the BIT attribute currently have any differences from TINYINT (1)?