我需要检索结果并将fname和lname作为name列的单个值,我该怎么做?
ProjectionList pl = Projections.projectionList();
pl.add(Projections.property("user.id").as("id"));
pl.add(Projections.property("user.fname").as("fname"));
pl.add(Projections.property("user.lname").as("lname"));
当前输出
id fname lname
17 Alex Moore
34 Jack Segal
输出
id name
17 Alex Moore
34 Jack Segal
答案 0 :(得分:2)
最好的解决方案是使用HQL或SQL查询,如here
所述select
cat.weight + sum(kitten.weight)
from Cat cat
join cat.kittens kitten
group by cat.id, cat.weight