Is it thread-safe to use QueryDsl query entities like the following
public class MyDaoImpl implements MyDao {
private static final QEntity entity = QEntity.entity;
public List<Entity> entities() {
return new JPAQuery(em).from(entity).list(entity);
}
public List<Entity> otherEntities() {
return new JPAQuery(em).from(entity).where(entity.foo.isNull()).list(entity);
}
}
As opposed to:
public class MyDaoImpl implements MyDao {
public List<Entity> entities() {
QEntity entity = QEntity.entity;
return new JPAQuery(em).from(entity).list(entity);
}
public List<Entity> otherEntities() {
QEntity entity = QEntity.entity;
return new JPAQuery(em).from(entity).where(entity.foo.isNull()).list(entity);
}
}
Found the answer from this Google Groups discussion
In short,
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With