I'm having trouble configuring and handling the use of ID
in parent / child classes using Hibernate
.
I get everything working correctly when the record does not exist in the parent table (records are created with% correct% of the parent and child tables), but when the record exists in the parent table and I need to insert it only into the child, a new id It is created.
I need IDs to stay the same in both tables
Parent class :
==========================
@Entity
@Table(name = "FUNDOS" , schema = "LIMITE")
@Inheritance(strategy = InheritanceType.JOINED)
public class Fundo implements Comparable<Fundo>, FundoInterface {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
protected Integer id;
======================
Daughter Class:
======================
@Entity
@Table(name = "BENCHMARKS" , schema = "LIMITE")
public class Benchmark extends Fundo {
Benchmark() {
}
public Benchmark(Fundo fundo) {
this.id = fundo.getId();
this.nome = fundo.getNome();
this.codigoX = fundo.getCodigoX();
this.codigoY = fundo.getCodigoY();
}
============
How to treat?
I have already tried to use reverse engineering to know what annotations id
would generate from the tables already created ...