I have a scenario where I have the entities Pedido
and Usuário
. The Pedido
is composed of some attributes, among them the requestor that is mapped as follows:
@ManyToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "usuario_matricula", referencedColumnName = "matricula", nullable = false)
private Usuario solicitante;
But this request also has the attendant, who is a Usuário
. I try to map it like this:
@ManyToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "usuario_matricula", referencedColumnName = "matricula", nullable = true)
private Usuario atendente;
The problem is that when I try to do this, I have the following exception:
br.com.caelum.vraptor.InterceptionException: org.hibernate.MappingException: Repeated column in mapping for entity: com.unicacao.model.Pedido column: usuario_matricula (should be mapped with insert="false" update="false")
If I add what is recommended in the (insert="false" update="false")
exception, the error some. I would like to know if this line will allow me to save and edit the data of the same and if this is the correct way to map two equal entities in Hibernate
?