I was just wondering if a query looking like this is valid:
Code:
select new UserBean(user.username, user.password, (select friends from FriendBean friend where friend.user.id = id and friend.age>12)) from UserBean user where username='ragnar'
That is, having a new object created with a subquery result as constructor parameter. When I try it, I get
Code:
org.hibernate.hql.ast.QuerySyntaxError: Unable to locate appropriate constructor...
So I'm wondering if this type of query is implemented in hql, and if so, what else could be wrong. (There is indeed a valid and appropriate constructor in UserBean). The query is just an example, so suggested workarounds might not be suitable.