I'm new to jpa, what I've been trying is to map a table of my DB of the user table which is divided into 2 types, which are natural and legal users but legal persons have data of ruc and organization to which belongs
public class Usuario implements Serializable {
@Id
@Column(name = "id_usuario")
private int id_usuario;
private String nombre;
private String apellido;
@Column(name = "dni", length = 8)
private int dni;
@Column(name = "user_name")
private String user_name;
@Column(name = "Clave")
private String Clave;
@Column(name = "Correo_Electronico", insertable = false)
private String Correo_Electronico;
@Column(name = "telefono", insertable = false)
private String Telefono;
@Column(name = "ruc", insertable = false, length = 11)
private int ruc;
@Column(name = "organizacion", insertable = false)
private String Organizacion;
@ManyToOne(fetch = FetchType.LAZY, cascade = { CascadeType.PERSIST,
CascadeType.MERGE, CascadeType.REMOVE, CascadeType.DETACH })
@JoinColumn(name = "persona_id_tipo_persona")
private Tipo_Persona tipoPersona;
.
.
.
}
I would like to know if it could be done in another way, because I see that it is not optimized since when entering the users I will have to see the theme of the ruc and create an object with that attribute. in advance thank you