title: How to work with tables without PRIMARY KEY in Hibernate?
body: <p>i have table </p>
  
  <pre><code>CREATE TABLE test_wopk
  (
    id integer,
    "name" character(25),
    age integer
  )
  </code></pre>
  
  <p>After Reverse Ingeniring in hibernate i get a classes and mapping file.</p>
  
  <p>TestWopk.java</p>
  
  <pre><code>package gen;
  
  // Generated 16.08.2012 14:08:26 by Hibernate Tools 3.4.0.CR1
  
  /**
   * TestWopk generated by hbm2java
   */
  public class TestWopk implements java.io.Serializable
  {
  
  private TestWopkId id;
  
  public TestWopk()
  {
  }
  
  public TestWopk(TestWopkId id)
  {
      this.id = id;
  }
  
  public TestWopkId getId()
  {
      return this.id;
  }
  
  public void setId(TestWopkId id)
  {
      this.id = id;
  }
  
  }
  </code></pre>
  
  <p>TestWopkId.java</p>
  
  <pre><code>package gen;
  
  // Generated 16.08.2012 14:08:26 by Hibernate Tools 3.4.0.CR1
  
  /**
   * TestWopkId generated by hbm2java
   */
  public class TestWopkId implements java.io.Serializable
  {
  
  private Integer id;
  private String name;
  private Integer age;
  
  public TestWopkId()
  {
  }
  
  public TestWopkId(Integer id, String name, Integer age)
  {
      this.id = id;
      this.name = name;
      this.age = age;
  }
  
  public Integer getId()
  {
      return this.id;
  }
  
  public void setId(Integer id)
  {
      this.id = id;
  }
  
  public String getName()
  {
      return this.name;
  }
  
  public void setName(String name)
  {
      this.name = name;
  }
  
  public Integer getAge()
  {
      return this.age;
  }
  
  public void setAge(Integer age)
  {
      this.age = age;
  }
  
  public boolean equals(Object other)
  {
      if ((this == other))
          return true;
      if ((other == null))
          return false;
      if (!(other instanceof TestWopkId))
          return false;
      TestWopkId castOther = (TestWopkId) other;
  
      return ((this.getId() == castOther.getId()) || (this.getId() != null &amp;&amp; castOther.getId() != null &amp;&amp; this.getId()
              .equals(castOther.getId())))
              &amp;&amp; ((this.getName() == castOther.getName()) || (this.getName() != null &amp;&amp; castOther.getName() != null &amp;&amp; this
                      .getName().equals(castOther.getName())))
              &amp;&amp; ((this.getAge() == castOther.getAge()) || (this.getAge() != null &amp;&amp; castOther.getAge() != null &amp;&amp; this
                      .getAge().equals(castOther.getAge())));
  }
  
  public int hashCode()
  {
      int result = 17;
  
      result = 37 * result + (getId() == null ? 0 : this.getId().hashCode());
      result = 37 * result + (getName() == null ? 0 : this.getName().hashCode());
      result = 37 * result + (getAge() == null ? 0 : this.getAge().hashCode());
      return result;
  }
  
  }
  </code></pre>
  
  <p>TestWopk.hbm.xml</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 16.08.2012 14:08:26 by Hibernate Tools 3.4.0.CR1 --&gt;
  &lt;hibernate-mapping&gt;
  &lt;class name="gen.TestWopk" table="test_wopk"&gt;
      &lt;composite-id name="id" class="gen.TestWopkId"&gt;
          &lt;key-property name="id" type="java.lang.Integer"&gt;
              &lt;column name="id" /&gt;
          &lt;/key-property&gt;
          &lt;key-property name="name" type="string"&gt;
              &lt;column name="name" length="25" /&gt;
          &lt;/key-property&gt;
          &lt;key-property name="age" type="java.lang.Integer"&gt;
              &lt;column name="age" /&gt;
          &lt;/key-property&gt;
      &lt;/composite-id&gt;
  &lt;/class&gt;
  &lt;/hibernate-mapping&gt;
  </code></pre>
  
  <p>Iwant to get data from db.</p>
  
  <pre><code>    Session session = HibernateUtil.currentSession();
  
      Transaction tx= session.beginTransaction();
      //чтение из бд
       List list = session.createQuery("from TestWopk").list();
   Iterator itr = list.iterator();
   while(itr.hasNext()){
     TestWopk test = (TestWopk) itr.next();
     System.out.print("EmpName: "+ test.getId());
     System.out.print(" EmpSal: "+ test.getName());
     System.out.print(" EmpSal: "+ test.getAge());
     System.out.println();
   }
      tx.commit();
  
      HibernateUtil.closeSession();
  </code></pre>
  
  <p>And get Error</p>
  
  <pre><code>Exception in thread "main" java.lang.Error: Unresolved compilation problems: 
  The method getName() is undefined for the type TestWopk
  The method getAge() is undefined for the type TestWopk
  
  at net.sf.hibernate.examples.quickstart.hib_main.main(hib_main.java:67)
  </code></pre>
  
  <p>Tell me please how to work with classes which was generated by hibernate?</p>