Using the class:
@Entity
public class Pessoa{
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long idPessoa;
@Column(nullable=false, unique = true)
private String nome;
@OneToOne
@JoinColumn(name = "idPais", nullable = true)
private Pais pais;
public Pessoa(){}
// Getters and Setters
}
In the bank is generated
CONSTRAINT fk_8pxwdacx0r81ra9d59m6erkri FOREIGN KEY (idpais)
CONSTRAINT uk_4tdehxj7dh8ghfc68kbwbsbll UNIQUE (nome)
How to name, instead of fk_8pxwdacx0r81ra9d59m6erkri
, name Pais_Pessoa
and uk_4tdehxj7dh8ghfc68kbwbsbll
, name unique_nome
.
Is this possible in JPA / Hibernate? If so, how?