I'm working on a legacy database schema. On this schema there are 2 tables: clienti 1->many clienti_soc
clienti has the primary key id_cliente, clienti_soc has composite key (id_cliente, id_societa). In my JPA application I need to pick the record of clienti_soc with a specific value of id_societa I'd like to put in my application.properties.
Here how I mapped my entity
@Entity
@Table(name="va_clienti")
@SecondaryTable(name = "va_clienti_soc", pkJoinColumns = @PrimaryKeyJoinColumn(name = "id_cliente"))
@Data
public class Cliente {
@Id
public String idCliente;
public String ragioneSociale;
....
@Column(table = "va_clienti_soc" , name="id_societa")
public String idSocieta = "1"; // <-- ????????
@Column(table = "va_clienti_soc" , name="id_gr_prezzi_partner")
public String idGrPrezziPartner;
}
is there a better way or any best practice to crerate the JPA enity? Is there a cleverer use of @PrimaryKeyJoinColumn annotation?