Hi everyone,
I need to convert an existing Lead entity to a Client entity in my Spring Boot project. The Client extends the Lead, and I must keep the Lead because of its relationships with other tables.
When I try to do this, it inserts a new Lead instead of using the existing one.
@Entity
@Inheritance(strategy = InheritanceType.JOINED)
public class Lead {
@Id
private Long id;
private String name;
private String email;
// other fields and relationships
}
@Entity
@PrimaryKeyJoinColumn(name = "student_id", referencedColumnName = "id")
public class Client extends Lead {
private String university;
private String college;
private LocalDate graduationYear;
// other client-specific fields
}
What's the best way to achieve this? Any advice or sample code would be great!