org.hibernate.AnnotationException: Use of the same entity name twice: User

AppFuse JIRA | Marc Schipperheyn | 10 years ago
  1. 0

    When you define a class mypackagename.User and use mvn appfuse:gen you will get the following error "Use of the same entity name twice: User". org.hibernate.AnnotationException: Use of the same entity name twice: User at org.hibernate.cfg.annotations.EntityBinder.bindEntity(EntityBinder.ja va:221) at org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:53 1) at org.hibernate.cfg.AnnotationConfiguration.processArtifactsOfType(Anno tationConfiguration.java:452) at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(Annotatio nConfiguration.java:268) at org.hibernate.cfg.Configuration.buildMappings(Configuration.java:1039 ) at org.codehaus.mojo.hibernate3.configuration.AbstractComponentConfigura tion.getConfiguration(AbstractComponentConfiguration.java:38) at org.appfuse.mojo.HibernateExporterMojo.configureExporter(HibernateExp orterMojo.java:196) at org.appfuse.mojo.exporter.AppFuseGeneratorMojo.configureExporter(AppF useGeneratorMojo.java:109) at org.appfuse.mojo.HibernateExporterMojo.doExecute(HibernateExporterMoj o.java:244) at org.appfuse.mojo.HibernateExporterMojo.execute(HibernateExporterMojo. java:154) at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPlugi nManager.java:443) at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(Defa ultLifecycleExecutor.java:539) at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeStandalone Goal(DefaultLifecycleExecutor.java:493) at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(Defau ltLifecycleExecutor.java:463) at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHan dleFailures(DefaultLifecycleExecutor.java:311) at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegmen ts(DefaultLifecycleExecutor.java:278) at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLi fecycleExecutor.java:143) at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:334) at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:125) at org.apache.maven.cli.MavenCli.main(MavenCli.java:272) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl. java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces sorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315) at org.codehaus.classworlds.Launcher.launch(Launcher.java:255) at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430) at org.codehaus.classworlds.Launcher.main(Launcher.java:375) If I change the class name to something else, e.g. Person, it works. My files are: <!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"> <hibernate-configuration> <session-factory> <mapping class="org.appfuse.model.User"/> <mapping class="org.appfuse.model.Role"/> <mapping class="nl.msw.dates43.model.Person"/> </session-factory> </hibernate-configuration> package nl.msw.dates43.model; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; import org.appfuse.model.BaseObject; @Entity public class Person extends BaseObject { private String firstName, lastName, middleName, username, password, email; private Long id; @Id @Column(name="userID") @GeneratedValue(strategy = GenerationType.AUTO) public Long getId() { return id; } public void setId(Long id) { this.id = id; } @Column(nullable = false, length = 30) public String getFirstName() { return firstName; } public void setFirstName(String firstName) { this.firstName = firstName; } @Column(nullable = false, length = 50) public String getLastName() { return lastName; } public void setLastName(String lastName) { this.lastName = lastName; } @Column(length = 30) public String getMiddleName() { return middleName; } public void setMiddleName(String middleName) { this.middleName = middleName; } @Column(nullable = false, length = 30) public String getUsername() { return username; } public void setUsername(String username) { this.username = username; } @Column(nullable = false, length = 15) public String getPassword() { return password; } public void setPassword(String password) { this.password = password; } @Column(nullable = false, length = 30) public String getEmail() { return email; } public void setEmail(String email) { this.email = email; } public String toString() { return username; } public boolean equals(Object that) { if (this.toString().equals(that.toString())) return true; return false; } public int hashCode() { return username.hashCode(); } }

    AppFuse JIRA | 10 years ago | Marc Schipperheyn
    org.hibernate.AnnotationException: Use of the same entity name twice: User
  2. 0

    When you define a class mypackagename.User and use mvn appfuse:gen you will get the following error "Use of the same entity name twice: User". org.hibernate.AnnotationException: Use of the same entity name twice: User at org.hibernate.cfg.annotations.EntityBinder.bindEntity(EntityBinder.ja va:221) at org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:53 1) at org.hibernate.cfg.AnnotationConfiguration.processArtifactsOfType(Anno tationConfiguration.java:452) at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(Annotatio nConfiguration.java:268) at org.hibernate.cfg.Configuration.buildMappings(Configuration.java:1039 ) at org.codehaus.mojo.hibernate3.configuration.AbstractComponentConfigura tion.getConfiguration(AbstractComponentConfiguration.java:38) at org.appfuse.mojo.HibernateExporterMojo.configureExporter(HibernateExp orterMojo.java:196) at org.appfuse.mojo.exporter.AppFuseGeneratorMojo.configureExporter(AppF useGeneratorMojo.java:109) at org.appfuse.mojo.HibernateExporterMojo.doExecute(HibernateExporterMoj o.java:244) at org.appfuse.mojo.HibernateExporterMojo.execute(HibernateExporterMojo. java:154) at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPlugi nManager.java:443) at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(Defa ultLifecycleExecutor.java:539) at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeStandalone Goal(DefaultLifecycleExecutor.java:493) at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(Defau ltLifecycleExecutor.java:463) at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHan dleFailures(DefaultLifecycleExecutor.java:311) at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegmen ts(DefaultLifecycleExecutor.java:278) at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLi fecycleExecutor.java:143) at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:334) at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:125) at org.apache.maven.cli.MavenCli.main(MavenCli.java:272) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl. java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces sorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315) at org.codehaus.classworlds.Launcher.launch(Launcher.java:255) at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430) at org.codehaus.classworlds.Launcher.main(Launcher.java:375) If I change the class name to something else, e.g. Person, it works. My files are: <!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"> <hibernate-configuration> <session-factory> <mapping class="org.appfuse.model.User"/> <mapping class="org.appfuse.model.Role"/> <mapping class="nl.msw.dates43.model.Person"/> </session-factory> </hibernate-configuration> package nl.msw.dates43.model; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; import org.appfuse.model.BaseObject; @Entity public class Person extends BaseObject { private String firstName, lastName, middleName, username, password, email; private Long id; @Id @Column(name="userID") @GeneratedValue(strategy = GenerationType.AUTO) public Long getId() { return id; } public void setId(Long id) { this.id = id; } @Column(nullable = false, length = 30) public String getFirstName() { return firstName; } public void setFirstName(String firstName) { this.firstName = firstName; } @Column(nullable = false, length = 50) public String getLastName() { return lastName; } public void setLastName(String lastName) { this.lastName = lastName; } @Column(length = 30) public String getMiddleName() { return middleName; } public void setMiddleName(String middleName) { this.middleName = middleName; } @Column(nullable = false, length = 30) public String getUsername() { return username; } public void setUsername(String username) { this.username = username; } @Column(nullable = false, length = 15) public String getPassword() { return password; } public void setPassword(String password) { this.password = password; } @Column(nullable = false, length = 30) public String getEmail() { return email; } public void setEmail(String email) { this.email = email; } public String toString() { return username; } public boolean equals(Object that) { if (this.toString().equals(that.toString())) return true; return false; } public int hashCode() { return username.hashCode(); } }

    AppFuse JIRA | 10 years ago | Marc Schipperheyn
    org.hibernate.AnnotationException: Use of the same entity name twice: User
  3. 0

    @Embeddable Issue with Spring and Hibernate3

    Stack Overflow | 4 years ago | Ben Dol
    org.hibernate.AnnotationException: Use of @OneToMany or @ManyToMany targeting an unmapped class: nz.co.doltech.ims.project.server.entities.CategoryEntity.incidentCategoryJoins[nz.co.doltech.ims.project.server.entities.IncidentCategoryJoin]
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    AnnotationException: A Foreign key refering has the wrong number of column. should be 2

    Stack Overflow | 2 years ago | ELĂ­as Vargas
    org.hibernate.AnnotationException: A Foreign key refering com.modulos.pvs.acceso.datos.entity.Provincia from com.modulos.pvs.acceso.datos.entity.Ciudad has the wrong number of column. should be 2
  6. 0

    Apply generic class @MappedSuperclass as targetEntity.Error: @ManyToOne on models.Unit.parent references an unknown entity: models.GenericHierarchic

    Stack Overflow | 2 years ago
    org.hibernate.AnnotationException: @OneToOne or @ManyToOne on models.Unit.parent references an unknown entity: models.GenericHierarchicalDictionary

    4 unregistered visitors
    Not finding the right solution?
    Take a tour to get the most out of Samebug.

    Tired of useless tips?

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. org.hibernate.AnnotationException

      Use of the same entity name twice: User

      at org.hibernate.cfg.annotations.EntityBinder.bindEntity()
    2. Hibernate
      Configuration.buildMappings
      1. org.hibernate.cfg.annotations.EntityBinder.bindEntity(EntityBinder.java:221)
      2. org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:531)
      3. org.hibernate.cfg.AnnotationConfiguration.processArtifactsOfType(AnnotationConfiguration.java:452)
      4. org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:268)
      5. org.hibernate.cfg.Configuration.buildMappings(Configuration.java:1039)
      5 frames
    3. org.codehaus.mojo
      AbstractComponentConfiguration.getConfiguration
      1. org.codehaus.mojo.hibernate3.configuration.AbstractComponentConfiguration.getConfiguration(AbstractComponentConfiguration.java:38)
      1 frame
    4. org.appfuse.mojo
      HibernateExporterMojo.execute
      1. org.appfuse.mojo.HibernateExporterMojo.configureExporter(HibernateExporterMojo.java:196)
      2. org.appfuse.mojo.exporter.AppFuseGeneratorMojo.configureExporter(AppFuseGeneratorMojo.java:109)
      3. org.appfuse.mojo.HibernateExporterMojo.doExecute(HibernateExporterMojo.java:244)
      4. org.appfuse.mojo.HibernateExporterMojo.execute(HibernateExporterMojo.java:154)
      4 frames
    5. Maven Plugin
      DefaultPluginManager.executeMojo
      1. org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:443)
      1 frame
    6. Maven Core
      DefaultMaven.execute
      1. org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:539)
      2. org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeStandaloneGoal(DefaultLifecycleExecutor.java:493)
      3. org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:463)
      4. org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:311)
      5. org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:278)
      6. org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:143)
      7. org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:334)
      8. org.apache.maven.DefaultMaven.execute(DefaultMaven.java:125)
      8 frames
    7. M3 Interceptor
      MavenCli.main
      1. org.apache.maven.cli.MavenCli.main(MavenCli.java:272)
      1 frame
    8. Java RT
      Method.invoke
      1. sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      2. sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      3. sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      4. java.lang.reflect.Method.invoke(Method.java:597)
      4 frames
    9. Plexus
      Launcher.main
      1. org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
      2. org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
      3. org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
      4. org.codehaus.classworlds.Launcher.main(Launcher.java:375)
      4 frames