1

I need to retrieve results and put fname and lname as single values of name column, how can I do that?

     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"));

Current output

id  fname  lname
17  Alex   Moore
34  Jack   Segal

Output should be

id  name
17  Alex Moore
34  Jack Segal
1
  • 1
    System.out.println(user.getFirstName() + " " + user.getLastName()). Your database queries shouldn't mess with pure presentation logic. Commented Nov 21, 2013 at 7:33

1 Answer 1

2

The best solution for you would be to use either HQL or SQL queries as explained here

select 
cat.weight + sum(kitten.weight)
from Cat cat
    join cat.kittens kitten
group by cat.id, cat.weight
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.