3
Hello, I am working on a Java Web project with Hibernate, Postgres, Glassfish, and JPA/JSF usage. The problem is that my relationships were being generated with the following strategy:
@JoinTable(name = "prop_user", joinColumns = {@JoinColumn(name = "id_prop", referencedColumnName = "idproposicao")},
inverseJoinColumns = {@JoinColumn(name = "id_user", referencedColumnName = "cpf")})
@PrimaryKeyJoinColumn
private UsuarioEntity userProp;
Using the above code in the User entity, I would create a relationship with the Proposition entity, generating a relationship table, but I have no control over it. Everything done via Ibernate by annotation.
And now I need to create an extra field in this relationship, an "Opinion" attribute like String and I don’t know how to do it with JPA.
I saw that it seems that I need to remake relationships, because I will need to create an entity class for this relationship, manually shaping for my need. Someone can confirm I’m on the right track?
Thanks!
Hello Edjane, thank you so much for your contribution. I wanted to attribute the attribute "opinion" in the relationship I have between User and Proposition. I’m seeing an example with the annotation @Associationoverride to map the relationship with this field more than the primary and foreign keys.
– kairos