First of, I am really new to QueryDSL.
I'm using a Spring + Hibernate environment.
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.
My entity class structure looks like this:
@Entity //jpa
public class Entity extends AbstractEntity{
//fields
...
}
public abstract class AbstractEntity{
//Logger
}
The basic structure of a QueryDSL-generated entity
public class QEntity extends PEntity<Entity>{
...
public static final QEntity entity = new QEntity("entity");
...
//constructors
}
And the GenericDao would look like this:
public class abstract GenericDao<T extends AbstractEntity, K extends PEntity<? extends AbstractEntity>>{
//some kind of method to get the K.k (QEntity.entity) reference.
//CRUD operations using T and K
}
One approach would be using Reflection, but I'm not an advocate of using that method, especially in this case.
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?
public QEntity(String variable) {
this(Entity.class, forVariable(variable), INITS);
}