how to write join query in hibernate

To add to gid's answer, if for some reason you need to eagerly fetch an entites relations, then the join syntax would be join fetch.

from VirtualDomain vd join fetch vd.usersset u 
   where vd.domainname = 'example.com' and u.username like 'foo%'

Always difficult to write HQL without a test system...but here we go:

select u from VirtualDomain vd join User vd.usersset u 
       where vd.domainname = 'example.com' and u.username like 'foo%'

Let me know how you get on.

One tip I often did prior to buying Intellji was to stop the app in the debugger and then use the immediate window to experiment with HQL.

The hibernate documentation on joins has always been a bit cryptic in my opinion.

Tags:

Java

Hibernate