org.hibernate.AnnotationException

There are no available Samebug tips for this exception. Do you have an idea how to solve this issue? A short tip would help users who saw this issue last week.

  • 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(); } }
    via by Marc Schipperheyn,
  • 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(); } }
    via by Marc Schipperheyn,
  • @Embeddable Issue with Spring and Hibernate3
    via Stack Overflow by Ben Dol
    ,
  • No me lista la colección
    via openxava by fredy1982
    ,
  • bidirectional hibernate relationship
    via Stack Overflow by ddejmek
    ,
  • Spring Hibernate error
    via Stack Overflow by david99world
    ,
    • org.hibernate.AnnotationException: Use of the same entity name twice: User at org.hibernate.cfg.annotations.EntityBinder.bindEntity(EntityBinder.java:221) at org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:531) at org.hibernate.cfg.AnnotationConfiguration.processArtifactsOfType(AnnotationConfiguration.java:452) at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:268) at org.hibernate.cfg.Configuration.buildMappings(Configuration.java:1039) at org.codehaus.mojo.hibernate3.configuration.AbstractComponentConfiguration.getConfiguration(AbstractComponentConfiguration.java:38) at org.appfuse.mojo.HibernateExporterMojo.configureExporter(HibernateExporterMojo.java:196) at org.appfuse.mojo.exporter.AppFuseGeneratorMojo.configureExporter(AppFuseGeneratorMojo.java:109) at org.appfuse.mojo.HibernateExporterMojo.doExecute(HibernateExporterMojo.java:244) at org.appfuse.mojo.HibernateExporterMojo.execute(HibernateExporterMojo.java:154) at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:443) at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:539) at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeStandaloneGoal(DefaultLifecycleExecutor.java:493) at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:463) at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:311) at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:278) at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.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(DelegatingMethodAccessorImpl.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)

    Users with the same issue

    oddodd
    1 times, last one,
    Unknown visitor
    Unknown visitor1 times, last one,
    Unknown visitor
    Unknown visitor1 times, last one,
    Unknown visitor
    Unknown visitor1 times, last one,