有如下段代碼 其中person是jpa的entity對象,personResult是自定義對象
@Query(select new com.xx.yy.PersonResult(p.id,p.name,p.age) from Person p)
List<PersonResult> findPersonResult();
這樣執行是可以的,但是如果我其中的personResult對象中的id是叫personId,上面的代碼該如何改?
我用過
@Query(select new com.xx.yy.PersonResult(p.id as personId,p.name,p.age) from Person p)
List<PersonResult> findPersonResult();
會報錯,是不是jpql new對象的時候不支持別名嗎?
添加回答
舉報
0/150
提交
取消