com.mysema.query.annotations
Annotation Type QueryProjection


@Documented
@Target(value=CONSTRUCTOR)
@Retention(value=RUNTIME)
public @interface 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 = query.from(user)
     .where(user.valid.eq(true))
     .list(new QUserInfo(user.firstName, user.lastName));
     
 



Copyright © 2007-2012 Mysema Ltd. All Rights Reserved.