HQL query with @JoinCoumn mapping returns object[] instead of Object

52 views Asked by At

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...?

1

There are 1 answers

1
Thilo On BEST ANSWER

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