0
I have 3 classes / 2 tables: employee / secretary :
Functionary
salesman employee extends
secretariat extends staff
i wanted to make a single table inheritance with seller and employee
and an inheritance joined with secretary and employee it is possible to do this?
classe funcionario;
@Entity(name="Funcionario")
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name = "tipo", length = 1, discriminatorType = DiscriminatorType.STRING)
@DiscriminatorValue("F")
@Table(name = "funconarios")
public abstract class Funcionario implements Autenticar {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "codFuncionario")
private String codFuncionario;
salesman:
@Entity
@DiscriminatorValue(value = "V")
public class Vendedor extends Funcionario implements BonusSalario{
}
and how I would do in the secretarial class?
public class Secretaria extends Funcionario implements BonusSalario{
}
Dude, I think it’s best you think of composition, px: Seller has work data (ai vc can write it down with @Embeded) class Seller { private Funcionario funcionario}
– cezar
@But like the seller class I wouldn’t even need to extend because it will have the same attributes as it works and the same table, you could answer with an example using this @embededso I can better understand how to use it in the manager class?
– Gabriel
I think using only JOINED should solve, except that in the case would be created 3 tables, where the primary employee key would be the foreign key of the children, the common attributes the seller and secretary would be in the abstract class
– André
https://memorynotfound.com/hibernate-jpa-joined-table-inheritance-example/
– André