title: Hibernate: getting too many rows
body: <p>I have problem with getting rows from my database using Hibernate. When I would like to get only one row, I am receiving 20. When I would like to get all of rows from table with about 1.5k rows, I am receiving exactly 15.2k rows.
  Entity class of this table has composite primary key.</p>
  
  <p>This is my code for getting all rows:</p>
  
  <pre><code>Criteria criteria = getSession().createCriteria(type);
  criteria.setCacheable(true).setCacheRegion(BaseEntity.PACKAGE);
  criteria.list();
  </code></pre>
  
  <p>And this is my Entity class:</p>
  
  <pre><code>@javax.persistence.Entity
  @Table(name = "my_table")
  public class My extends MyEntity&lt;MyPK&gt; {
  
      @EmbeddedId
      private MyPK id;
  
      @Column(name = "text", nullable = false)
      protected String text;
  
      @ManyToOne
      @JoinColumn(name = "property", nullable = false, insertable = false, updatable = false)
      protected Option option;
  
      @Override
      public MyPK getId() {
          return id;
      }
  
      @Override
      public void setId(MyPK id) {
          this.id = id;
      }
  
      //getters and setter
  }
  </code></pre>
  
  <p>And this is <code>MyPK</code> class:</p>
  
  <pre><code>@Embeddable
  public class MyPK implements Serializable {
  
     @Column(name = "qwerty")
     protected String qwerty;
  
     @Column(name = "property")
     protected String property;
  
     //constructors, getters and setters
  }
  </code></pre>
  
  <p><code>MyEntity</code> class is abstract class with <code>@MappedSuperclass</code> annotation. This is this class header:    </p>
  
  <pre><code>@MappedSuperclass
  public abstract class MyEntity&lt;T extends Serializable&gt;
  </code></pre>
  
  <p>What am I doing wrong? Is this problem with <code>EmbeddedId</code>?</p>
  
  <p><strong>EDIT #1</strong>
  As I have realized this is problem with this: </p>
  
  <pre><code>@ManyToOne
  @JoinColumn(name = "property", nullable = false, insertable = false, updatable = false)
  protected Option option;
  </code></pre>
  
  <p>This object contains foreign key to another table. And this another table has reference to another. And this last table has 10 rows for previous table. In the result I am getting rows amount * 10. The problem is probably with Hibernate annotation in my entities.</p>