Use the default variables of the query types as much as possible. The default variables are available as static final fields in the query types. The name is always the decaptialized version of the simple type name. For the type Account this would be account :
QAccount extends PEntity<Account>{ public static final Account account = new QAccount("account"); }
Querydsl query types are safe to re-use, and by using Querydsl default variables you save initialization time and memory.
Whenever possible, use interface based query references : JDOQLQuery for JDO and HQLQuery for HQL
A practice which we have found to be very easy to use is to provide factory methods for Query instances in DAO implementations in the following form.
For HQL usage :
protected HQLQuery from(PEntity<?>... o) { return new HqlQueryImpl(session).from(o); }
For JDO usage :
protected JDOQLQuery from(PEntity<?>... o) { return new JDOQLQueryImpl(persistenceManager).from(o); }