我已经看过像这样的JPQL查询
SELECT new path.to.dto.MyDto(e.id, e.otherProperty) FROM Student e WHERE e.id = ?1
我能用这种方式写点什么吗?
SELECT new path.to.dto.MyDto(e.id, new path.to.dto.OtherDTO) FROM Student e WHERE e.id = ?1
答案 0 :(得分:0)
也许你应该使用这样的查询:
SELECT new path.to.dto.MyDto(e.id, e.otherDtoParam1, e.otherDtoParam2,...) FROM Student e
并实现MyDto的构造函数:
public MyDto(Integer id, Object otherDtoParam1, Object otherDtoParam2, ...) {
this.id = id;
this.otherDto = new OtherDto(otherDtoParam1, otherDtoParam2, ...)
...
}