Spring Data JPA 查询结果返回至自定义实体

    @Query(value = "select new com.sinosoft.sinoep.modules.hygl.meetingApply.dto.MeetingNumDto(a.creJuName as name,count(a.creJuName) as value) from MeetingApply as a where a.creUserDeptUnitType in ('0','6','7') and a.meetingRoomId != 'outside' and a.visible = '1' group by a.creJuName")
    List<MeetingNumDto> getNationalInsideMeetingNum();

DTO类

public class MeetingNumDto implements Serializable {

    private String name;
    private Long value;

    public MeetingNumDto() {
    }

    public MeetingNumDto(String name, Long value) {
        this.name = name;
        this.value = value;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Long getValue() {
        return value;
    }

    public void setValue(Long value) {
        this.value = value;
    }
}

posted @ 2021-06-28 14:10  GKGKGK  阅读(227)  评论(0编辑  收藏  举报