title: How do I build a GenericDao using QueryDSL?
body: <p>First of, I am really new to QueryDSL.</p>
  
  <p>I'm using a Spring + Hibernate environment.</p>
  
  <p>The problem I'm facing is with building a GenericDAO to implement all the basic CRUD operations, but I'm not sure how do I get the static reference from a QEntity.</p>
  
  <p>My entity class structure looks like this:</p>
  
  <pre><code>    @Entity //jpa
      public class Entity extends AbstractEntity{
      //fields
      ...
      }
  
      public abstract class AbstractEntity{
      //Logger 
      }
  </code></pre>
  
  <p>The basic structure of a QueryDSL-generated entity</p>
  
  <pre><code>    public class QEntity extends PEntity&lt;Entity&gt;{
      ...
      public static final QEntity entity = new QEntity("entity");        
      ...
      //constructors
  
      } 
  </code></pre>
  
  <p>And the GenericDao would look like this:</p>
  
  <pre><code>    public class abstract GenericDao&lt;T extends AbstractEntity, K extends PEntity&lt;? extends AbstractEntity&gt;&gt;{
  
      //some kind of method to get the K.k (QEntity.entity) reference.        
      //CRUD operations using T and K
  
      }
  </code></pre>
  
  <p>One approach would be using Reflection, but I'm not an advocate of using that method, especially in this case.</p>
  
  <p>Another thing that I'm not sure of, is it mandatory to use the static reference from a QEntity to build queries or is it ok if I do a contructor call to get a new object. Also, what does the String in the constructor parameter signify?</p>
  
  <pre><code>    public QEntity(String variable) {
      this(Entity.class, forVariable(variable), INITS);
      }
  </code></pre>