First off, I'm really new to QueryDSL.
I am using Spring + Hibernate environment.
The problem I ran into is creating a GenericDAO to implement all the basic CRUD operations, but I'm not sure how to get a static link from QEntity.
My entity class structure is as follows:
@Entity //jpa public class Entity extends AbstractEntity{ //fields ... } public abstract class AbstractEntity{ //Logger }
The basic structure of an object created by QueryDSL
public class QEntity extends PEntity<Entity>{ ... public static final QEntity entity = new QEntity("entity"); ...
And GenericDao will look like this:
public class abstract GenericDao<T extends AbstractEntity, K extends PEntity<? extends AbstractEntity>>{
One approach would be to use Reflection, but I am not a proponent of using this method, especially in this case.
Another thing I'm not sure about is the mandatory use of a static link from QEntity to create queries, or is it ok if I make a contructor call to get a new object. Also, what does the string in the constructor parameter mean?
public QEntity(String variable) { this(Entity.class, forVariable(variable), INITS); }
java generics jpa dao querydsl
Alexandru Tomuta
source share