title: Hibernate beginner - Duplicate import
body: <p>I am following the tutorials from pluralsight - introduction to hibernate and encountered errors when persisting my object.</p>
  
  <p>I have re-watch several times the videos and I have followed every step correctly, but i could not figure out where the issue was.</p>
  
  <p>Can anyone advise what have I done incorrectly?</p>
  
  <p>Note: I downloaded hibernate 4.3.5 and copy hibernate-release-4.3.5.Final\lib\required to the \lib folder of my eclipse project.</p>
  
  <p>Error:</p>
  
  <pre><code>Aug 02, 2014 10:49:03 PM org.hibernate.annotations.common.reflection.java.JavaReflectionManager &lt;clinit&gt;
  INFO: HCANN000001: Hibernate Commons Annotations {4.0.4.Final}
  Aug 02, 2014 10:49:03 PM org.hibernate.Version logVersion
  INFO: HHH000412: Hibernate Core {4.3.5.Final}
  Aug 02, 2014 10:49:03 PM org.hibernate.cfg.Environment &lt;clinit&gt;
  INFO: HHH000206: hibernate.properties not found
  Aug 02, 2014 10:49:03 PM org.hibernate.cfg.Environment buildBytecodeProvider
  INFO: HHH000021: Bytecode provider name : javassist
  Aug 02, 2014 10:49:04 PM org.hibernate.cfg.Configuration configure
  INFO: HHH000043: Configuring from resource: /hibernate.cfg.xml
  Aug 02, 2014 10:49:04 PM org.hibernate.cfg.Configuration getConfigurationInputStream
  INFO: HHH000040: Configuration resource: /hibernate.cfg.xml
  Aug 02, 2014 10:49:04 PM org.hibernate.internal.util.xml.DTDEntityResolver resolveEntity
  WARN: HHH000223: Recognized obsolete hibernate namespace http://hibernate.sourceforge.net/. Use namespace http://www.hibernate.org/dtd/ instead. Refer to Hibernate 3.6 Migration Guide!
  Aug 02, 2014 10:49:04 PM org.hibernate.cfg.Configuration addResource
  INFO: HHH000221: Reading mappings from resource: com/simpleprogrammer/User.hbm.xml
  Aug 02, 2014 10:49:04 PM org.hibernate.internal.util.xml.DTDEntityResolver resolveEntity
  WARN: HHH000223: Recognized obsolete hibernate namespace http://hibernate.sourceforge.net/. Use namespace http://www.hibernate.org/dtd/ instead. Refer to Hibernate 3.6 Migration Guide!
  Aug 02, 2014 10:49:04 PM org.hibernate.cfg.Configuration doConfigure
  INFO: HHH000041: Configured SessionFactory: null
  Aug 02, 2014 10:49:04 PM org.hibernate.cfg.Configuration configure
  INFO: HHH000043: Configuring from resource: /hibernate.cfg.xml
  Aug 02, 2014 10:49:04 PM org.hibernate.cfg.Configuration getConfigurationInputStream
  INFO: HHH000040: Configuration resource: /hibernate.cfg.xml
  Aug 02, 2014 10:49:04 PM org.hibernate.internal.util.xml.DTDEntityResolver resolveEntity
  WARN: HHH000223: Recognized obsolete hibernate namespace http://hibernate.sourceforge.net/. Use namespace http://www.hibernate.org/dtd/ instead. Refer to Hibernate 3.6 Migration Guide!
  Aug 02, 2014 10:49:04 PM org.hibernate.cfg.Configuration addResource
  INFO: HHH000221: Reading mappings from resource: com/simpleprogrammer/User.hbm.xml
  Aug 02, 2014 10:49:04 PM org.hibernate.internal.util.xml.DTDEntityResolver resolveEntity
  WARN: HHH000223: Recognized obsolete hibernate namespace http://hibernate.sourceforge.net/. Use namespace http://www.hibernate.org/dtd/ instead. Refer to Hibernate 3.6 Migration Guide!
  Aug 02, 2014 10:49:04 PM org.hibernate.cfg.Configuration doConfigure
  INFO: HHH000041: Configured SessionFactory: null
  Aug 02, 2014 10:49:04 PM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure
  WARN: HHH000402: Using Hibernate built-in connection pool (not for production use!)
  Aug 02, 2014 10:49:04 PM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl buildCreator
  INFO: HHH000401: using driver [com.mysql.jdbc.Driver] at URL [jdbc:mysql://localhost:3306/]
  Aug 02, 2014 10:49:04 PM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl buildCreator
  INFO: HHH000046: Connection properties: {user=appuser, password=****}
  Aug 02, 2014 10:49:04 PM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl buildCreator
  INFO: HHH000006: Autocommit mode: false
  Aug 02, 2014 10:49:04 PM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure
  INFO: HHH000115: Hibernate connection pool size: 20 (min=1)
  Aug 02, 2014 10:49:04 PM org.hibernate.dialect.Dialect &lt;init&gt;
  INFO: HHH000400: Using dialect: org.hibernate.dialect.MySQLDialect
  Aug 02, 2014 10:49:04 PM org.hibernate.cfg.Configuration$MappingsImpl addImport
  INFO: HHH000071: Duplicate import: com.simpleprogrammer.User -&gt; com.simpleprogrammer.User
  Aug 02, 2014 10:49:04 PM org.hibernate.cfg.Configuration$MappingsImpl addImport
  INFO: HHH000071: Duplicate import: com.simpleprogrammer.User -&gt; User
  Initial SessionFactory creation failed.org.hibernate.InvalidMappingException: Could not parse mapping document from resource com/simpleprogrammer/User.hbm.xml
  Exception in thread "main" java.lang.ExceptionInInitializerError
      at com.simpleprogrammer.HibernateUtilities.&lt;clinit&gt;(HibernateUtilities.java:22)
      at com.simpleprogrammer.Program.main(Program.java:9)
  Caused by: org.hibernate.InvalidMappingException: Could not parse mapping document from resource com/simpleprogrammer/User.hbm.xml
      at org.hibernate.cfg.Configuration$MetadataSourceQueue.processHbmXml(Configuration.java:3762)
      at org.hibernate.cfg.Configuration$MetadataSourceQueue.processHbmXmlQueue(Configuration.java:3751)
      at org.hibernate.cfg.Configuration$MetadataSourceQueue.processMetadata(Configuration.java:3739)
      at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1410)
      at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1844)
      at com.simpleprogrammer.HibernateUtilities.&lt;clinit&gt;(HibernateUtilities.java:17)
      ... 1 more
  Caused by: org.hibernate.DuplicateMappingException: Duplicate class/entity mapping com.simpleprogrammer.User
      at org.hibernate.cfg.Configuration$MappingsImpl.addClass(Configuration.java:2835)
      at org.hibernate.cfg.HbmBinder.bindRoot(HbmBinder.java:178)
      at org.hibernate.cfg.Configuration$MetadataSourceQueue.processHbmXml(Configuration.java:3759)
      ... 6 more
  </code></pre>
  
  <p>My mapping file:</p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
  "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"&gt;
  &lt;!-- Generated Aug 2, 2014 9:15:11 PM by Hibernate Tools 3.4.0.CR1 --&gt;
  &lt;hibernate-mapping&gt;
      &lt;class name="com.simpleprogrammer.User" table="USERS"&gt;
          &lt;id name="id" type="int"&gt;
              &lt;column name="ID" /&gt;
              &lt;generator class="identity" /&gt;
          &lt;/id&gt;
          &lt;property name="name" type="java.lang.String"&gt;
              &lt;column name="NAME" /&gt;
          &lt;/property&gt;
          &lt;property name="total" type="int"&gt;
              &lt;column name="TOTAL" /&gt;
          &lt;/property&gt;
          &lt;property name="goal" type="int"&gt;
              &lt;column name="GOAL" /&gt;
          &lt;/property&gt;
      &lt;/class&gt;
  &lt;/hibernate-mapping&gt;
  </code></pre>
  
  <p>My configuration:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
                                           "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"&gt;
  &lt;hibernate-configuration&gt;
   &lt;session-factory name=""&gt;
    &lt;property name="hibernate.connection.driver_class"&gt;com.mysql.jdbc.Driver&lt;/property&gt;
    &lt;property name="hibernate.connection.password"&gt;password&lt;/property&gt;
    &lt;property name="hibernate.connection.url"&gt;jdbc:mysql://localhost:3306/&lt;/property&gt;
    &lt;property name="hibernate.connection.username"&gt;appuser&lt;/property&gt;
    &lt;property name="hibernate.default_schema"&gt;protein_tracker&lt;/property&gt;
    &lt;property name="hibernate.dialect"&gt;org.hibernate.dialect.MySQLDialect&lt;/property&gt;
    &lt;property name="hibernate.show_sql"&gt;true&lt;/property&gt;
    &lt;mapping resource="com/simpleprogrammer/User.hbm.xml"/&gt;
   &lt;/session-factory&gt;
  &lt;/hibernate-configuration&gt;
  </code></pre>
  
  <p>My POJO</p>
  
  <pre><code>package com.simpleprogrammer;
  
  public class User {
  
      private int id;
      private String name;
      private int total;
      private int goal;
  
      public int getId() {
          return id;
      }
      public void setId(int id) {
          this.id = id;
      }
      public String getName() {
          return name;
      }
      public void setName(String name) {
          this.name = name;
      }
      public int getTotal() {
          return total;
      }
      public void setTotal(int total) {
          this.total = total;
      }
      public int getGoal() {
          return goal;
      }
      public void setGoal(int goal) {
          this.goal = goal;
      }   
  }
  </code></pre>
  
  <p>My main class:</p>
  
  <pre><code>package com.simpleprogrammer;
  
  import org.hibernate.Session;
  
  public class Program {
  
      public static void main(String[] args) {
  
          Session session = HibernateUtilities.getSessionFactory().openSession();
          session.beginTransaction();
  
          User user = new User();
          user.setName("Joe");
          user.setGoal(250);
          session.save(user);
  
          session.getTransaction().commit();
          session.close();
  
          System.out.println("Hello World");
          HibernateUtilities.getSessionFactory().close();
      }
  
  }
  </code></pre>