Duplicate mapping error: org.hibernate.Duplicatemappingexceptionn

Asked

Viewed 203 times

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"?

  • Where does this br.edu.unifeob.entidades.apuracao.Serie come from ?

  • 1

    You cannot have 2 classes "representing" the same table

  • @Pedrolaini, I’ve never tried, but I think it’s possible.

  • how is the java class that configures or persistence.xml?

  • 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?

Show 1 more comment

1 answer

0

Browser other questions tagged

You are not signed in. Login or sign up in order to post.