Comment 3 for bug 500163

Revision history for this message
Timo Westkämper (timo-westkamper) wrote :

For the moment using QueryInit is the way to go. It is a declarative approach and enables path initializations for types instead of type instances, which is an advantage in our opinion.

As for your example, it can be expressived with QueryInit without a reference to the property :

QEntity.entity.link1.link2

Entity {
   @QueryInit("*")
   private QLink1 link1;
}

Declarating the initializations directly in the property context instead of package context reduces the amount of String based references, as the declaring type and annoted property define already some context.

Btw, every annotation can be considered a "pollution" of the host class. Querydsl annotations are in no way inferior annotations compared to JPA or Hibernate annotations.

If using QueryInit is for some reason no option to you can fall back to using HQL inner joins, they are supported in Querydsl and reduce issues with long paths.

Merry christmas!