0

I have this HQL query:

from Usergroup as us join us.user

where Usergroup and User are both types. But when the data is fetched. It returns an ArrayList that contains Object[] that cotnain the Usergroup and the corresponding User.

Where as with from Usergroup returns an ArrayList of Usergroup objects...

Is there a way that I can return the former query as just an ArrayList of Usergroup objects like the latter query, I don't know why it returns an object array like that...?

user2405469
  • 1,953
  • 2
  • 22
  • 43
  • I don't really mind whether I get the data from the second table, the purpose of the join was get all of the users for a user group, yes you are right I could do that with a where clause instead...but is there a way to get an ArrayList containing Usergroup Objects instead of Object arrays containing both? it would be nice to know... I don't know what happened to the comment above this that I replied to... – user2405469 Nov 13 '14 at 12:41

1 Answers1

0

If you select more than one "thing", Hibernate will give you an array.

If you don't specify what you want to select from a join of two entities, it will give you both.

Try

select us from Usergroup as us join us.user
Thilo
  • 257,207
  • 101
  • 511
  • 656
  • I will accept this as the answer when the timer lets me, perfect, works great, In my mind I thought selecting all was the same as selecting "us" but then I forgot that this is working with objects not table properties. – user2405469 Nov 13 '14 at 12:49