在注解Query中可以直接new对象
@Query("select new com.mytest.vo.VideoVO(u.id,v.userId,v.audioId,v.videoDesc,v.videoPath,v.videoSeconds,v.videoWidth,v.videoHeight) from Video v,User u where v.userId = u.id")
public List<VideoVO> findVideoWithAuthor();
之后添加对象的构造方法接解决了
public VideoVO(String id, String userId, String audioId, String videoDesc, String videoPath, Float videoSeconds, Integer videoWidth, Integer videoHeight) {
this.id = id;
this.userId = userId;
this.audioId = audioId;
this.videoDesc = videoDesc;
this.videoPath = videoPath;
this.videoSeconds = videoSeconds;
this.videoWidth = videoWidth;
this.videoHeight = videoHeight;
}
如果有分页的话,还是和以前一样,传入Pageable对象流程和以前一样!