#Converting Lead to Client Without Deleting the Lead

1 messages · Page 1 of 1 (latest)

errant star
#

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!

obsidian jewelBOT
#

<@&1004656351647117403> please have a look, thanks.

errant star
carmine jetty
#

and how exactly are they organized on the db?

#

are you using postgres inheritance or what

regal fern
#

Is a lead a client or not ?

#

If it isn't

#

Then don't make it extend client

#

and if it is

#

making it extend client depend of what you want

#

but usually you do not want to extend