title: hibernate creating duplicate columns automatically
body: <p>I have started learning HQL recently and tried to create a test application to see how it works.. but when i'm trying to run the project, i see duplicate columns are getting created with NULL value in it. </p>
  
  <p>Here are my project details</p>
  
  <p>I have a table (insurance) with this structure {id,insurance_name,invested_amount,investment_date} which i have create it.</p>
  
  <p>and when i run the application it is creating two additional columns with null values {id,insurance_name,invested_amount,investment_date,INSURANCE_AMOUNT,INSURANCE_DATE } and i dont know from where they were getting created. </p>
  
  <p>hibernate configuration file:</p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"&gt;
  
  &lt;hibernate-configuration&gt;
  &lt;session-factory&gt;
   &lt;property name="hibernate.connection.driver_class"&gt;com.mysql.jdbc.Driver&lt;/property&gt;
   &lt;property name="hibernate.connection.url"&gt;jdbc:mysql://localhost:3306/hibernate4&lt;/property&gt;
   &lt;property name="hibernate.connection.username"&gt;root&lt;/property&gt;
   &lt;property name="hibernate.connection.password"&gt;root&lt;/property&gt;
   &lt;property name="hibernate.connection.pool_size"&gt;10&lt;/property&gt;
   &lt;property name="show_sql"&gt;true&lt;/property&gt;
   &lt;property name="dialect"&gt;org.hibernate.dialect.MySQLDialect&lt;/property&gt;
   &lt;property name="hibernate.hbm2ddl.auto"&gt;update&lt;/property&gt;
   &lt;mapping resource="insurance.hbm.xml"/&gt;
  &lt;/session-factory&gt;
  </code></pre>
  
  <p></p>
  
  <p>Mapping file:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"&gt;
  
  &lt;hibernate-mapping&gt;
   &lt;class name="com.roseindia.app.HQL.Insurance" table="INSURANCE"&gt;
      &lt;id name="id" type="long" column="ID"&gt;
          &lt;generator class="increment"&gt;&lt;/generator&gt;
      &lt;/id&gt;
      &lt;property name="insuranceName"&gt;
          &lt;column name="INSURANCE_NAME"&gt;&lt;/column&gt;
      &lt;/property&gt;
      &lt;property name="investmentAmount"&gt;
          &lt;column name="INSURANCE_AMOUNT"&gt;&lt;/column&gt;
      &lt;/property&gt;
      &lt;property name="investmentDate"&gt;
          &lt;column name="INSURANCE_DATE"&gt;&lt;/column&gt;
      &lt;/property&gt; 
   &lt;/class&gt;
  &lt;/hibernate-mapping&gt;
  </code></pre>
  
  <p>POJO class:</p>
  
  <pre><code>public class Insurance {
  
  private Long id;
  private String insuranceName;
  private Integer investmentAmount;
  private Date investmentDate;
  
  public Long getId() {
      return id;
  }
  public void setId(Long id) {
      this.id = id;
  }
  public String getInsuranceName() {
      return insuranceName;
  }
  public void setInsuranceName(String insuranceName) {
      this.insuranceName = insuranceName;
  }
  public Integer getInvestmentAmount() {
      return investmentAmount;
  }
  public void setInvestmentAmount(Integer investmentAmount) {
      this.investmentAmount = investmentAmount;
  }
  public Date getInvestmentDate() {
      return investmentDate;
  }
  public void setInvestmentDate(Date investmentDate) {
      this.investmentDate = investmentDate;
  }
  }
  </code></pre>
  
  <p>main class:</p>
  
  <pre><code>public class SelectClauseExample {
  
  public static void main(String[] args) {
      // TODO Auto-generated method stub
  
      Session session =null;
  
      try{
  
          SessionFactory sessionFactory =new Configuration().configure().buildSessionFactory();
          session= sessionFactory.openSession();
  
          String SQL_QUERY="select insurance.id, insurance.insuranceName,insurance.investmentAmount,insurance.investmentDate from Insurance insurance";
  
          Query query = session.createQuery(SQL_QUERY);
  
          for (java.util.Iterator it = query.iterate(); it.hasNext();){
              System.out.print("Inside for");
              Object[] row = (Object[]) it.next();
              System.out.println("ID: "+row[0]);
              System.out.println("Name: "+row[1]);
              System.out.println("Amount: "+row[2]);
              System.out.println("Date: "+row[3]);
          }
  
  
      }catch(Exception e){
  
      }finally{
          session.flush();
          session.close();
  
      }
  
  }
  
  }
  </code></pre>