Siemka piszę sobie cruda. Na początku miałem encję Account i Patient. Encja Account miała w sobie pole Patient. Teraz dodałem encję Doctor i chciałem to w miarę sensownie rozplanować. Chodzi mi o to, że wcześniej gdy miałem tylko Patient to pole Patient w encjii Account załatwiało sprawę. Nie wiem czy dobrze zobrazowałem o co mi chodzi. Wkleiłem kod przykładowych klas. Oczywiście mój kod nie ma tak mało pól chodzi mi tylko o idee jak powinno się przechowywać konta i różnych użytkowników.
@Entity
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
public class Account {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
private String login;
private String password;
private String role;
@OneToOne(cascade = CascadeType.ALL)
private User user;
}
@Entity
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
public class Doktor extends User {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
private String specialization;
}
@Entity
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
public class Patient extends User {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
private String pesel;
private String email;
}
@Entity
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
public abstract class User {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
private String firstName;
private String lastName;
}