Package com.querydsl.core.annotations
Annotation Type QueryProjection
Annotation for APT based query type generation. Annotate constructors with this annotation.
Example
class UserInfo {
private String firstName, lastName;
@QueryProjection
public UserInfo(String firstName, String lastName) {
this.firstName = firstName;
this.lastName = lastName;
}
// getters and setters
}
The projection can then be used like this
QUser user = QUser.user;
List <UserInfo> result = querydsl.from(user)
.where(user.valid.eq(true))
.select(new QUserInfo(user.firstName, user.lastName))
.fetch();