ConstructorExpression创建querydsl

时间:2015-11-16 20:51:45

标签: querydsl

我正在尝试在查询中使用ConstructorExpression.create(RoleDto.class, role.id, BooleanTemplate.FALSE)。它抛出wrong number of arguments例外。

查询:

    JPAQuery roleQuery = new JPAQuery(em);
List<RoleDto> tupples = roleQuery
    .from(role)
    .where(role.techSupport.isFalse())
    .distinct()
    .list(ConstructorExpression.create(RoleDto.class, role.id, BooleanTemplate.FALSE));

RoleDto类:

public class RoleDto {

private String roleId;
private boolean bpmRole = false;

public RoleDto(Long roleId, Boolean bpmRole) {
    this.roleId = roleId+"";        
    this.bpmRole = bpmRole.booleanValue();
}

public String getRoleId() {
    return roleId;
}

}

此外,还有一个很容易将role.id从long转换为string。

0 个答案:

没有答案