[SOLVED] Hibernate HQL get all fields from a table as fields list and not as an object

Issue

This Content is from Stack Overflow. Question asked by Baiso

I need to get all values from a table and one more from another one, I am close to the solution but with the code below I got the object of the first table but I need the list of all fields:

select new map(t1 as tableOne, t2.day as tableTwoDay) from TableOne t1 left join t1.table2 t2  where ...

t1.* doesn’t work

Someone can help me?
Thanks



Solution

You already have all T1 fields: they are mapped as the value for key t1 of resulting map() ; you are using an ORM so working with objects is pretty natural.
If you need all T1 fields as single values in resulting map() just write something similar to:
select new map(T1.field1 as field1, T1.field2 as field2,...,T1.fieldN as fieldN)...

(untested code,just an idea)


This Question was asked in StackOverflow by Baiso and Answered by Luca Basso Ricci It is licensed under the terms of CC BY-SA 2.5. - CC BY-SA 3.0. - CC BY-SA 4.0.

people found this article helpful. What about you?