3
I am using Hibernate 5 and am having the following problem:
Caused by: org.hibernate.DuplicateMappingException: duplicate import: br.edu.unifeob.entidades.apuracao.Avaliacao refers to both br.edu.unifeob.entidades.apuracao.Avaliacao and br.edu.unifeob.entidades.apuracao.Serie (try using auto-import="false")
at org.hibernate.cfg.Configuration$MappingsImpl.addImport(Configuration.java:2892)
at org.hibernate.cfg.annotations.EntityBinder.bindEntity(EntityBinder.java:401)
I have tried to write down my entities this way but it did not help:
@Entity(name="br.edu.unifeob.entidades.apuracao.Avaliacao")
@Table(name="Avaliacao")
public class Avaliacao {
...
}
@Entity(name="br.edu.unifeob.entidades.base.Avaliacao")
@Table(name="Avaliacao")
public class Avaliacao{
...
}
The two classes are in different persistence units. Does anyone know what it might be? I already searched and the only way I could solve the problem is to use the name of the @Entity annotation to differentiate the entities.
What is the complete code of these 2 entities "Evaluation"?
– Dherik
Where does this br.edu.unifeob.entidades.apuracao.Serie come from ?
– jpkrohling
You cannot have 2 classes "representing" the same table
– Pedro Laini
@Pedrolaini, I’ve never tried, but I think it’s possible.
– Dherik
how is the java class that configures or persistence.xml?
– Sidney
If the two classes are in different persistence units, you could map them to a table of the same name. The point is, how are you injecting or creating the entityManagers in your application?
– Giuliana Bezerra