4
I have a scenario where I have the entities Pedido
and Usuário
. The Pedido
is composed of some attributes, among them the requester 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, which 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 it this way I have the following exception:
br.com.Caelum.vraptor.Interceptionexception: org.hibernate.Mappingexception: Repeated column in Mapping for Entity: com.comunicacao.model.Request column: usuario_matricula (should be Mapped with Insert="false" update="false")
If I add what is recommended in the exception (insert="false" update="false")
the error goes away. I wonder if this line will allow me to save and edit the data of it and if this is the correct way to map two equal entities in the Hibernate
?
Wow, I forgot the name that would be generated for haha relationship. Thank you very much, that was it.
– DiegoAugusto
Welcome to Stack Overflow! Welcome to Stackoverflow in English. I edited your post to remove the greetings, as we usually keep them as clean as possible to focus on your scheduling question. If you are interested in visiting a part of the site that is not aimed to ask questions can know the Stack Overflow Chat in Portuguese. If you have questions about the operation, rules and procedures of the site visit the Stack Overflow in English Meta :)
– Jéf Bueno