I'm trying for some time a solution to my problem. I have researched a lot but nothing explains me clearly what I need.
So I created an example application and I'm making it available from this link: Appliance
To run this application, simply use the NetBeans IDE and create a MySql DB with the following name: "testHeranca".
My question is:
I have two entities, Participant and Issuer. The Issuer class extends the participating class. For example:
@Entity
@Inheritance(strategy = InheritanceType.JOINED)
@Table(name = "participante")
public class Participante implements Serializable{
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "id")
private Long id;
@Column(name = "nome", nullable = false, length = 100)
private String nome;
@Column(name = "documento", nullable = false, length = 100)
private String documento;
...
}
@Entity
@Table(name = "emitente")
@PrimaryKeyJoinColumn(name = "id")
public class Emitente extends Participante{
@Column(name = "cargo", nullable = false, length = 100)
private String cargo;
...
}
Suppose I have a participant already registered in my database, if I want to register a new issuer from this already existing participant, how should I proceed? Does Hibernate do this for me? With the test I passed in the example this does not happen.